1323788f4SGreg Roach<?php 23976b470SGreg Roach 3323788f4SGreg Roach/** 4323788f4SGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 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 223cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 233cfcc809SGreg Roach 24323788f4SGreg Roach/** 25323788f4SGreg Roach * Test harness for the class PaternalSurnameTradition 26323788f4SGreg Roach */ 273cfcc809SGreg Roachclass PaternalSurnameTraditionTest extends TestCase 28c1010edaSGreg Roach{ 29*c4943cffSGreg Roach private SurnameTraditionInterface $surname_tradition; 30323788f4SGreg Roach 31323788f4SGreg Roach /** 32323788f4SGreg Roach * Prepare the environment for these tests 3352348eb8SGreg Roach * 3452348eb8SGreg Roach * @return void 35323788f4SGreg Roach */ 365c48bcd6SGreg Roach protected function setUp(): void 37c1010edaSGreg Roach { 380115bc16SGreg Roach parent::setUp(); 390115bc16SGreg Roach 4074d6dc0eSGreg Roach $this->surname_tradition = new PaternalSurnameTradition(); 41323788f4SGreg Roach } 42323788f4SGreg Roach 43323788f4SGreg Roach /** 44323788f4SGreg Roach * Test whether married surnames are used 4517d74f3aSGreg Roach * 4615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 4752348eb8SGreg Roach * 4852348eb8SGreg Roach * @return void 49323788f4SGreg Roach */ 509b802b22SGreg Roach public function testMarriedSurnames(): void 51c1010edaSGreg Roach { 525e933c21SGreg Roach self::assertTrue($this->surname_tradition->hasMarriedNames()); 53323788f4SGreg Roach } 54323788f4SGreg Roach 55323788f4SGreg Roach /** 56c1ec7145SGreg Roach * Test whether surnames are used 5717d74f3aSGreg Roach * 5815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 5952348eb8SGreg Roach * 6052348eb8SGreg Roach * @return void 61c1ec7145SGreg Roach */ 629b802b22SGreg Roach public function testSurnames(): void 63c1010edaSGreg Roach { 645e933c21SGreg Roach self::assertTrue($this->surname_tradition->hasSurnames()); 65c1ec7145SGreg Roach } 66c1ec7145SGreg Roach 67c1ec7145SGreg Roach /** 68323788f4SGreg Roach * Test new son names 6917d74f3aSGreg Roach * 7015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 7152348eb8SGreg Roach * 7252348eb8SGreg Roach * @return void 73323788f4SGreg Roach */ 749b802b22SGreg Roach public function testNewSonNames(): void 75c1010edaSGreg Roach { 765e933c21SGreg Roach self::assertSame( 77c1010edaSGreg Roach [ 78c1010edaSGreg Roach 'NAME' => '/White/', 79c1010edaSGreg Roach 'SURN' => 'White', 80c1010edaSGreg Roach ], 81323788f4SGreg Roach $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') 82323788f4SGreg Roach ); 83323788f4SGreg Roach } 84323788f4SGreg Roach 85323788f4SGreg Roach /** 86323788f4SGreg Roach * Test new daughter names 8717d74f3aSGreg Roach * 8815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 8952348eb8SGreg Roach * 9052348eb8SGreg Roach * @return void 91323788f4SGreg Roach */ 929b802b22SGreg Roach public function testNewDaughterNames(): void 93c1010edaSGreg Roach { 945e933c21SGreg Roach self::assertSame( 95c1010edaSGreg Roach [ 96c1010edaSGreg Roach 'NAME' => '/White/', 97c1010edaSGreg Roach 'SURN' => 'White', 98c1010edaSGreg Roach ], 99323788f4SGreg Roach $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') 100323788f4SGreg Roach ); 101323788f4SGreg Roach } 102323788f4SGreg Roach 103323788f4SGreg Roach /** 104323788f4SGreg Roach * Test new child names 10517d74f3aSGreg Roach * 10615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 10752348eb8SGreg Roach * 10852348eb8SGreg Roach * @return void 109323788f4SGreg Roach */ 1109b802b22SGreg Roach public function testNewChildNames(): void 111c1010edaSGreg Roach { 1125e933c21SGreg Roach self::assertSame( 113c1010edaSGreg Roach [ 114c1010edaSGreg Roach 'NAME' => '/White/', 115c1010edaSGreg Roach 'SURN' => 'White', 116c1010edaSGreg Roach ], 117323788f4SGreg Roach $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') 118323788f4SGreg Roach ); 119323788f4SGreg Roach } 120323788f4SGreg Roach 121323788f4SGreg Roach /** 122323788f4SGreg Roach * Test new child names 12317d74f3aSGreg Roach * 12415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 12552348eb8SGreg Roach * 12652348eb8SGreg Roach * @return void 127323788f4SGreg Roach */ 1289b802b22SGreg Roach public function testNewChildNamesWithSpfx(): void 129c1010edaSGreg Roach { 1305e933c21SGreg Roach self::assertSame( 131c1010edaSGreg Roach [ 132c1010edaSGreg Roach 'NAME' => '/de White/', 133c1010edaSGreg Roach 'SPFX' => 'de', 134c1010edaSGreg Roach 'SURN' => 'White', 135c1010edaSGreg Roach ], 136323788f4SGreg Roach $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') 137323788f4SGreg Roach ); 138323788f4SGreg Roach } 139323788f4SGreg Roach 140323788f4SGreg Roach /** 1418caf8226SGreg Roach * Test new child names 1428caf8226SGreg Roach * 14315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 14452348eb8SGreg Roach * 14552348eb8SGreg Roach * @return void 1468caf8226SGreg Roach */ 1479b802b22SGreg Roach public function testNewChildNamesWithMultipleSpfx(): void 148c1010edaSGreg Roach { 1495e933c21SGreg Roach self::assertSame( 150c1010edaSGreg Roach [ 151c1010edaSGreg Roach 'NAME' => '/van der White/', 152c1010edaSGreg Roach 'SPFX' => 'van der', 153c1010edaSGreg Roach 'SURN' => 'White', 154c1010edaSGreg Roach ], 1558caf8226SGreg Roach $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U') 1568caf8226SGreg Roach ); 1578caf8226SGreg Roach } 1588caf8226SGreg Roach 1598caf8226SGreg Roach /** 1609797fe2eSGreg Roach * Test new child names 1619797fe2eSGreg Roach * 16215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 16352348eb8SGreg Roach * 16452348eb8SGreg Roach * @return void 1659797fe2eSGreg Roach */ 1669b802b22SGreg Roach public function testNewChildNamesWithDutchSpfx(): void 167c1010edaSGreg Roach { 1685e933c21SGreg Roach self::assertSame( 169c1010edaSGreg Roach [ 170c1010edaSGreg Roach 'NAME' => '/\'t White/', 171c1010edaSGreg Roach 'SPFX' => '\'t', 172c1010edaSGreg Roach 'SURN' => 'White', 173c1010edaSGreg Roach ], 1749797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U') 1759797fe2eSGreg Roach ); 1765e933c21SGreg Roach self::assertSame( 177c1010edaSGreg Roach [ 178c1010edaSGreg Roach 'NAME' => '/’t White/', 179c1010edaSGreg Roach 'SPFX' => '’t', 180c1010edaSGreg Roach 'SURN' => 'White', 181c1010edaSGreg Roach ], 1829797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U') 1839797fe2eSGreg Roach ); 1849797fe2eSGreg Roach } 1859797fe2eSGreg Roach 1869797fe2eSGreg Roach /** 1879797fe2eSGreg Roach * Test new child names 1889797fe2eSGreg Roach * 18915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 19052348eb8SGreg Roach * 19152348eb8SGreg Roach * @return void 1929797fe2eSGreg Roach */ 1939b802b22SGreg Roach public function testNewChildNamesWithMultipleDutchSpfx(): void 194c1010edaSGreg Roach { 1955e933c21SGreg Roach self::assertSame( 196c1010edaSGreg Roach [ 197c1010edaSGreg Roach 'NAME' => '/van \'t White/', 198c1010edaSGreg Roach 'SPFX' => 'van \'t', 199c1010edaSGreg Roach 'SURN' => 'White', 200c1010edaSGreg Roach ], 2019797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U') 2029797fe2eSGreg Roach ); 2035e933c21SGreg Roach self::assertSame( 204c1010edaSGreg Roach [ 205c1010edaSGreg Roach 'NAME' => '/van ’t White/', 206c1010edaSGreg Roach 'SPFX' => 'van ’t', 207c1010edaSGreg Roach 'SURN' => 'White', 208c1010edaSGreg Roach ], 2099797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U') 2109797fe2eSGreg Roach ); 2119797fe2eSGreg Roach } 2129797fe2eSGreg Roach 2139797fe2eSGreg Roach /** 214323788f4SGreg Roach * Test new father names 21517d74f3aSGreg Roach * 21615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 21752348eb8SGreg Roach * 21852348eb8SGreg Roach * @return void 219323788f4SGreg Roach */ 2209b802b22SGreg Roach public function testNewFatherNames(): void 221c1010edaSGreg Roach { 2225e933c21SGreg Roach self::assertSame( 223c1010edaSGreg Roach [ 224c1010edaSGreg Roach 'NAME' => '/White/', 225c1010edaSGreg Roach 'SURN' => 'White', 226c1010edaSGreg Roach ], 227323788f4SGreg Roach $this->surname_tradition->newParentNames('John /White/', 'M') 228323788f4SGreg Roach ); 229323788f4SGreg Roach } 230323788f4SGreg Roach 231323788f4SGreg Roach /** 232323788f4SGreg Roach * Test new mother names 23317d74f3aSGreg Roach * 23415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 23552348eb8SGreg Roach * 23652348eb8SGreg Roach * @return void 237323788f4SGreg Roach */ 2389b802b22SGreg Roach public function testNewMotherNames(): void 239c1010edaSGreg Roach { 2405e933c21SGreg Roach self::assertSame( 241c1010edaSGreg Roach [ 242c1010edaSGreg Roach 'NAME' => '//', 243c1010edaSGreg Roach '_MARNM' => '/White/', 244c1010edaSGreg Roach ], 245323788f4SGreg Roach $this->surname_tradition->newParentNames('John /White/', 'F') 246323788f4SGreg Roach ); 247323788f4SGreg Roach } 248323788f4SGreg Roach 249323788f4SGreg Roach /** 250323788f4SGreg Roach * Test new parent names 25117d74f3aSGreg Roach * 25215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 25352348eb8SGreg Roach * 25452348eb8SGreg Roach * @return void 255323788f4SGreg Roach */ 2569b802b22SGreg Roach public function testNewParentNames(): void 257c1010edaSGreg Roach { 2585e933c21SGreg Roach self::assertSame( 25913abd6f3SGreg Roach ['NAME' => '//'], 260323788f4SGreg Roach $this->surname_tradition->newParentNames('John /White/', 'U') 261323788f4SGreg Roach ); 262323788f4SGreg Roach } 263323788f4SGreg Roach 264323788f4SGreg Roach /** 265323788f4SGreg Roach * Test new husband names 26617d74f3aSGreg Roach * 26715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 26852348eb8SGreg Roach * 26952348eb8SGreg Roach * @return void 270323788f4SGreg Roach */ 2719b802b22SGreg Roach public function testNewHusbandNames(): void 272c1010edaSGreg Roach { 2735e933c21SGreg Roach self::assertSame( 27413abd6f3SGreg Roach ['NAME' => '//'], 275323788f4SGreg Roach $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') 276323788f4SGreg Roach ); 277323788f4SGreg Roach } 278323788f4SGreg Roach 279323788f4SGreg Roach /** 280323788f4SGreg Roach * Test new wife names 28117d74f3aSGreg Roach * 28215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 28352348eb8SGreg Roach * 28452348eb8SGreg Roach * @return void 285323788f4SGreg Roach */ 2869b802b22SGreg Roach public function testNewWifeNames(): void 287c1010edaSGreg Roach { 2885e933c21SGreg Roach self::assertSame( 289c1010edaSGreg Roach [ 290c1010edaSGreg Roach 'NAME' => '//', 291c1010edaSGreg Roach '_MARNM' => '/White/', 292c1010edaSGreg Roach ], 293323788f4SGreg Roach $this->surname_tradition->newSpouseNames('John /White/', 'F') 294323788f4SGreg Roach ); 295323788f4SGreg Roach } 296323788f4SGreg Roach 297323788f4SGreg Roach /** 2985b2de99fSGreg Roach * Test new wife names 2995b2de99fSGreg Roach * 30015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 30152348eb8SGreg Roach * 30252348eb8SGreg Roach * @return void 3035b2de99fSGreg Roach */ 3049b802b22SGreg Roach public function testNewWifeNamesWithSpfx(): void 305c1010edaSGreg Roach { 3065e933c21SGreg Roach self::assertSame( 307c1010edaSGreg Roach [ 308c1010edaSGreg Roach 'NAME' => '//', 309c1010edaSGreg Roach '_MARNM' => '/van der White/', 310c1010edaSGreg Roach ], 3115b2de99fSGreg Roach $this->surname_tradition->newSpouseNames('John /van der White/', 'F') 3125b2de99fSGreg Roach ); 3135b2de99fSGreg Roach } 3145b2de99fSGreg Roach 3155b2de99fSGreg Roach /** 316323788f4SGreg Roach * Test new spouse names 31717d74f3aSGreg Roach * 31815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 31952348eb8SGreg Roach * 32052348eb8SGreg Roach * @return void 321323788f4SGreg Roach */ 3229b802b22SGreg Roach public function testNewSpouseNames(): void 323c1010edaSGreg Roach { 3245e933c21SGreg Roach self::assertSame( 32513abd6f3SGreg Roach ['NAME' => '//'], 326323788f4SGreg Roach $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') 327323788f4SGreg Roach ); 328323788f4SGreg Roach } 329323788f4SGreg Roach} 330