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