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#[CoversClass(SurnameTraditionFactory::class)] 36class SurnameTraditionFactoryTest extends TestCase 37{ 38 public function testCreate(): void 39 { 40 $factory = new SurnameTraditionFactory(); 41 42 self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::DEFAULT)); 43 self::assertInstanceOf(IcelandicSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::ICELANDIC)); 44 self::assertInstanceOf(LithuanianSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::LITHUANIAN)); 45 self::assertInstanceOf(MatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::MATRILINEAL)); 46 self::assertInstanceOf(PaternalSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATERNAL)); 47 self::assertInstanceOf(PatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATRILINEAL)); 48 self::assertInstanceOf(PolishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::POLISH)); 49 self::assertInstanceOf(PortugueseSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PORTUGUESE)); 50 self::assertInstanceOf(SpanishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::SPANISH)); 51 } 52 53 /** 54 * Test create() with invalid input 55 */ 56 public function testCreateInvalid(): void 57 { 58 $factory = new SurnameTraditionFactory(); 59 60 self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make('FOOBAR')); 61 } 62 63 /** 64 * Test allDescriptions() 65 */ 66 public function testAllDescriptions(): void 67 { 68 $descriptions = Registry::surnameTraditionFactory()->list(); 69 self::assertCount(9, $descriptions); 70 } 71} 72