1323788f4SGreg Roach<?php 23976b470SGreg Roach 3323788f4SGreg Roach/** 4323788f4SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6323788f4SGreg Roach * This program is free software: you can redistribute it and/or modify 7323788f4SGreg Roach * it under the terms of the GNU General Public License as published by 8323788f4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9323788f4SGreg Roach * (at your option) any later version. 10323788f4SGreg Roach * This program is distributed in the hope that it will be useful, 11323788f4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12323788f4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13323788f4SGreg Roach * GNU General Public License for more details. 14323788f4SGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16323788f4SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2084e2cf4eSGreg Roachnamespace Fisharebest\Webtrees\SurnameTradition; 21c1010edaSGreg Roach 22cb7a42eaSGreg Roachuse Fisharebest\Webtrees\Fact; 23cb7a42eaSGreg Roachuse Fisharebest\Webtrees\Individual; 243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 25cb7a42eaSGreg Roachuse Illuminate\Support\Collection; 26202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 273cfcc809SGreg Roach 28202c018bSGreg Roach#[CoversClass(LithuanianSurnameTradition::class)] 29202c018bSGreg Roach#[CoversClass(PatrilinealSurnameTradition::class)] 303cfcc809SGreg Roachclass LithuanianSurnameTraditionTest extends TestCase 31c1010edaSGreg Roach{ 32c4943cffSGreg Roach private SurnameTraditionInterface $surname_tradition; 33323788f4SGreg Roach 34323788f4SGreg Roach /** 35323788f4SGreg Roach * Prepare the environment for these tests 36323788f4SGreg Roach */ 375c48bcd6SGreg Roach protected function setUp(): void 38c1010edaSGreg Roach { 390115bc16SGreg Roach parent::setUp(); 400115bc16SGreg Roach 4174d6dc0eSGreg Roach $this->surname_tradition = new LithuanianSurnameTradition(); 42323788f4SGreg Roach } 43323788f4SGreg Roach 44323788f4SGreg Roach /** 45c1ec7145SGreg Roach * Test whether surnames are used 46c1ec7145SGreg Roach */ 479b802b22SGreg Roach public function testSurnames(): void 48c1010edaSGreg Roach { 49a171b6a5SGreg Roach self::assertSame('//', $this->surname_tradition->defaultName()); 50c1ec7145SGreg Roach } 51c1ec7145SGreg Roach 52c1ec7145SGreg Roach /** 53323788f4SGreg Roach * Test new son names 54323788f4SGreg Roach */ 559b802b22SGreg Roach public function testNewSonNames(): void 56c1010edaSGreg Roach { 57*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 5883c91e47SGreg Roach $father_fact->method('value')->willReturn('John /White/'); 59cb7a42eaSGreg Roach 60*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 6183c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 62cb7a42eaSGreg Roach 63*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 6483c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 65cb7a42eaSGreg Roach 66*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 6783c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 68cb7a42eaSGreg Roach 695e933c21SGreg Roach self::assertSame( 708939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 71cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'M') 72323788f4SGreg Roach ); 73323788f4SGreg Roach } 74323788f4SGreg Roach 75323788f4SGreg Roach /** 76323788f4SGreg Roach * Test new daughter names 77323788f4SGreg Roach */ 789b802b22SGreg Roach public function testNewDaughterNames(): void 79c1010edaSGreg Roach { 80*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 8183c91e47SGreg Roach $father_fact->method('value')->willReturn('John /White/'); 82cb7a42eaSGreg Roach 83*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 8483c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 85cb7a42eaSGreg Roach 86*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 8783c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 88cb7a42eaSGreg Roach 89*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 9083c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 91cb7a42eaSGreg Roach 925e933c21SGreg Roach self::assertSame( 938939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 94cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 95323788f4SGreg Roach ); 96323788f4SGreg Roach } 97323788f4SGreg Roach 98323788f4SGreg Roach /** 99323788f4SGreg Roach * Test new daughter names 100323788f4SGreg Roach */ 1019b802b22SGreg Roach public function testNewDaughterNamesInflected(): void 102c1010edaSGreg Roach { 103*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 10483c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whita/'); 105cb7a42eaSGreg Roach 106*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 10783c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 108cb7a42eaSGreg Roach 109*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 11083c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 111cb7a42eaSGreg Roach 112*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 11383c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 114cb7a42eaSGreg Roach 1155e933c21SGreg Roach self::assertSame( 1168939e2c2SGreg Roach ["1 NAME /Whitaitė/\n2 TYPE BIRTH\n2 SURN Whita"], 117cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 118323788f4SGreg Roach ); 119cb7a42eaSGreg Roach 120*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 12183c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitas/'); 122cb7a42eaSGreg Roach 123*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 12483c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 125cb7a42eaSGreg Roach 1265e933c21SGreg Roach self::assertSame( 1278939e2c2SGreg Roach ["1 NAME /Whitaitė/\n2 TYPE BIRTH\n2 SURN Whitas"], 128cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 129323788f4SGreg Roach ); 130cb7a42eaSGreg Roach 131*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 13283c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitis/'); 133cb7a42eaSGreg Roach 134*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 13583c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 136cb7a42eaSGreg Roach 1375e933c21SGreg Roach self::assertSame( 1388939e2c2SGreg Roach ["1 NAME /Whitytė/\n2 TYPE BIRTH\n2 SURN Whitis"], 139cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 140323788f4SGreg Roach ); 141cb7a42eaSGreg Roach 142*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 14383c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitys/'); 144cb7a42eaSGreg Roach 145*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 14683c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 147cb7a42eaSGreg Roach 1485e933c21SGreg Roach self::assertSame( 1498939e2c2SGreg Roach ["1 NAME /Whitytė/\n2 TYPE BIRTH\n2 SURN Whitys"], 150cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 151323788f4SGreg Roach ); 152cb7a42eaSGreg Roach 153*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 15483c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitius/'); 155cb7a42eaSGreg Roach 156*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 15783c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 158cb7a42eaSGreg Roach 1595e933c21SGreg Roach self::assertSame( 1608939e2c2SGreg Roach ["1 NAME /Whitiūtė/\n2 TYPE BIRTH\n2 SURN Whitius"], 161cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 162323788f4SGreg Roach ); 163cb7a42eaSGreg Roach 164*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 16583c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitus/'); 166cb7a42eaSGreg Roach 167*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 16883c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 169cb7a42eaSGreg Roach 1705e933c21SGreg Roach self::assertSame( 1718939e2c2SGreg Roach ["1 NAME /Whitutė/\n2 TYPE BIRTH\n2 SURN Whitus"], 172cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 173323788f4SGreg Roach ); 174323788f4SGreg Roach } 175323788f4SGreg Roach 176323788f4SGreg Roach /** 177323788f4SGreg Roach * Test new child names 178323788f4SGreg Roach */ 1799b802b22SGreg Roach public function testNewChildNames(): void 180c1010edaSGreg Roach { 181*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 18283c91e47SGreg Roach $father_fact->method('value')->willReturn('John /White/'); 183cb7a42eaSGreg Roach 184*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 18583c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 186cb7a42eaSGreg Roach 187*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 18883c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 189cb7a42eaSGreg Roach 190*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 19183c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 192cb7a42eaSGreg Roach 1935e933c21SGreg Roach self::assertSame( 1948939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 195cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'U') 196323788f4SGreg Roach ); 197323788f4SGreg Roach } 198323788f4SGreg Roach 199323788f4SGreg Roach /** 2001677a03aSGreg Roach * Test new child names 2011677a03aSGreg Roach */ 2029b802b22SGreg Roach public function testNewChildNamesWithNoParentsNames(): void 203c1010edaSGreg Roach { 2045e933c21SGreg Roach self::assertSame( 2058939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 206cb7a42eaSGreg Roach $this->surname_tradition->newChildNames(null, null, 'U') 2071677a03aSGreg Roach ); 2081677a03aSGreg Roach } 2091677a03aSGreg Roach 2101677a03aSGreg Roach /** 211323788f4SGreg Roach * Test new father names 212323788f4SGreg Roach */ 2139b802b22SGreg Roach public function testNewFatherNames(): void 214c1010edaSGreg Roach { 215*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 21683c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 217cb7a42eaSGreg Roach 218*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 21983c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 220cb7a42eaSGreg Roach 2215e933c21SGreg Roach self::assertSame( 2228939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 223cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 224323788f4SGreg Roach ); 225323788f4SGreg Roach } 226323788f4SGreg Roach 227323788f4SGreg Roach /** 228323788f4SGreg Roach * Test new father names 229323788f4SGreg Roach */ 2309b802b22SGreg Roach public function testNewFatherNamesInflected(): void 231c1010edaSGreg Roach { 232*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 23383c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitaitė/'); 234cb7a42eaSGreg Roach 235*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 23683c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 237cb7a42eaSGreg Roach 2385e933c21SGreg Roach self::assertSame( 2398939e2c2SGreg Roach ["1 NAME /Whitas/\n2 TYPE BIRTH\n2 SURN Whitas"], 240cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 241323788f4SGreg Roach ); 242cb7a42eaSGreg Roach 243*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 24483c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitytė/'); 245cb7a42eaSGreg Roach 246*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 24783c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 248cb7a42eaSGreg Roach 2495e933c21SGreg Roach self::assertSame( 2508939e2c2SGreg Roach ["1 NAME /Whitis/\n2 TYPE BIRTH\n2 SURN Whitis"], 251cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 252323788f4SGreg Roach ); 253cb7a42eaSGreg Roach 254*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 25583c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitiūtė/'); 256cb7a42eaSGreg Roach 257*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 25883c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 259cb7a42eaSGreg Roach 2605e933c21SGreg Roach self::assertSame( 2618939e2c2SGreg Roach ["1 NAME /Whitius/\n2 TYPE BIRTH\n2 SURN Whitius"], 262cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 263323788f4SGreg Roach ); 264cb7a42eaSGreg Roach 265*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 26683c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitutė/'); 267cb7a42eaSGreg Roach 268*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 26983c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 270cb7a42eaSGreg Roach 2715e933c21SGreg Roach self::assertSame( 2728939e2c2SGreg Roach ["1 NAME /Whitus/\n2 TYPE BIRTH\n2 SURN Whitus"], 273cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 274323788f4SGreg Roach ); 275323788f4SGreg Roach } 276323788f4SGreg Roach 277323788f4SGreg Roach /** 278323788f4SGreg Roach * Test new mother names 279323788f4SGreg Roach */ 2809b802b22SGreg Roach public function testNewMotherNames(): void 281c1010edaSGreg Roach { 282*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 28383c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 284cb7a42eaSGreg Roach 285*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 28683c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 287cb7a42eaSGreg Roach 2885e933c21SGreg Roach self::assertSame( 2898939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 290cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'F') 291323788f4SGreg Roach ); 292323788f4SGreg Roach } 293323788f4SGreg Roach 294323788f4SGreg Roach /** 295323788f4SGreg Roach * Test new parent names 296323788f4SGreg Roach */ 2979b802b22SGreg Roach public function testNewParentNames(): void 298c1010edaSGreg Roach { 299*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 30083c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 301cb7a42eaSGreg Roach 302*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 30383c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 304cb7a42eaSGreg Roach 3055e933c21SGreg Roach self::assertSame( 3068939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 307cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'U') 308323788f4SGreg Roach ); 309323788f4SGreg Roach } 310323788f4SGreg Roach 311323788f4SGreg Roach /** 312323788f4SGreg Roach * Test new husband names 313323788f4SGreg Roach */ 3149b802b22SGreg Roach public function testNewHusbandNames(): void 315c1010edaSGreg Roach { 316*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 31783c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Black/'); 318cb7a42eaSGreg Roach 319*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 32083c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 321cb7a42eaSGreg Roach 3225e933c21SGreg Roach self::assertSame( 3238939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 324cb7a42eaSGreg Roach $this->surname_tradition->newSpouseNames($individual, 'M') 325323788f4SGreg Roach ); 326323788f4SGreg Roach } 327323788f4SGreg Roach 328323788f4SGreg Roach /** 329323788f4SGreg Roach * Test new wife names 330323788f4SGreg Roach */ 3319b802b22SGreg Roach public function testNewWifeNames(): void 332c1010edaSGreg Roach { 333*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 33483c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 335cb7a42eaSGreg Roach 336*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 33783c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 338cb7a42eaSGreg Roach 3395e933c21SGreg Roach self::assertSame( 3408939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH", "1 NAME /White/\n2 TYPE MARRIED\n2 SURN White"], 341cb7a42eaSGreg Roach $this->surname_tradition->newSpouseNames($individual, 'F') 342323788f4SGreg Roach ); 343323788f4SGreg Roach } 344323788f4SGreg Roach 345323788f4SGreg Roach /** 346323788f4SGreg Roach * Test new spouse names 347323788f4SGreg Roach */ 3489b802b22SGreg Roach public function testNewSpouseNames(): void 349c1010edaSGreg Roach { 350*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 35183c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 352cb7a42eaSGreg Roach 353*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 35483c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 355cb7a42eaSGreg Roach 3565e933c21SGreg Roach self::assertSame( 3578939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 358cb7a42eaSGreg Roach $this->surname_tradition->newSpouseNames($individual, 'U') 359323788f4SGreg Roach ); 360323788f4SGreg Roach } 361323788f4SGreg Roach} 362