EofEndingFixerTest.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Fixer\PSR2;
  11. use Symfony\CS\Tests\Fixer\AbstractFixerTestBase;
  12. /**
  13. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  14. */
  15. class EofEndingFixerTest extends AbstractFixerTestBase
  16. {
  17. /**
  18. * @dataProvider provideCases
  19. */
  20. public function testFix($expected, $input = null)
  21. {
  22. $this->makeTest($expected, $input);
  23. }
  24. public function provideCases()
  25. {
  26. return array(
  27. array(
  28. '',
  29. ),
  30. array(
  31. "<?php\n",
  32. ),
  33. array(
  34. '<?php
  35. $a = 1;
  36. ',
  37. '<?php
  38. $a = 1;',
  39. ),
  40. array(
  41. '<?php
  42. $a = 2;
  43. ',
  44. ),
  45. array(
  46. '<?php
  47. $a = 3;
  48. ',
  49. '<?php
  50. $a = 3;
  51. ',
  52. ),
  53. array(
  54. "<?php\r\n\$a = 4;\n",
  55. "<?php\r\n\$a = 4;",
  56. ),
  57. array(
  58. // test not changing line break characters,
  59. // this is not the responsibility of this fixer
  60. "<?php\r\n\$a = 5;\r\n",
  61. "<?php\r\n\$a = 5;\r\n \r\n",
  62. ),
  63. array(
  64. '<?php
  65. $a = 6;
  66. //test
  67. ?>
  68. ', ),
  69. array(
  70. // test for not adding an empty line after PHP tag has been closed
  71. '<?php
  72. $a = 7;
  73. //test
  74. ?>', ),
  75. array(
  76. // test for not adding an empty line after PHP tag has been closed
  77. '<?php
  78. $a = 8;
  79. //test
  80. ?>
  81. Outside of PHP tags rendering
  82. ', ),
  83. array(
  84. // test for not adding an empty line after PHP tag has been closed
  85. "<?php
  86. //test
  87. ?>
  88. inline 1
  89. <?php
  90. ?>Inline2\r\n", ),
  91. );
  92. }
  93. }