AbstractMigrationSetDescriptionTest.php 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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\RuleSet;
  13. use PhpCsFixer\RuleSet\AbstractMigrationSetDescription;
  14. use PhpCsFixer\Tests\TestCase;
  15. /**
  16. * @internal
  17. *
  18. * @covers \PhpCsFixer\RuleSet\AbstractMigrationSetDescription
  19. */
  20. final class AbstractMigrationSetDescriptionTest extends TestCase
  21. {
  22. public function testGetDescriptionForPhpMigrationSet(): void
  23. {
  24. $set = new class extends AbstractMigrationSetDescription {
  25. public function getName(): string
  26. {
  27. return '@PHP99MigrationSet';
  28. }
  29. public function getRules(): array
  30. {
  31. return [];
  32. }
  33. };
  34. self::assertSame('Rules to improve code for PHP 9.9 compatibility.', $set->getDescription());
  35. }
  36. public function testGetDescriptionForPhpUnitMigrationSet(): void
  37. {
  38. $set = new class extends AbstractMigrationSetDescription {
  39. public function getName(): string
  40. {
  41. return '@PHPUnit30Migration';
  42. }
  43. public function getRules(): array
  44. {
  45. return [];
  46. }
  47. };
  48. self::assertSame('Rules to improve tests code for PHPUnit 3.0 compatibility.', $set->getDescription());
  49. }
  50. public function testGetDescriptionForNoneMigrationSet(): void
  51. {
  52. $set = new class extends AbstractMigrationSetDescription {
  53. public function getName(): string
  54. {
  55. return 'foo';
  56. }
  57. public function getRules(): array
  58. {
  59. return [];
  60. }
  61. };
  62. $this->expectException(\RuntimeException::class);
  63. $this->expectExceptionMessageMatches('/^Cannot generate description for ".*" "foo"\.$/');
  64. $set->getDescription();
  65. }
  66. }