NoSinglelineWhitespaceBeforeSemicolonsFixerTest.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4. * This file is part of PHP CS Fixer.
  5. *
  6. * (c) Fabien Potencier <fabien@symfony.com>
  7. * Dariusz Rumiński <dariusz.ruminski@gmail.com>
  8. *
  9. * This source file is subject to the MIT license that is bundled
  10. * with this source code in the file LICENSE.
  11. */
  12. namespace PhpCsFixer\Tests\Fixer\Semicolon;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author John Kelly <wablam@gmail.com>
  16. * @author Graham Campbell <hello@gjcampbell.co.uk>
  17. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  18. *
  19. * @internal
  20. *
  21. * @covers \PhpCsFixer\Fixer\Semicolon\NoSinglelineWhitespaceBeforeSemicolonsFixer
  22. */
  23. final class NoSinglelineWhitespaceBeforeSemicolonsFixerTest extends AbstractFixerTestCase
  24. {
  25. /**
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix(string $expected, ?string $input = null): void
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. public static function provideFixCases(): iterable
  33. {
  34. yield [
  35. '<?php for ($uu = 0; ; ++$uu) {}',
  36. '<?php for ($uu = 0 ; ; ++$uu) {}',
  37. ];
  38. yield [
  39. '<?php
  40. $this
  41. ->setName(\'readme1\')
  42. ->setDescription(\'Generates the README content, based on the fix command help\')
  43. ;',
  44. ];
  45. yield [
  46. '<?php
  47. $this
  48. ->setName(\'readme2\')
  49. ->setDescription(\'Generates the README content, based on the fix command help\')
  50. ;',
  51. ];
  52. yield [
  53. '<?php echo "$this->foo(\'with param containing ;\') ;";',
  54. '<?php echo "$this->foo(\'with param containing ;\') ;" ;',
  55. ];
  56. yield [
  57. '<?php $this->foo();',
  58. '<?php $this->foo() ;',
  59. ];
  60. yield [
  61. '<?php $this->foo(\'with param containing ;\');',
  62. '<?php $this->foo(\'with param containing ;\') ;',
  63. ];
  64. yield [
  65. '<?php $this->foo(\'with param containing ) ; \');',
  66. '<?php $this->foo(\'with param containing ) ; \') ;',
  67. ];
  68. yield [
  69. '<?php $this->foo("with param containing ) ; ");',
  70. '<?php $this->foo("with param containing ) ; ") ;',
  71. ];
  72. yield [
  73. '<?php
  74. $foo
  75. ->bar(1)
  76. ->baz(2)
  77. ;',
  78. ];
  79. yield [
  80. '<?php
  81. $foo
  82. ->bar(1)
  83. //->baz(2)
  84. ;',
  85. ];
  86. yield [
  87. '<?php $this->foo("with semicolon in string) ; ");',
  88. ];
  89. }
  90. }