xref: /webtrees/tests/app/SurnameTradition/MatrilinealSurnameTraditionTest.php (revision c4943cff72f95a28fbb9404e3c20b169ff098e5c)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 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\SurnameTradition;
21
22use Fisharebest\Webtrees\TestCase;
23
24/**
25 * Test harness for the class MatrilinenalSurnameTradition
26 */
27class MatrilinealSurnameTraditionTest extends TestCase
28{
29    private SurnameTraditionInterface $surname_tradition;
30
31    /**
32     * Prepare the environment for these tests
33     *
34     * @return void
35     */
36    protected function setUp(): void
37    {
38        parent::setUp();
39
40        $this->surname_tradition = new MatrilinealSurnameTradition();
41    }
42
43    /**
44     * Test whether married surnames are used
45     *
46     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
47     *
48     * @return void
49     */
50    public function testMarriedSurnames(): void
51    {
52        self::assertFalse($this->surname_tradition->hasMarriedNames());
53    }
54
55    /**
56     * Test whether surnames are used
57     *
58     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
59     *
60     * @return void
61     */
62    public function testSurnames(): void
63    {
64        self::assertTrue($this->surname_tradition->hasSurnames());
65    }
66
67    /**
68     * Test new son names
69     *
70     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
71     *
72     * @return void
73     */
74    public function testNewSonNames(): void
75    {
76        self::assertSame(
77            [
78                'NAME' => '/Black/',
79                'SURN' => 'Black',
80            ],
81            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M')
82        );
83    }
84
85    /**
86     * Test new daughter names
87     *
88     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
89     *
90     * @return void
91     */
92    public function testNewDaughterNames(): void
93    {
94        self::assertSame(
95            [
96                'NAME' => '/Black/',
97                'SURN' => 'Black',
98            ],
99            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F')
100        );
101    }
102
103    /**
104     * Test new child names
105     *
106     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
107     *
108     * @return void
109     */
110    public function testNewChildNames(): void
111    {
112        self::assertSame(
113            [
114                'NAME' => '/Black/',
115                'SURN' => 'Black',
116            ],
117            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U')
118        );
119    }
120
121    /**
122     * Test new child names
123     *
124     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
125     *
126     * @return void
127     */
128    public function testNewChildNamesWithSpfx(): void
129    {
130        self::assertSame(
131            [
132                'NAME' => '/van Black/',
133                'SPFX' => 'van',
134                'SURN' => 'Black',
135            ],
136            $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U')
137        );
138    }
139
140    /**
141     * Test new child names
142     *
143     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
144     *
145     * @return void
146     */
147    public function testNewChildNamesWithNoParentsNames(): void
148    {
149        self::assertSame(
150            ['NAME' => '//'],
151            $this->surname_tradition->newChildNames('', '', 'U')
152        );
153    }
154
155    /**
156     * Test new father names
157     *
158     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
159     *
160     * @return void
161     */
162    public function testNewFatherNames(): void
163    {
164        self::assertSame(
165            ['NAME' => '//'],
166            $this->surname_tradition->newParentNames('John /White/', 'M')
167        );
168    }
169
170    /**
171     * Test new mother names
172     *
173     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
174     *
175     * @return void
176     */
177    public function testNewMotherNames(): void
178    {
179        self::assertSame(
180            [
181                'NAME' => '/White/',
182                'SURN' => 'White',
183            ],
184            $this->surname_tradition->newParentNames('John /White/', 'F')
185        );
186    }
187
188    /**
189     * Test new parent names
190     *
191     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
192     *
193     * @return void
194     */
195    public function testNewParentNames(): void
196    {
197        self::assertSame(
198            ['NAME' => '//'],
199            $this->surname_tradition->newParentNames('John /White/', 'U')
200        );
201    }
202
203    /**
204     * Test new husband names
205     *
206     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
207     *
208     * @return void
209     */
210    public function testNewHusbandNames(): void
211    {
212        self::assertSame(
213            ['NAME' => '//'],
214            $this->surname_tradition->newSpouseNames('Mary /Black/', 'M')
215        );
216    }
217
218    /**
219     * Test new wife names
220     *
221     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
222     *
223     * @return void
224     */
225    public function testNewWifeNames(): void
226    {
227        self::assertSame(
228            ['NAME' => '//'],
229            $this->surname_tradition->newSpouseNames('John /White/', 'F')
230        );
231    }
232
233    /**
234     * Test new spouse names
235     *
236     * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition
237     *
238     * @return void
239     */
240    public function testNewSpouseNames(): void
241    {
242        self::assertSame(
243            ['NAME' => '//'],
244            $this->surname_tradition->newSpouseNames('Chris /Green/', 'U')
245        );
246    }
247}
248