. */ declare(strict_types=1); namespace Fisharebest\Webtrees; use Fisharebest\Webtrees\Contracts\SurnameTraditionFactoryInterface; use Fisharebest\Webtrees\Factories\SurnameTraditionFactory; use Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition; use Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(SurnameTraditionFactory::class)] class SurnameTraditionFactoryTest extends TestCase { public function testCreate(): void { $factory = new SurnameTraditionFactory(); self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::DEFAULT)); self::assertInstanceOf(IcelandicSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::ICELANDIC)); self::assertInstanceOf(LithuanianSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::LITHUANIAN)); self::assertInstanceOf(MatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::MATRILINEAL)); self::assertInstanceOf(PaternalSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATERNAL)); self::assertInstanceOf(PatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATRILINEAL)); self::assertInstanceOf(PolishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::POLISH)); self::assertInstanceOf(PortugueseSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PORTUGUESE)); self::assertInstanceOf(SpanishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::SPANISH)); } /** * Test create() with invalid input */ public function testCreateInvalid(): void { $factory = new SurnameTraditionFactory(); self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make('FOOBAR')); } /** * Test allDescriptions() */ public function testAllDescriptions(): void { $descriptions = Registry::surnameTraditionFactory()->list(); self::assertCount(9, $descriptions); } }