xref: /webtrees/tests/app/SurnameTradition/PaternalSurnameTraditionTest.php (revision 5c48bcd62613a083ce0d1998e379b7010eee8985)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\SurnameTradition;
19
20/**
21 * Test harness for the class PaternalSurnameTradition
22 */
23class PaternalSurnameTraditionTest extends \Fisharebest\Webtrees\TestCase
24{
25    /** @var SurnameTraditionInterface */
26    private $surname_tradition;
27
28    /**
29     * Prepare the environment for these tests
30     *
31     * @return void
32     */
33    protected function setUp(): void
34    {
35        parent::setUp();
36
37        $this->surname_tradition = new PaternalSurnameTradition();
38    }
39
40    /**
41     * Test whether married surnames are used
42     *
43     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
44     *
45     * @return void
46     */
47    public function testMarriedSurnames(): void
48    {
49        $this->assertSame(true, $this->surname_tradition->hasMarriedNames());
50    }
51
52    /**
53     * Test whether surnames are used
54     *
55     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
56     *
57     * @return void
58     */
59    public function testSurnames(): void
60    {
61        $this->assertSame(true, $this->surname_tradition->hasSurnames());
62    }
63
64    /**
65     * Test new son names
66     *
67     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
68     *
69     * @return void
70     */
71    public function testNewSonNames(): void
72    {
73        $this->assertSame(
74            [
75                'NAME' => '/White/',
76                'SURN' => 'White',
77            ],
78            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M')
79        );
80    }
81
82    /**
83     * Test new daughter names
84     *
85     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
86     *
87     * @return void
88     */
89    public function testNewDaughterNames(): void
90    {
91        $this->assertSame(
92            [
93                'NAME' => '/White/',
94                'SURN' => 'White',
95            ],
96            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F')
97        );
98    }
99
100    /**
101     * Test new child names
102     *
103     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
104     *
105     * @return void
106     */
107    public function testNewChildNames(): void
108    {
109        $this->assertSame(
110            [
111                'NAME' => '/White/',
112                'SURN' => 'White',
113            ],
114            $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U')
115        );
116    }
117
118    /**
119     * Test new child names
120     *
121     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
122     *
123     * @return void
124     */
125    public function testNewChildNamesWithSpfx(): void
126    {
127        $this->assertSame(
128            [
129                'NAME' => '/de White/',
130                'SPFX' => 'de',
131                'SURN' => 'White',
132            ],
133            $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U')
134        );
135    }
136
137    /**
138     * Test new child names
139     *
140     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
141     *
142     * @return void
143     */
144    public function testNewChildNamesWithMultipleSpfx(): void
145    {
146        $this->assertSame(
147            [
148                'NAME' => '/van der White/',
149                'SPFX' => 'van der',
150                'SURN' => 'White',
151            ],
152            $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U')
153        );
154    }
155
156    /**
157     * Test new child names
158     *
159     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
160     *
161     * @return void
162     */
163    public function testNewChildNamesWithDutchSpfx(): void
164    {
165        $this->assertSame(
166            [
167                'NAME' => '/\'t White/',
168                'SPFX' => '\'t',
169                'SURN' => 'White',
170            ],
171            $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U')
172        );
173        $this->assertSame(
174            [
175                'NAME' => '/’t White/',
176                'SPFX' => '’t',
177                'SURN' => 'White',
178            ],
179            $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U')
180        );
181    }
182
183    /**
184     * Test new child names
185     *
186     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
187     *
188     * @return void
189     */
190    public function testNewChildNamesWithMultipleDutchSpfx(): void
191    {
192        $this->assertSame(
193            [
194                'NAME' => '/van \'t White/',
195                'SPFX' => 'van \'t',
196                'SURN' => 'White',
197            ],
198            $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U')
199        );
200        $this->assertSame(
201            [
202                'NAME' => '/van ’t White/',
203                'SPFX' => 'van ’t',
204                'SURN' => 'White',
205            ],
206            $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U')
207        );
208    }
209
210    /**
211     * Test new father names
212     *
213     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
214     *
215     * @return void
216     */
217    public function testNewFatherNames(): void
218    {
219        $this->assertSame(
220            [
221                'NAME' => '/White/',
222                'SURN' => 'White',
223            ],
224            $this->surname_tradition->newParentNames('John /White/', 'M')
225        );
226    }
227
228    /**
229     * Test new mother names
230     *
231     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
232     *
233     * @return void
234     */
235    public function testNewMotherNames(): void
236    {
237        $this->assertSame(
238            [
239                'NAME'   => '//',
240                '_MARNM' => '/White/',
241            ],
242            $this->surname_tradition->newParentNames('John /White/', 'F')
243        );
244    }
245
246    /**
247     * Test new parent names
248     *
249     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
250     *
251     * @return void
252     */
253    public function testNewParentNames(): void
254    {
255        $this->assertSame(
256            ['NAME' => '//'],
257            $this->surname_tradition->newParentNames('John /White/', 'U')
258        );
259    }
260
261    /**
262     * Test new husband names
263     *
264     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
265     *
266     * @return void
267     */
268    public function testNewHusbandNames(): void
269    {
270        $this->assertSame(
271            ['NAME' => '//'],
272            $this->surname_tradition->newSpouseNames('Mary /Black/', 'M')
273        );
274    }
275
276    /**
277     * Test new wife names
278     *
279     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
280     *
281     * @return void
282     */
283    public function testNewWifeNames(): void
284    {
285        $this->assertSame(
286            [
287                'NAME'   => '//',
288                '_MARNM' => '/White/',
289            ],
290            $this->surname_tradition->newSpouseNames('John /White/', 'F')
291        );
292    }
293
294    /**
295     * Test new wife names
296     *
297     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
298     *
299     * @return void
300     */
301    public function testNewWifeNamesWithSpfx(): void
302    {
303        $this->assertSame(
304            [
305                'NAME'   => '//',
306                '_MARNM' => '/van der White/',
307            ],
308            $this->surname_tradition->newSpouseNames('John /van der White/', 'F')
309        );
310    }
311
312    /**
313     * Test new spouse names
314     *
315     * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition
316     *
317     * @return void
318     */
319    public function testNewSpouseNames(): void
320    {
321        $this->assertSame(
322            ['NAME' => '//'],
323            $this->surname_tradition->newSpouseNames('Chris /Green/', 'U')
324        );
325    }
326}
327