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 29202c018bSGreg Roach#[CoversClass(LithuanianSurnameTradition::class)] 30202c018bSGreg Roach#[CoversClass(PatrilinealSurnameTradition::class)] 313cfcc809SGreg Roachclass LithuanianSurnameTraditionTest extends TestCase 32c1010edaSGreg Roach{ 33c4943cffSGreg Roach private SurnameTraditionInterface $surname_tradition; 34323788f4SGreg Roach 35323788f4SGreg Roach /** 36323788f4SGreg Roach * Prepare the environment for these tests 37323788f4SGreg Roach */ 385c48bcd6SGreg Roach protected function setUp(): void 39c1010edaSGreg Roach { 400115bc16SGreg Roach parent::setUp(); 410115bc16SGreg Roach 4274d6dc0eSGreg Roach $this->surname_tradition = new LithuanianSurnameTradition(); 43323788f4SGreg Roach } 44323788f4SGreg Roach 45323788f4SGreg Roach /** 46c1ec7145SGreg Roach * Test whether surnames are used 47c1ec7145SGreg Roach */ 489b802b22SGreg Roach public function testSurnames(): void 49c1010edaSGreg Roach { 50a171b6a5SGreg Roach self::assertSame('//', $this->surname_tradition->defaultName()); 51c1ec7145SGreg Roach } 52c1ec7145SGreg Roach 53c1ec7145SGreg Roach /** 54323788f4SGreg Roach * Test new son names 55323788f4SGreg Roach */ 569b802b22SGreg Roach public function testNewSonNames(): void 57c1010edaSGreg Roach { 58*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 5983c91e47SGreg Roach $father_fact->method('value')->willReturn('John /White/'); 60cb7a42eaSGreg Roach 61*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 6283c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 63cb7a42eaSGreg Roach 64*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 6583c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 66cb7a42eaSGreg Roach 67*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 6883c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 69cb7a42eaSGreg Roach 705e933c21SGreg Roach self::assertSame( 718939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 72cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'M') 73323788f4SGreg Roach ); 74323788f4SGreg Roach } 75323788f4SGreg Roach 76323788f4SGreg Roach /** 77323788f4SGreg Roach * Test new daughter names 78323788f4SGreg Roach */ 799b802b22SGreg Roach public function testNewDaughterNames(): void 80c1010edaSGreg Roach { 81*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 8283c91e47SGreg Roach $father_fact->method('value')->willReturn('John /White/'); 83cb7a42eaSGreg Roach 84*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 8583c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 86cb7a42eaSGreg Roach 87*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 8883c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 89cb7a42eaSGreg Roach 90*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 9183c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 92cb7a42eaSGreg Roach 935e933c21SGreg Roach self::assertSame( 948939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 95cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 96323788f4SGreg Roach ); 97323788f4SGreg Roach } 98323788f4SGreg Roach 99323788f4SGreg Roach /** 100323788f4SGreg Roach * Test new daughter names 101323788f4SGreg Roach */ 1029b802b22SGreg Roach public function testNewDaughterNamesInflected(): void 103c1010edaSGreg Roach { 104*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 10583c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whita/'); 106cb7a42eaSGreg Roach 107*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 10883c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 109cb7a42eaSGreg Roach 110*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 11183c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 112cb7a42eaSGreg Roach 113*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 11483c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 115cb7a42eaSGreg Roach 1165e933c21SGreg Roach self::assertSame( 1178939e2c2SGreg Roach ["1 NAME /Whitaitė/\n2 TYPE BIRTH\n2 SURN Whita"], 118cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 119323788f4SGreg Roach ); 120cb7a42eaSGreg Roach 121*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 12283c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitas/'); 123cb7a42eaSGreg Roach 124*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 12583c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 126cb7a42eaSGreg Roach 1275e933c21SGreg Roach self::assertSame( 1288939e2c2SGreg Roach ["1 NAME /Whitaitė/\n2 TYPE BIRTH\n2 SURN Whitas"], 129cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 130323788f4SGreg Roach ); 131cb7a42eaSGreg Roach 132*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 13383c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitis/'); 134cb7a42eaSGreg Roach 135*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 13683c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 137cb7a42eaSGreg Roach 1385e933c21SGreg Roach self::assertSame( 1398939e2c2SGreg Roach ["1 NAME /Whitytė/\n2 TYPE BIRTH\n2 SURN Whitis"], 140cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 141323788f4SGreg Roach ); 142cb7a42eaSGreg Roach 143*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 14483c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitys/'); 145cb7a42eaSGreg Roach 146*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 14783c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 148cb7a42eaSGreg Roach 1495e933c21SGreg Roach self::assertSame( 1508939e2c2SGreg Roach ["1 NAME /Whitytė/\n2 TYPE BIRTH\n2 SURN Whitys"], 151cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 152323788f4SGreg Roach ); 153cb7a42eaSGreg Roach 154*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 15583c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitius/'); 156cb7a42eaSGreg Roach 157*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 15883c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 159cb7a42eaSGreg Roach 1605e933c21SGreg Roach self::assertSame( 1618939e2c2SGreg Roach ["1 NAME /Whitiūtė/\n2 TYPE BIRTH\n2 SURN Whitius"], 162cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 163323788f4SGreg Roach ); 164cb7a42eaSGreg Roach 165*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 16683c91e47SGreg Roach $father_fact->method('value')->willReturn('John /Whitus/'); 167cb7a42eaSGreg Roach 168*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 16983c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 170cb7a42eaSGreg Roach 1715e933c21SGreg Roach self::assertSame( 1728939e2c2SGreg Roach ["1 NAME /Whitutė/\n2 TYPE BIRTH\n2 SURN Whitus"], 173cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'F') 174323788f4SGreg Roach ); 175323788f4SGreg Roach } 176323788f4SGreg Roach 177323788f4SGreg Roach /** 178323788f4SGreg Roach * Test new child names 179323788f4SGreg Roach */ 1809b802b22SGreg Roach public function testNewChildNames(): void 181c1010edaSGreg Roach { 182*62ff2f18SGreg Roach $father_fact = $this->createMock(Fact::class); 18383c91e47SGreg Roach $father_fact->method('value')->willReturn('John /White/'); 184cb7a42eaSGreg Roach 185*62ff2f18SGreg Roach $father = $this->createMock(Individual::class); 18683c91e47SGreg Roach $father->method('facts')->willReturn(new Collection([$father_fact])); 187cb7a42eaSGreg Roach 188*62ff2f18SGreg Roach $mother_fact = $this->createMock(Fact::class); 18983c91e47SGreg Roach $mother_fact->method('value')->willReturn('Mary /Black/'); 190cb7a42eaSGreg Roach 191*62ff2f18SGreg Roach $mother = $this->createMock(Individual::class); 19283c91e47SGreg Roach $mother->method('facts')->willReturn(new Collection([$mother_fact])); 193cb7a42eaSGreg Roach 1945e933c21SGreg Roach self::assertSame( 1958939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 196cb7a42eaSGreg Roach $this->surname_tradition->newChildNames($father, $mother, 'U') 197323788f4SGreg Roach ); 198323788f4SGreg Roach } 199323788f4SGreg Roach 200323788f4SGreg Roach /** 2011677a03aSGreg Roach * Test new child names 2021677a03aSGreg Roach */ 2039b802b22SGreg Roach public function testNewChildNamesWithNoParentsNames(): void 204c1010edaSGreg Roach { 2055e933c21SGreg Roach self::assertSame( 2068939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 207cb7a42eaSGreg Roach $this->surname_tradition->newChildNames(null, null, 'U') 2081677a03aSGreg Roach ); 2091677a03aSGreg Roach } 2101677a03aSGreg Roach 2111677a03aSGreg Roach /** 212323788f4SGreg Roach * Test new father names 213323788f4SGreg Roach */ 2149b802b22SGreg Roach public function testNewFatherNames(): void 215c1010edaSGreg Roach { 216*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 21783c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 218cb7a42eaSGreg Roach 219*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 22083c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 221cb7a42eaSGreg Roach 2225e933c21SGreg Roach self::assertSame( 2238939e2c2SGreg Roach ["1 NAME /White/\n2 TYPE BIRTH\n2 SURN White"], 224cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 225323788f4SGreg Roach ); 226323788f4SGreg Roach } 227323788f4SGreg Roach 228323788f4SGreg Roach /** 229323788f4SGreg Roach * Test new father names 230323788f4SGreg Roach */ 2319b802b22SGreg Roach public function testNewFatherNamesInflected(): void 232c1010edaSGreg Roach { 233*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 23483c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitaitė/'); 235cb7a42eaSGreg Roach 236*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 23783c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 238cb7a42eaSGreg Roach 2395e933c21SGreg Roach self::assertSame( 2408939e2c2SGreg Roach ["1 NAME /Whitas/\n2 TYPE BIRTH\n2 SURN Whitas"], 241cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 242323788f4SGreg Roach ); 243cb7a42eaSGreg Roach 244*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 24583c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitytė/'); 246cb7a42eaSGreg Roach 247*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 24883c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 249cb7a42eaSGreg Roach 2505e933c21SGreg Roach self::assertSame( 2518939e2c2SGreg Roach ["1 NAME /Whitis/\n2 TYPE BIRTH\n2 SURN Whitis"], 252cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 253323788f4SGreg Roach ); 254cb7a42eaSGreg Roach 255*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 25683c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitiūtė/'); 257cb7a42eaSGreg Roach 258*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 25983c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 260cb7a42eaSGreg Roach 2615e933c21SGreg Roach self::assertSame( 2628939e2c2SGreg Roach ["1 NAME /Whitius/\n2 TYPE BIRTH\n2 SURN Whitius"], 263cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 264323788f4SGreg Roach ); 265cb7a42eaSGreg Roach 266*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 26783c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Whitutė/'); 268cb7a42eaSGreg Roach 269*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 27083c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 271cb7a42eaSGreg Roach 2725e933c21SGreg Roach self::assertSame( 2738939e2c2SGreg Roach ["1 NAME /Whitus/\n2 TYPE BIRTH\n2 SURN Whitus"], 274cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'M') 275323788f4SGreg Roach ); 276323788f4SGreg Roach } 277323788f4SGreg Roach 278323788f4SGreg Roach /** 279323788f4SGreg Roach * Test new mother names 280323788f4SGreg Roach */ 2819b802b22SGreg Roach public function testNewMotherNames(): void 282c1010edaSGreg Roach { 283*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 28483c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 285cb7a42eaSGreg Roach 286*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 28783c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 288cb7a42eaSGreg Roach 2895e933c21SGreg Roach self::assertSame( 2908939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 291cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'F') 292323788f4SGreg Roach ); 293323788f4SGreg Roach } 294323788f4SGreg Roach 295323788f4SGreg Roach /** 296323788f4SGreg Roach * Test new parent names 297323788f4SGreg Roach */ 2989b802b22SGreg Roach public function testNewParentNames(): void 299c1010edaSGreg Roach { 300*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 30183c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 302cb7a42eaSGreg Roach 303*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 30483c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 305cb7a42eaSGreg Roach 3065e933c21SGreg Roach self::assertSame( 3078939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 308cb7a42eaSGreg Roach $this->surname_tradition->newParentNames($individual, 'U') 309323788f4SGreg Roach ); 310323788f4SGreg Roach } 311323788f4SGreg Roach 312323788f4SGreg Roach /** 313323788f4SGreg Roach * Test new husband names 314323788f4SGreg Roach */ 3159b802b22SGreg Roach public function testNewHusbandNames(): void 316c1010edaSGreg Roach { 317*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 31883c91e47SGreg Roach $fact->method('value')->willReturn('Mary /Black/'); 319cb7a42eaSGreg Roach 320*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 32183c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 322cb7a42eaSGreg Roach 3235e933c21SGreg Roach self::assertSame( 3248939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 325cb7a42eaSGreg Roach $this->surname_tradition->newSpouseNames($individual, 'M') 326323788f4SGreg Roach ); 327323788f4SGreg Roach } 328323788f4SGreg Roach 329323788f4SGreg Roach /** 330323788f4SGreg Roach * Test new wife names 331323788f4SGreg Roach */ 3329b802b22SGreg Roach public function testNewWifeNames(): void 333c1010edaSGreg Roach { 334*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 33583c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 336cb7a42eaSGreg Roach 337*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 33883c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 339cb7a42eaSGreg Roach 3405e933c21SGreg Roach self::assertSame( 3418939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH", "1 NAME /White/\n2 TYPE MARRIED\n2 SURN White"], 342cb7a42eaSGreg Roach $this->surname_tradition->newSpouseNames($individual, 'F') 343323788f4SGreg Roach ); 344323788f4SGreg Roach } 345323788f4SGreg Roach 346323788f4SGreg Roach /** 347323788f4SGreg Roach * Test new spouse names 348323788f4SGreg Roach */ 3499b802b22SGreg Roach public function testNewSpouseNames(): void 350c1010edaSGreg Roach { 351*62ff2f18SGreg Roach $fact = $this->createMock(Fact::class); 35283c91e47SGreg Roach $fact->method('value')->willReturn('John /White/'); 353cb7a42eaSGreg Roach 354*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 35583c91e47SGreg Roach $individual->method('facts')->willReturn(new Collection([$fact])); 356cb7a42eaSGreg Roach 3575e933c21SGreg Roach self::assertSame( 3588939e2c2SGreg Roach ["1 NAME //\n2 TYPE BIRTH"], 359cb7a42eaSGreg Roach $this->surname_tradition->newSpouseNames($individual, 'U') 360323788f4SGreg Roach ); 361323788f4SGreg Roach } 362323788f4SGreg Roach} 363