123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- <?php
- declare(strict_types=1);
- namespace PhpCsFixer\Tests\DocBlock;
- use PhpCsFixer\DocBlock\Line;
- use PhpCsFixer\DocBlock\Tag;
- use PhpCsFixer\DocBlock\TagComparator;
- use PhpCsFixer\Tests\TestCase;
- final class TagComparatorTest extends TestCase
- {
-
- public function testComparatorTogether(string $first, string $second, bool $expected): void
- {
- $tag1 = new Tag(new Line('* @'.$first));
- $tag2 = new Tag(new Line('* @'.$second));
- $this->expectDeprecation('%AMethod PhpCsFixer\DocBlock\TagComparator::shouldBeTogether is deprecated and will be removed in version 4.0.');
- self::assertSame($expected, TagComparator::shouldBeTogether($tag1, $tag2));
- }
- public static function provideComparatorTogetherCases(): iterable
- {
- yield ['return', 'return', true];
- yield ['param', 'param', true];
- yield ['return', 'param', false];
- yield ['var', 'foo', false];
- yield ['api', 'deprecated', false];
- yield ['author', 'copyright', true];
- yield ['author', 'since', false];
- yield ['link', 'see', true];
- yield ['category', 'package', true];
- }
-
- public function testComparatorTogetherWithDefinedGroups(array $groups, string $first, string $second, bool $expected): void
- {
- $tag1 = new Tag(new Line('* @'.$first));
- $tag2 = new Tag(new Line('* @'.$second));
- $this->expectDeprecation('%AMethod PhpCsFixer\DocBlock\TagComparator::shouldBeTogether is deprecated and will be removed in version 4.0.');
- self::assertSame(
- $expected,
- TagComparator::shouldBeTogether($tag1, $tag2, $groups)
- );
- }
- public static function provideComparatorTogetherWithDefinedGroupsCases(): iterable
- {
- yield [[['param', 'return']], 'return', 'return', true];
- yield [[], 'param', 'return', false];
- yield [[['param', 'return']], 'return', 'param', true];
- yield [[['param', 'return']], 'var', 'foo', false];
- yield [[['param', 'return']], 'api', 'deprecated', false];
- yield [[['param', 'return']], 'author', 'copyright', false];
- yield [[['param', 'return'], ['author', 'since']], 'author', 'since', true];
- yield [[...TagComparator::DEFAULT_GROUPS, ['param', 'return']], 'link', 'see', true];
- yield [[['param', 'return']], 'category', 'package', false];
- }
- }
|