xref: /webtrees/tests/app/Factories/SurnameTraditionFactoryTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
17e128bbfSGreg Roach<?php
27e128bbfSGreg Roach
37e128bbfSGreg Roach/**
47e128bbfSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
67e128bbfSGreg Roach * This program is free software: you can redistribute it and/or modify
77e128bbfSGreg Roach * it under the terms of the GNU General Public License as published by
87e128bbfSGreg Roach * the Free Software Foundation, either version 3 of the License, or
97e128bbfSGreg Roach * (at your option) any later version.
107e128bbfSGreg Roach * This program is distributed in the hope that it will be useful,
117e128bbfSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
127e128bbfSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137e128bbfSGreg Roach * GNU General Public License for more details.
147e128bbfSGreg Roach * You should have received a copy of the GNU General Public License
157e128bbfSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
167e128bbfSGreg Roach */
177e128bbfSGreg Roach
187e128bbfSGreg Roachdeclare(strict_types=1);
197e128bbfSGreg Roach
207e128bbfSGreg Roachnamespace Fisharebest\Webtrees;
217e128bbfSGreg Roach
227e128bbfSGreg Roachuse Fisharebest\Webtrees\Contracts\SurnameTraditionFactoryInterface;
237e128bbfSGreg Roachuse Fisharebest\Webtrees\Factories\SurnameTraditionFactory;
247e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\DefaultSurnameTradition;
257e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\IcelandicSurnameTradition;
267e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition;
277e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition;
287e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition;
297e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition;
307e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\PolishSurnameTradition;
317e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition;
327e128bbfSGreg Roachuse Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition;
33*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
347e128bbfSGreg Roach
35*202c018bSGreg Roach#[CoversClass(SurnameTraditionFactory::class)]
367e128bbfSGreg Roachclass SurnameTraditionFactoryTest extends TestCase
377e128bbfSGreg Roach{
387e128bbfSGreg Roach    public function testCreate(): void
397e128bbfSGreg Roach    {
407e128bbfSGreg Roach        $factory = new SurnameTraditionFactory();
417e128bbfSGreg Roach
427e128bbfSGreg Roach        self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::DEFAULT));
437e128bbfSGreg Roach        self::assertInstanceOf(IcelandicSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::ICELANDIC));
447e128bbfSGreg Roach        self::assertInstanceOf(LithuanianSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::LITHUANIAN));
457e128bbfSGreg Roach        self::assertInstanceOf(MatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::MATRILINEAL));
467e128bbfSGreg Roach        self::assertInstanceOf(PaternalSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATERNAL));
477e128bbfSGreg Roach        self::assertInstanceOf(PatrilinealSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PATRILINEAL));
487e128bbfSGreg Roach        self::assertInstanceOf(PolishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::POLISH));
497e128bbfSGreg Roach        self::assertInstanceOf(PortugueseSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::PORTUGUESE));
507e128bbfSGreg Roach        self::assertInstanceOf(SpanishSurnameTradition::class, $factory->make(SurnameTraditionFactoryInterface::SPANISH));
517e128bbfSGreg Roach    }
527e128bbfSGreg Roach
537e128bbfSGreg Roach    /**
547e128bbfSGreg Roach     * Test create() with invalid input
557e128bbfSGreg Roach     */
567e128bbfSGreg Roach    public function testCreateInvalid(): void
577e128bbfSGreg Roach    {
587e128bbfSGreg Roach        $factory = new SurnameTraditionFactory();
597e128bbfSGreg Roach
607e128bbfSGreg Roach        self::assertInstanceOf(DefaultSurnameTradition::class, $factory->make('FOOBAR'));
617e128bbfSGreg Roach    }
627e128bbfSGreg Roach
637e128bbfSGreg Roach    /**
647e128bbfSGreg Roach     * Test allDescriptions()
657e128bbfSGreg Roach     */
667e128bbfSGreg Roach    public function testAllDescriptions(): void
677e128bbfSGreg Roach    {
687e128bbfSGreg Roach        $descriptions = Registry::surnameTraditionFactory()->list();
697e128bbfSGreg Roach        self::assertCount(9, $descriptions);
707e128bbfSGreg Roach    }
717e128bbfSGreg Roach}
72