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