xref: /webtrees/tests/app/Factories/SurnameTraditionFactoryTest.php (revision 53ee5b1238b88500e2546985e91fe24a762a47df)
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;
33
34/**
35 * Test harness for the class SurnameTradition
36 */
37class SurnameTraditionFactoryTest extends TestCase
38{
39    /**
40     * @covers \Fisharebest\Webtrees\Factories\SurnameTraditionFactory::make
41     */
42    public function testCreate(): void
43    {
44        $factory = new SurnameTraditionFactory();
45
46        self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::DEFAULT));
47        self::assertInstanceOf(IcelandicSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::ICELANDIC));
48        self::assertInstanceOf(LithuanianSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::LITHUANIAN));
49        self::assertInstanceOf(MatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::MATRILINEAL));
50        self::assertInstanceOf(PaternalSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATERNAL));
51        self::assertInstanceOf(PatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATRILINEAL));
52        self::assertInstanceOf(PolishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::POLISH));
53        self::assertInstanceOf(PortugueseSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PORTUGUESE));
54        self::assertInstanceOf(SpanishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::SPANISH));
55    }
56
57    /**
58     * Test create() with invalid input
59     *
60     * @covers \Fisharebest\Webtrees\Factories\SurnameTraditionFactory::make
61     */
62    public function testCreateInvalid(): void
63    {
64        $factory = new SurnameTraditionFactory();
65
66        self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make('FOOBAR'));
67    }
68
69    /**
70     * Test allDescriptions()
71     *
72     * @covers \Fisharebest\Webtrees\Factories\SurnameTraditionFactory::list
73     */
74    public function testAllDescriptions(): void
75    {
76        $descriptions = Registry::surnameTraditionFactory()->list();
77        self::assertCount(9, $descriptions);
78    }
79}
80