xref: /webtrees/tests/app/Factories/SurnameTraditionFactoryTest.php (revision ef475b14d08542378dc3f165515f9182552984ef)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2022 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     * @return void
42     */
43    public function testCreate(): void
44    {
45        $factory = new SurnameTraditionFactory();
46
47        self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::DEFAULT));
48        self::assertInstanceOf(IcelandicSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::ICELANDIC));
49        self::assertInstanceOf(LithuanianSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::LITHUANIAN));
50        self::assertInstanceOf(MatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::MATRILINEAL));
51        self::assertInstanceOf(PaternalSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATERNAL));
52        self::assertInstanceOf(PatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATRILINEAL));
53        self::assertInstanceOf(PolishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::POLISH));
54        self::assertInstanceOf(PortugueseSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PORTUGUESE));
55        self::assertInstanceOf(SpanishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::SPANISH));
56    }
57
58    /**
59     * Test create() with invalid input
60     *
61     * @covers \Fisharebest\Webtrees\Factories\SurnameTraditionFactory::make
62     * @return void
63     */
64    public function testCreateInvalid(): void
65    {
66        $factory = new SurnameTraditionFactory();
67
68        self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make('FOOBAR'));
69    }
70
71    /**
72     * Test allDescriptions()
73     *
74     * @covers \Fisharebest\Webtrees\Factories\SurnameTraditionFactory::list
75     * @return void
76     */
77    public function testAllDescriptions(): void
78    {
79        $descriptions = Registry::surnameTraditionFactory()->list();
80        self::assertCount(9, $descriptions);
81    }
82}
83