xref: /webtrees/tests/app/SurnameTradition/LithuanianSurnameTraditionTest.php (revision 9a46db0748712ff5ee1c721ba70f1d876abcdcf9)
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\Fact;
23use Fisharebest\Webtrees\Individual;
24use Fisharebest\Webtrees\TestCase;
25use Illuminate\Support\Collection;
26
27/**
28 * Test harness for the class LithuanianSurnameTraditionTest
29 */
30class LithuanianSurnameTraditionTest extends TestCase
31{
32    private SurnameTraditionInterface $surname_tradition;
33
34    /**
35     * Prepare the environment for these tests
36     *
37     * @return void
38     */
39    protected function setUp(): void
40    {
41        parent::setUp();
42
43        $this->surname_tradition = new LithuanianSurnameTradition();
44    }
45
46    /**
47     * Test whether married surnames are used
48     *
49     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
50     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
51     *
52     * @return void
53     */
54    public function testMarriedSurnames(): void
55    {
56        self::assertTrue($this->surname_tradition->hasMarriedNames());
57    }
58
59    /**
60     * Test whether surnames are used
61     *
62     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
63     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
64     *
65     * @return void
66     */
67    public function testSurnames(): void
68    {
69        self::assertTrue($this->surname_tradition->hasSurnames());
70    }
71
72    /**
73     * Test new son names
74     *
75     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
76     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
77     *
78     * @return void
79     */
80    public function testNewSonNames(): void
81    {
82        $father_fact = $this->createStub(Fact::class);
83        $father_fact->expects(self::any())->method('value')->willReturn('John /White/');
84
85        $father = $this->createStub(Individual::class);
86        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
87
88        $mother_fact = $this->createStub(Fact::class);
89        $mother_fact->expects(self::any())->method('value')->willReturn('Mary /Black/');
90
91        $mother = $this->createStub(Individual::class);
92        $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact]));
93
94        self::assertSame(
95            ["1 NAME /White/\n2 TYPE birth\n2 SURN White"],
96            $this->surname_tradition->newChildNames($father, $mother, 'M')
97        );
98    }
99
100    /**
101     * Test new daughter names
102     *
103     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
104     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
105     *
106     * @return void
107     */
108    public function testNewDaughterNames(): void
109    {
110        $father_fact = $this->createStub(Fact::class);
111        $father_fact->expects(self::any())->method('value')->willReturn('John /White/');
112
113        $father = $this->createStub(Individual::class);
114        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
115
116        $mother_fact = $this->createStub(Fact::class);
117        $mother_fact->expects(self::any())->method('value')->willReturn('Mary /Black/');
118
119        $mother = $this->createStub(Individual::class);
120        $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact]));
121
122        self::assertSame(
123            ["1 NAME /White/\n2 TYPE birth\n2 SURN White"],
124            $this->surname_tradition->newChildNames($father, $mother, 'F')
125        );
126    }
127
128    /**
129     * Test new daughter names
130     *
131     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
132     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
133     *
134     * @return void
135     */
136    public function testNewDaughterNamesInflected(): void
137    {
138        $father_fact = $this->createStub(Fact::class);
139        $father_fact->expects(self::any())->method('value')->willReturn('John /Whita/');
140
141        $father = $this->createStub(Individual::class);
142        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
143
144        $mother_fact = $this->createStub(Fact::class);
145        $mother_fact->expects(self::any())->method('value')->willReturn('Mary /Black/');
146
147        $mother = $this->createStub(Individual::class);
148        $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact]));
149
150        self::assertSame(
151            ["1 NAME /Whitaitė/\n2 TYPE birth\n2 SURN Whita"],
152            $this->surname_tradition->newChildNames($father, $mother, 'F')
153        );
154
155        $father_fact = $this->createStub(Fact::class);
156        $father_fact->expects(self::any())->method('value')->willReturn('John /Whitas/');
157
158        $father = $this->createStub(Individual::class);
159        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
160
161        self::assertSame(
162            ["1 NAME /Whitaitė/\n2 TYPE birth\n2 SURN Whitas"],
163            $this->surname_tradition->newChildNames($father, $mother, 'F')
164        );
165
166        $father_fact = $this->createStub(Fact::class);
167        $father_fact->expects(self::any())->method('value')->willReturn('John /Whitis/');
168
169        $father = $this->createStub(Individual::class);
170        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
171
172        self::assertSame(
173            ["1 NAME /Whitytė/\n2 TYPE birth\n2 SURN Whitis"],
174            $this->surname_tradition->newChildNames($father, $mother, 'F')
175        );
176
177        $father_fact = $this->createStub(Fact::class);
178        $father_fact->expects(self::any())->method('value')->willReturn('John /Whitys/');
179
180        $father = $this->createStub(Individual::class);
181        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
182
183        self::assertSame(
184            ["1 NAME /Whitytė/\n2 TYPE birth\n2 SURN Whitys"],
185            $this->surname_tradition->newChildNames($father, $mother, 'F')
186        );
187
188        $father_fact = $this->createStub(Fact::class);
189        $father_fact->expects(self::any())->method('value')->willReturn('John /Whitius/');
190
191        $father = $this->createStub(Individual::class);
192        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
193
194        self::assertSame(
195            ["1 NAME /Whitiūtė/\n2 TYPE birth\n2 SURN Whitius"],
196            $this->surname_tradition->newChildNames($father, $mother, 'F')
197        );
198
199        $father_fact = $this->createStub(Fact::class);
200        $father_fact->expects(self::any())->method('value')->willReturn('John /Whitus/');
201
202        $father = $this->createStub(Individual::class);
203        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
204
205        self::assertSame(
206            ["1 NAME /Whitutė/\n2 TYPE birth\n2 SURN Whitus"],
207            $this->surname_tradition->newChildNames($father, $mother, 'F')
208        );
209    }
210
211    /**
212     * Test new child names
213     *
214     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
215     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
216     *
217     * @return void
218     */
219    public function testNewChildNames(): void
220    {
221        $father_fact = $this->createStub(Fact::class);
222        $father_fact->expects(self::any())->method('value')->willReturn('John /White/');
223
224        $father = $this->createStub(Individual::class);
225        $father->expects(self::any())->method('facts')->willReturn(new Collection([$father_fact]));
226
227        $mother_fact = $this->createStub(Fact::class);
228        $mother_fact->expects(self::any())->method('value')->willReturn('Mary /Black/');
229
230        $mother = $this->createStub(Individual::class);
231        $mother->expects(self::any())->method('facts')->willReturn(new Collection([$mother_fact]));
232
233        self::assertSame(
234            ["1 NAME /White/\n2 TYPE birth\n2 SURN White"],
235            $this->surname_tradition->newChildNames($father, $mother, 'U')
236        );
237    }
238
239    /**
240     * Test new child names
241     *
242     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
243     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
244     *
245     * @return void
246     */
247    public function testNewChildNamesWithNoParentsNames(): void
248    {
249        self::assertSame(
250            ["1 NAME //\n2 TYPE birth"],
251            $this->surname_tradition->newChildNames(null, null, 'U')
252        );
253    }
254
255    /**
256     * Test new father names
257     *
258     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
259     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
260     *
261     * @return void
262     */
263    public function testNewFatherNames(): void
264    {
265        $fact = $this->createStub(Fact::class);
266        $fact->expects(self::any())->method('value')->willReturn('John /White/');
267
268        $individual = $this->createStub(Individual::class);
269        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
270
271        self::assertSame(
272            ["1 NAME /White/\n2 TYPE birth\n2 SURN White"],
273            $this->surname_tradition->newParentNames($individual, 'M')
274        );
275    }
276
277    /**
278     * Test new father names
279     *
280     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
281     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
282     *
283     * @return void
284     */
285    public function testNewFatherNamesInflected(): void
286    {
287        $fact = $this->createStub(Fact::class);
288        $fact->expects(self::any())->method('value')->willReturn('Mary /Whitaitė/');
289
290        $individual = $this->createStub(Individual::class);
291        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
292
293        self::assertSame(
294            ["1 NAME /Whitas/\n2 TYPE birth\n2 SURN Whitas"],
295            $this->surname_tradition->newParentNames($individual, 'M')
296        );
297
298        $fact = $this->createStub(Fact::class);
299        $fact->expects(self::any())->method('value')->willReturn('Mary /Whitytė/');
300
301        $individual = $this->createStub(Individual::class);
302        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
303
304        self::assertSame(
305            ["1 NAME /Whitis/\n2 TYPE birth\n2 SURN Whitis"],
306            $this->surname_tradition->newParentNames($individual, 'M')
307        );
308
309        $fact = $this->createStub(Fact::class);
310        $fact->expects(self::any())->method('value')->willReturn('Mary /Whitiūtė/');
311
312        $individual = $this->createStub(Individual::class);
313        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
314
315        self::assertSame(
316            ["1 NAME /Whitius/\n2 TYPE birth\n2 SURN Whitius"],
317            $this->surname_tradition->newParentNames($individual, 'M')
318        );
319
320        $fact = $this->createStub(Fact::class);
321        $fact->expects(self::any())->method('value')->willReturn('Mary /Whitutė/');
322
323        $individual = $this->createStub(Individual::class);
324        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
325
326        self::assertSame(
327            ["1 NAME /Whitus/\n2 TYPE birth\n2 SURN Whitus"],
328            $this->surname_tradition->newParentNames($individual, 'M')
329        );
330    }
331
332    /**
333     * Test new mother names
334     *
335     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
336     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
337     *
338     * @return void
339     */
340    public function testNewMotherNames(): void
341    {
342        $fact = $this->createStub(Fact::class);
343        $fact->expects(self::any())->method('value')->willReturn('John /White/');
344
345        $individual = $this->createStub(Individual::class);
346        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
347
348        self::assertSame(
349            ["1 NAME //\n2 TYPE birth"],
350            $this->surname_tradition->newParentNames($individual, 'F')
351        );
352    }
353
354    /**
355     * Test new parent names
356     *
357     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
358     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
359     *
360     * @return void
361     */
362    public function testNewParentNames(): void
363    {
364        $fact = $this->createStub(Fact::class);
365        $fact->expects(self::any())->method('value')->willReturn('John /White/');
366
367        $individual = $this->createStub(Individual::class);
368        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
369
370        self::assertSame(
371            ["1 NAME //\n2 TYPE birth"],
372            $this->surname_tradition->newParentNames($individual, 'U')
373        );
374    }
375
376    /**
377     * Test new husband names
378     *
379     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
380     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
381     *
382     * @return void
383     */
384    public function testNewHusbandNames(): void
385    {
386        $fact = $this->createStub(Fact::class);
387        $fact->expects(self::any())->method('value')->willReturn('Mary /Black/');
388
389        $individual = $this->createStub(Individual::class);
390        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
391
392        self::assertSame(
393            ["1 NAME //\n2 TYPE birth"],
394            $this->surname_tradition->newSpouseNames($individual, 'M')
395        );
396    }
397
398    /**
399     * Test new wife names
400     *
401     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
402     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
403     *
404     * @return void
405     */
406    public function testNewWifeNames(): void
407    {
408        $fact = $this->createStub(Fact::class);
409        $fact->expects(self::any())->method('value')->willReturn('John /White/');
410
411        $individual = $this->createStub(Individual::class);
412        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
413
414        self::assertSame(
415            ["1 NAME //\n2 TYPE birth", "1 NAME /White/\n2 TYPE married\n2 SURN White"],
416            $this->surname_tradition->newSpouseNames($individual, 'F')
417        );
418    }
419
420    /**
421     * Test new spouse names
422     *
423     * @covers \Fisharebest\Webtrees\SurnameTradition\LithuanianSurnameTradition
424     * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition
425     *
426     * @return void
427     */
428    public function testNewSpouseNames(): void
429    {
430        $fact = $this->createStub(Fact::class);
431        $fact->expects(self::any())->method('value')->willReturn('John /White/');
432
433        $individual = $this->createStub(Individual::class);
434        $individual->expects(self::any())->method('facts')->willReturn(new Collection([$fact]));
435
436        self::assertSame(
437            ["1 NAME //\n2 TYPE birth"],
438            $this->surname_tradition->newSpouseNames($individual, 'U')
439        );
440    }
441}
442