LogicalOperatorsFixerTest.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 Haralan Dobrev <hkdobrev@gmail.com>
  16. *
  17. * @internal
  18. *
  19. * @covers \PhpCsFixer\Fixer\Operator\LogicalOperatorsFixer
  20. *
  21. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\Operator\LogicalOperatorsFixer>
  22. */
  23. final class LogicalOperatorsFixerTest extends AbstractFixerTestCase
  24. {
  25. /**
  26. * @dataProvider provideFixCases
  27. */
  28. public function testFix(string $expected, string $input): void
  29. {
  30. $this->doTest($expected, $input);
  31. }
  32. /**
  33. * @return iterable<array{string, string}>
  34. */
  35. public static function provideFixCases(): iterable
  36. {
  37. yield [
  38. '<?php if ($a == "foo" && $b == "bar") {}',
  39. '<?php if ($a == "foo" and $b == "bar") {}',
  40. ];
  41. yield [
  42. '<?php if ($a == "foo" || $b == "bar") {}',
  43. '<?php if ($a == "foo" or $b == "bar") {}',
  44. ];
  45. yield [
  46. '<?php if ($a == "foo" && ($b == "bar" || $c == "baz")) {}',
  47. '<?php if ($a == "foo" and ($b == "bar" or $c == "baz")) {}',
  48. ];
  49. yield [
  50. '<?php if ($a == "foo" && ($b == "bar" || $c == "baz")) {}',
  51. '<?php if ($a == "foo" and ($b == "bar" || $c == "baz")) {}',
  52. ];
  53. yield [
  54. '<?php if ($a == "foo" && ($b == "bar" || $c == "baz")) {}',
  55. '<?php if ($a == "foo" && ($b == "bar" or $c == "baz")) {}',
  56. ];
  57. yield [
  58. '<?php if ($a == "foo" && ($b == "bar" || $c == "baz")) {}',
  59. '<?php if ($a == "foo" AND ($b == "bar" OR $c == "baz")) {}',
  60. ];
  61. yield [
  62. '<?php if ($a == "foo" && ($b == "bar" || $c == "baz")) {}',
  63. '<?php if ($a == "foo" and ($b == "bar" OR $c == "baz")) {}',
  64. ];
  65. yield [
  66. '<?php if ($a == "foo" && ($b == "bar" || $c == "baz")) {}',
  67. '<?php if ($a == "foo" AND ($b == "bar" or $c == "baz")) {}',
  68. ];
  69. }
  70. }