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