xref: /webtrees/tests/app/SurnameTradition/PaternalSurnameTraditionTest.php (revision b56fa9dd6a5e9075de5337fd34748412e9e559a7)
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 PaternalSurnameTradition
26 */
27class PaternalSurnameTraditionTest extends TestCase
28{
29    /** @var SurnameTraditionInterface */
30    private $surname_tradition;
31
32    /**
33     * Prepare the environment for these tests
34     *
35     * @return void
36     */
37    protected function setUp(): void
38    {
39        parent::setUp();
40
41        $this->surname_tradition = new PaternalSurnameTradition();
42    }
43
44    /**
45     * Test whether married surnames are used
46     *
47     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
48     *
49     * @return void
50     */
51    public function testMarriedSurnames(): void
52    {
53        self::assertTrue($this->surname_tradition->hasMarriedNames());
54    }
55
56    /**
57     * Test whether surnames are used
58     *
59     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
60     *
61     * @return void
62     */
63    public function testSurnames(): void
64    {
65        self::assertTrue($this->surname_tradition->hasSurnames());
66    }
67
68    /**
69     * Test new son names
70     *
71     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
72     *
73     * @return void
74     */
75    public function testNewSonNames(): void
76    {
77        self::assertSame(
78            [
79                'NAME' => '/White/',
80                'SURN' => 'White',
81            ],
82            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M')
83        );
84    }
85
86    /**
87     * Test new daughter names
88     *
89     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
90     *
91     * @return void
92     */
93    public function testNewDaughterNames(): void
94    {
95        self::assertSame(
96            [
97                'NAME' => '/White/',
98                'SURN' => 'White',
99            ],
100            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F')
101        );
102    }
103
104    /**
105     * Test new child names
106     *
107     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
108     *
109     * @return void
110     */
111    public function testNewChildNames(): void
112    {
113        self::assertSame(
114            [
115                'NAME' => '/White/',
116                'SURN' => 'White',
117            ],
118            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U')
119        );
120    }
121
122    /**
123     * Test new child names
124     *
125     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
126     *
127     * @return void
128     */
129    public function testNewChildNamesWithSpfx(): void
130    {
131        self::assertSame(
132            [
133                'NAME' => '/de White/',
134                'SPFX' => 'de',
135                'SURN' => 'White',
136            ],
137            $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U')
138        );
139    }
140
141    /**
142     * Test new child names
143     *
144     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
145     *
146     * @return void
147     */
148    public function testNewChildNamesWithMultipleSpfx(): void
149    {
150        self::assertSame(
151            [
152                'NAME' => '/van der White/',
153                'SPFX' => 'van der',
154                'SURN' => 'White',
155            ],
156            $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U')
157        );
158    }
159
160    /**
161     * Test new child names
162     *
163     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
164     *
165     * @return void
166     */
167    public function testNewChildNamesWithDutchSpfx(): void
168    {
169        self::assertSame(
170            [
171                'NAME' => '/\'t White/',
172                'SPFX' => '\'t',
173                'SURN' => 'White',
174            ],
175            $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U')
176        );
177        self::assertSame(
178            [
179                'NAME' => '/’t White/',
180                'SPFX' => '’t',
181                'SURN' => 'White',
182            ],
183            $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U')
184        );
185    }
186
187    /**
188     * Test new child names
189     *
190     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
191     *
192     * @return void
193     */
194    public function testNewChildNamesWithMultipleDutchSpfx(): void
195    {
196        self::assertSame(
197            [
198                'NAME' => '/van \'t White/',
199                'SPFX' => 'van \'t',
200                'SURN' => 'White',
201            ],
202            $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U')
203        );
204        self::assertSame(
205            [
206                'NAME' => '/van ’t White/',
207                'SPFX' => 'van ’t',
208                'SURN' => 'White',
209            ],
210            $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U')
211        );
212    }
213
214    /**
215     * Test new father names
216     *
217     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
218     *
219     * @return void
220     */
221    public function testNewFatherNames(): void
222    {
223        self::assertSame(
224            [
225                'NAME' => '/White/',
226                'SURN' => 'White',
227            ],
228            $this->surname_tradition->newParentNames('John /White/', 'M')
229        );
230    }
231
232    /**
233     * Test new mother names
234     *
235     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
236     *
237     * @return void
238     */
239    public function testNewMotherNames(): void
240    {
241        self::assertSame(
242            [
243                'NAME'   => '//',
244                '_MARNM' => '/White/',
245            ],
246            $this->surname_tradition->newParentNames('John /White/', 'F')
247        );
248    }
249
250    /**
251     * Test new parent names
252     *
253     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
254     *
255     * @return void
256     */
257    public function testNewParentNames(): void
258    {
259        self::assertSame(
260            ['NAME' => '//'],
261            $this->surname_tradition->newParentNames('John /White/', 'U')
262        );
263    }
264
265    /**
266     * Test new husband names
267     *
268     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
269     *
270     * @return void
271     */
272    public function testNewHusbandNames(): void
273    {
274        self::assertSame(
275            ['NAME' => '//'],
276            $this->surname_tradition->newSpouseNames('Mary /Black/', 'M')
277        );
278    }
279
280    /**
281     * Test new wife names
282     *
283     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
284     *
285     * @return void
286     */
287    public function testNewWifeNames(): void
288    {
289        self::assertSame(
290            [
291                'NAME'   => '//',
292                '_MARNM' => '/White/',
293            ],
294            $this->surname_tradition->newSpouseNames('John /White/', 'F')
295        );
296    }
297
298    /**
299     * Test new wife names
300     *
301     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
302     *
303     * @return void
304     */
305    public function testNewWifeNamesWithSpfx(): void
306    {
307        self::assertSame(
308            [
309                'NAME'   => '//',
310                '_MARNM' => '/van der White/',
311            ],
312            $this->surname_tradition->newSpouseNames('John /van der White/', 'F')
313        );
314    }
315
316    /**
317     * Test new spouse names
318     *
319     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
320     *
321     * @return void
322     */
323    public function testNewSpouseNames(): void
324    {
325        self::assertSame(
326            ['NAME' => '//'],
327            $this->surname_tradition->newSpouseNames('Chris /Green/', 'U')
328        );
329    }
330}
331