PageRenderTime 377ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/Symfony/CS/Tests/Fixer/PSR2/PhpClosingTagFixerTest.php

http://github.com/fabpot/PHP-CS-Fixer
PHP | 117 lines | 93 code | 9 blank | 15 comment | 1 complexity | 0685819694e7b1fa8107b075d28b23c8 MD5 | raw file
  1. <?php
  2. /*
  3. * This file is part of PHP CS Fixer.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. * Dariusz RumiƄski <dariusz.ruminski@gmail.com>
  7. *
  8. * This source file is subject to the MIT license that is bundled
  9. * with this source code in the file LICENSE.
  10. */
  11. namespace Symfony\CS\Tests\Fixer\PSR2;
  12. use Symfony\CS\Tests\Fixer\AbstractFixerTestBase;
  13. class PhpClosingTagFixerTest extends AbstractFixerTestBase
  14. {
  15. /**
  16. * @dataProvider provideCasesWithFullOpenTag
  17. */
  18. public function testCasesWithFullOpenTag($expected, $input = null)
  19. {
  20. $this->makeTest($expected, $input);
  21. }
  22. /**
  23. * @dataProvider provideCasesWithShortOpenTag
  24. */
  25. public function testCasesWithShortOpenTag($expected, $input = null)
  26. {
  27. if (!ini_get('short_open_tag')) {
  28. $this->markTestSkipped('PHP short open tags are not enabled.');
  29. return;
  30. }
  31. $this->makeTest($expected, $input);
  32. }
  33. public function provideCasesWithFullOpenTag()
  34. {
  35. return array(
  36. array('<?php echo \'Foo\';', '<?php echo \'Foo\'; ?>'),
  37. array('<?php echo \'Foo\';', '<?php echo \'Foo\';?>'),
  38. array('<?php echo \'Foo\'; ?> PLAIN TEXT'),
  39. array('PLAIN TEXT<?php echo \'Foo\'; ?>'),
  40. array('<?php
  41. echo \'Foo\';',
  42. '<?php
  43. echo \'Foo\';
  44. ?>',
  45. ),
  46. array('<?php echo \'Foo\'; ?>
  47. <p><?php echo \'this is a template\'; ?></p>
  48. <?php echo \'Foo\'; ?>',
  49. ),
  50. array('<?php echo "foo";', '<?php echo "foo" ?>'),
  51. array(
  52. '<?php
  53. class foo
  54. {
  55. public function bar()
  56. {
  57. echo "Here I am!";
  58. }
  59. }',
  60. '<?php
  61. class foo
  62. {
  63. public function bar()
  64. {
  65. echo "Here I am!";
  66. }
  67. }?>',
  68. ),
  69. array(
  70. '<?php
  71. function bar()
  72. {
  73. echo "Here I am!";
  74. }',
  75. '<?php
  76. function bar()
  77. {
  78. echo "Here I am!";
  79. }?>',
  80. ),
  81. array(
  82. '<?php
  83. if (true) {
  84. echo "Here I am!";
  85. }',
  86. '<?php
  87. if (true) {
  88. echo "Here I am!";
  89. }?>',
  90. ),
  91. );
  92. }
  93. public function provideCasesWithShortOpenTag()
  94. {
  95. return array(
  96. array('<? echo \'Foo\';', '<? echo \'Foo\'; ?>'),
  97. array('<? echo \'Foo\';', '<? echo \'Foo\';?>'),
  98. array('<? echo \'Foo\'; ?>
  99. <p><? echo \'this is a template\'; ?></p>
  100. <? echo \'Foo\'; ?>',
  101. ),
  102. array('<?= "somestring"; ?> <?= "anotherstring"; ?>'),
  103. );
  104. }
  105. }