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