PhpUnitStrictFixerTest.php 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /*
  3. * This file is part of the PHP CS utility.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\CS\Tests\Fixer\Contrib;
  11. use Symfony\CS\Tests\Fixer\AbstractFixerTestBase;
  12. /**
  13. * @author Dariusz Rumiński <dariusz.ruminski@gmail.com>
  14. */
  15. class PhpUnitStrictFixerTest extends AbstractFixerTestBase
  16. {
  17. /**
  18. * @dataProvider provideTestFixCases
  19. */
  20. public function testFix($expected, $input = null)
  21. {
  22. $this->makeTest($expected, $input);
  23. }
  24. public function provideTestFixCases()
  25. {
  26. $fixerReflection = new \ReflectionClass($this->getFixer());
  27. $propertyReflection = $fixerReflection->getProperty('configuration');
  28. $propertyReflection->setAccessible(true);
  29. $methodsMap = $propertyReflection->getValue($this->getFixer());
  30. $cases = array(
  31. array('<?php $self->foo();'),
  32. );
  33. foreach ($methodsMap as $methodBefore => $methodAfter) {
  34. $cases[] = array("<?php \$sth->$methodBefore(1, 1);");
  35. $cases[] = array("<?php \$sth->$methodAfter(1, 1);");
  36. $cases[] = array(
  37. "<?php \$this->$methodAfter(1, 2);",
  38. "<?php \$this->$methodBefore(1, 2);",
  39. );
  40. $cases[] = array(
  41. "<?php \$this->$methodAfter(1, 2); \$this->$methodAfter(1, 2);",
  42. "<?php \$this->$methodBefore(1, 2); \$this->$methodBefore(1, 2);",
  43. );
  44. $cases[] = array(
  45. "<?php \$this->$methodAfter(1, 2, 'descr');",
  46. "<?php \$this->$methodBefore(1, 2, 'descr');",
  47. );
  48. $cases[] = array(
  49. "<?php \$this->/*aaa*/$methodAfter \t /**bbb*/ ( /*ccc*/1 , 2);",
  50. "<?php \$this->/*aaa*/$methodBefore \t /**bbb*/ ( /*ccc*/1 , 2);",
  51. );
  52. $cases[] = array(
  53. "<?php \$this->$methodAfter(\$expectedTokens->count() + 10, \$tokens->count() ? 10 : 20 , 'Test');",
  54. "<?php \$this->$methodBefore(\$expectedTokens->count() + 10, \$tokens->count() ? 10 : 20 , 'Test');",
  55. );
  56. }
  57. return $cases;
  58. }
  59. }