LogicalOperatorsFixerTest.php 2.2 KB

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