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