|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Tempest\Support\Tests\Pluralizer; |
| 6 | + |
| 7 | +use Countable; |
| 8 | +use PHPUnit\Framework\Attributes\TestWith; |
| 9 | +use PHPUnit\Framework\TestCase; |
| 10 | +use Tempest\Support\Pluralizer\InflectorPluralizer; |
| 11 | + |
| 12 | +/** |
| 13 | + * @internal |
| 14 | + * @small |
| 15 | + */ |
| 16 | +final class InflectorPluralizerTest extends TestCase |
| 17 | +{ |
| 18 | + #[TestWith(['migration', 'migrations', 0])] |
| 19 | + #[TestWith(['migration', 'migration', 1])] |
| 20 | + #[TestWith(['Migration', 'Migrations', 2])] |
| 21 | + #[TestWith(['migration', 'migrations', 2])] |
| 22 | + #[TestWith(['migration', 'migrations', [1, 2]])] |
| 23 | + public function test_that_pluralizer_pluralizes(string $value, string $expected, int|array|Countable $count): void |
| 24 | + { |
| 25 | + $pluralizer = new InflectorPluralizer(); |
| 26 | + |
| 27 | + $this->assertEquals($expected, $pluralizer->pluralize($value, $count)); |
| 28 | + } |
| 29 | + |
| 30 | + #[TestWith(['Migrations', 'Migration'])] |
| 31 | + #[TestWith(['migrations', 'migration'])] |
| 32 | + public function test_that_pluralizer_singularizes(string $value, string $expected): void |
| 33 | + { |
| 34 | + $pluralizer = new InflectorPluralizer(); |
| 35 | + |
| 36 | + $this->assertEquals($expected, $pluralizer->singularize($value)); |
| 37 | + } |
| 38 | +} |
0 commit comments