PhpUnitAssertNewNamesFixerTest.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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\PhpUnit;
  13. use PhpCsFixer\Tests\Test\AbstractFixerTestCase;
  14. /**
  15. * @internal
  16. *
  17. * @covers \PhpCsFixer\Fixer\PhpUnit\PhpUnitAssertNewNamesFixer
  18. *
  19. * @extends AbstractFixerTestCase<\PhpCsFixer\Fixer\PhpUnit\PhpUnitAssertNewNamesFixer>
  20. */
  21. final class PhpUnitAssertNewNamesFixerTest 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. /**
  31. * @return iterable<array{0: string, 1: string}>
  32. */
  33. public static function provideFixCases(): iterable
  34. {
  35. yield [
  36. self::generateTest(
  37. '
  38. $this->assertFileDoesNotExist($a);
  39. $this->assertIsNotReadable($a);
  40. $this->assertIsNotWritable($a);
  41. $this->assertDirectoryDoesNotExist($a);
  42. $this->assertDirectoryIsNotReadable($a);
  43. $this->assertDirectoryIsNotWriteable($a);
  44. $this->assertFileIsNotReadable($a);
  45. $this->assertFileIsNotWriteable($a);
  46. $this->assertMatchesRegularExpression($a);
  47. $this->assertDoesNotMatchRegularExpression($a);
  48. '
  49. ),
  50. self::generateTest(
  51. '
  52. $this->assertFileNotExists($a);
  53. $this->assertNotIsReadable($a);
  54. $this->assertNotIsWritable($a);
  55. $this->assertDirectoryNotExists($a);
  56. $this->assertDirectoryNotIsReadable($a);
  57. $this->assertDirectoryNotIsWritable($a);
  58. $this->assertFileNotIsReadable($a);
  59. $this->assertFileNotIsWritable($a);
  60. $this->assertRegExp($a);
  61. $this->assertNotRegExp($a);
  62. '
  63. ),
  64. ];
  65. }
  66. private static function generateTest(string $content): string
  67. {
  68. return "<?php final class FooTest extends \\PHPUnit_Framework_TestCase {\n public function testSomething() {\n ".$content."\n }\n}\n";
  69. }
  70. }