1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2023 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees; 21 22use Fisharebest\Webtrees\Contracts\SurnameTraditionFactoryInterface; 23use Fisharebest\Webtrees\Factories\SurnameTraditionFactory; 24use Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition; 25use Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition; 26use Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition; 27use Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition; 28use Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition; 29use Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition; 30use Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition; 31use Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition; 32use Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition; 33use PHPUnit\Framework\Attributes\CoversClass; 34 35 36#[CoversClass(SurnameTraditionFactory::class)] 37class SurnameTraditionFactoryTest extends TestCase 38{ 39 public function testCreate(): void 40 { 41 $factory = new SurnameTraditionFactory(); 42 43 self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::DEFAULT)); 44 self::assertInstanceOf(IcelandicSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::ICELANDIC)); 45 self::assertInstanceOf(LithuanianSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::LITHUANIAN)); 46 self::assertInstanceOf(MatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::MATRILINEAL)); 47 self::assertInstanceOf(PaternalSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATERNAL)); 48 self::assertInstanceOf(PatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATRILINEAL)); 49 self::assertInstanceOf(PolishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::POLISH)); 50 self::assertInstanceOf(PortugueseSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PORTUGUESE)); 51 self::assertInstanceOf(SpanishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::SPANISH)); 52 } 53 54 /** 55 * Test create() with invalid input 56 */ 57 public function testCreateInvalid(): void 58 { 59 $factory = new SurnameTraditionFactory(); 60 61 self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make('FOOBAR')); 62 } 63 64 /** 65 * Test allDescriptions() 66 */ 67 public function testAllDescriptions(): void 68 { 69 $descriptions = Registry::surnameTraditionFactory()->list(); 70 self::assertCount(9, $descriptions); 71 } 72} 73