NotOperatorWithSpaceFixerTest.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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\Operator;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @author Javier Spagnoletti <phansys@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\Operator\NotOperatorWithSpaceFixer
  20. */
  21. final class NotOperatorWithSpaceFixerTest extends AbstractFixerTestCase
  22. {
  23. /**
  24. * @dataProvider provideFixCases
  25. */
  26. public function testFix(string $expected, ?string $input = null): void
  27. {
  28. $this->doTest($expected, $input);
  29. }
  30. public static function provideFixCases(): iterable
  31. {
  32. return [
  33. [
  34. '<?php $i = 0; $i++; ++$i; $foo = ! false || ( ! true);',
  35. '<?php $i = 0; $i++; ++$i; $foo = !false || (!true);',
  36. ],
  37. [
  38. '<?php $i = 0; $i--; --$i; $foo = ! false || ($i && ! true);',
  39. '<?php $i = 0; $i--; --$i; $foo = !false || ($i && !true);',
  40. ],
  41. [
  42. '<?php $i = 0; $i--; $foo = ! false || ($i && ! /* some comment */true);',
  43. '<?php $i = 0; $i--; $foo = !false || ($i && !/* some comment */true);',
  44. ],
  45. [
  46. '<?php $i = 0; $i--; $foo = ! false || ($i && ! true);',
  47. '<?php $i = 0; $i--; $foo = !false || ($i && ! true);',
  48. ],
  49. [
  50. '<?php $i = 0; $i--; $foo = ! false || ($i && ! true);',
  51. '<?php $i = 0; $i--; $foo = !false || ($i && ! true);',
  52. ],
  53. ];
  54. }
  55. }