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