1323788f4SGreg Roach<?php 23976b470SGreg Roach 3323788f4SGreg Roach/** 4323788f4SGreg Roach * webtrees: online genealogy 5*5e933c21SGreg Roach * Copyright (C) 2020 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 15323788f4SGreg Roach * along with this program. If not, see <http://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{ 29323788f4SGreg Roach /** @var SurnameTraditionInterface */ 30323788f4SGreg Roach private $surname_tradition; 31323788f4SGreg Roach 32323788f4SGreg Roach /** 33323788f4SGreg Roach * Prepare the environment for these tests 3452348eb8SGreg Roach * 3552348eb8SGreg Roach * @return void 36323788f4SGreg Roach */ 375c48bcd6SGreg Roach protected function setUp(): void 38c1010edaSGreg Roach { 390115bc16SGreg Roach parent::setUp(); 400115bc16SGreg Roach 4174d6dc0eSGreg Roach $this->surname_tradition = new PaternalSurnameTradition(); 42323788f4SGreg Roach } 43323788f4SGreg Roach 44323788f4SGreg Roach /** 45323788f4SGreg Roach * Test whether married surnames are used 4617d74f3aSGreg Roach * 4715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 4852348eb8SGreg Roach * 4952348eb8SGreg Roach * @return void 50323788f4SGreg Roach */ 519b802b22SGreg Roach public function testMarriedSurnames(): void 52c1010edaSGreg Roach { 53*5e933c21SGreg Roach self::assertTrue($this->surname_tradition->hasMarriedNames()); 54323788f4SGreg Roach } 55323788f4SGreg Roach 56323788f4SGreg Roach /** 57c1ec7145SGreg Roach * Test whether surnames are used 5817d74f3aSGreg Roach * 5915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 6052348eb8SGreg Roach * 6152348eb8SGreg Roach * @return void 62c1ec7145SGreg Roach */ 639b802b22SGreg Roach public function testSurnames(): void 64c1010edaSGreg Roach { 65*5e933c21SGreg Roach self::assertTrue($this->surname_tradition->hasSurnames()); 66c1ec7145SGreg Roach } 67c1ec7145SGreg Roach 68c1ec7145SGreg Roach /** 69323788f4SGreg Roach * Test new son names 7017d74f3aSGreg Roach * 7115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 7252348eb8SGreg Roach * 7352348eb8SGreg Roach * @return void 74323788f4SGreg Roach */ 759b802b22SGreg Roach public function testNewSonNames(): void 76c1010edaSGreg Roach { 77*5e933c21SGreg Roach self::assertSame( 78c1010edaSGreg Roach [ 79c1010edaSGreg Roach 'NAME' => '/White/', 80c1010edaSGreg Roach 'SURN' => 'White', 81c1010edaSGreg Roach ], 82323788f4SGreg Roach $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') 83323788f4SGreg Roach ); 84323788f4SGreg Roach } 85323788f4SGreg Roach 86323788f4SGreg Roach /** 87323788f4SGreg Roach * Test new daughter names 8817d74f3aSGreg Roach * 8915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 9052348eb8SGreg Roach * 9152348eb8SGreg Roach * @return void 92323788f4SGreg Roach */ 939b802b22SGreg Roach public function testNewDaughterNames(): void 94c1010edaSGreg Roach { 95*5e933c21SGreg Roach self::assertSame( 96c1010edaSGreg Roach [ 97c1010edaSGreg Roach 'NAME' => '/White/', 98c1010edaSGreg Roach 'SURN' => 'White', 99c1010edaSGreg Roach ], 100323788f4SGreg Roach $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') 101323788f4SGreg Roach ); 102323788f4SGreg Roach } 103323788f4SGreg Roach 104323788f4SGreg Roach /** 105323788f4SGreg Roach * Test new child names 10617d74f3aSGreg Roach * 10715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 10852348eb8SGreg Roach * 10952348eb8SGreg Roach * @return void 110323788f4SGreg Roach */ 1119b802b22SGreg Roach public function testNewChildNames(): void 112c1010edaSGreg Roach { 113*5e933c21SGreg Roach self::assertSame( 114c1010edaSGreg Roach [ 115c1010edaSGreg Roach 'NAME' => '/White/', 116c1010edaSGreg Roach 'SURN' => 'White', 117c1010edaSGreg Roach ], 118323788f4SGreg Roach $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') 119323788f4SGreg Roach ); 120323788f4SGreg Roach } 121323788f4SGreg Roach 122323788f4SGreg Roach /** 123323788f4SGreg Roach * Test new child names 12417d74f3aSGreg Roach * 12515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 12652348eb8SGreg Roach * 12752348eb8SGreg Roach * @return void 128323788f4SGreg Roach */ 1299b802b22SGreg Roach public function testNewChildNamesWithSpfx(): void 130c1010edaSGreg Roach { 131*5e933c21SGreg Roach self::assertSame( 132c1010edaSGreg Roach [ 133c1010edaSGreg Roach 'NAME' => '/de White/', 134c1010edaSGreg Roach 'SPFX' => 'de', 135c1010edaSGreg Roach 'SURN' => 'White', 136c1010edaSGreg Roach ], 137323788f4SGreg Roach $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') 138323788f4SGreg Roach ); 139323788f4SGreg Roach } 140323788f4SGreg Roach 141323788f4SGreg Roach /** 1428caf8226SGreg Roach * Test new child names 1438caf8226SGreg Roach * 14415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 14552348eb8SGreg Roach * 14652348eb8SGreg Roach * @return void 1478caf8226SGreg Roach */ 1489b802b22SGreg Roach public function testNewChildNamesWithMultipleSpfx(): void 149c1010edaSGreg Roach { 150*5e933c21SGreg Roach self::assertSame( 151c1010edaSGreg Roach [ 152c1010edaSGreg Roach 'NAME' => '/van der White/', 153c1010edaSGreg Roach 'SPFX' => 'van der', 154c1010edaSGreg Roach 'SURN' => 'White', 155c1010edaSGreg Roach ], 1568caf8226SGreg Roach $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U') 1578caf8226SGreg Roach ); 1588caf8226SGreg Roach } 1598caf8226SGreg Roach 1608caf8226SGreg Roach /** 1619797fe2eSGreg Roach * Test new child names 1629797fe2eSGreg Roach * 16315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 16452348eb8SGreg Roach * 16552348eb8SGreg Roach * @return void 1669797fe2eSGreg Roach */ 1679b802b22SGreg Roach public function testNewChildNamesWithDutchSpfx(): void 168c1010edaSGreg Roach { 169*5e933c21SGreg Roach self::assertSame( 170c1010edaSGreg Roach [ 171c1010edaSGreg Roach 'NAME' => '/\'t White/', 172c1010edaSGreg Roach 'SPFX' => '\'t', 173c1010edaSGreg Roach 'SURN' => 'White', 174c1010edaSGreg Roach ], 1759797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U') 1769797fe2eSGreg Roach ); 177*5e933c21SGreg Roach self::assertSame( 178c1010edaSGreg Roach [ 179c1010edaSGreg Roach 'NAME' => '/’t White/', 180c1010edaSGreg Roach 'SPFX' => '’t', 181c1010edaSGreg Roach 'SURN' => 'White', 182c1010edaSGreg Roach ], 1839797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U') 1849797fe2eSGreg Roach ); 1859797fe2eSGreg Roach } 1869797fe2eSGreg Roach 1879797fe2eSGreg Roach /** 1889797fe2eSGreg Roach * Test new child names 1899797fe2eSGreg Roach * 19015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 19152348eb8SGreg Roach * 19252348eb8SGreg Roach * @return void 1939797fe2eSGreg Roach */ 1949b802b22SGreg Roach public function testNewChildNamesWithMultipleDutchSpfx(): void 195c1010edaSGreg Roach { 196*5e933c21SGreg Roach self::assertSame( 197c1010edaSGreg Roach [ 198c1010edaSGreg Roach 'NAME' => '/van \'t White/', 199c1010edaSGreg Roach 'SPFX' => 'van \'t', 200c1010edaSGreg Roach 'SURN' => 'White', 201c1010edaSGreg Roach ], 2029797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U') 2039797fe2eSGreg Roach ); 204*5e933c21SGreg Roach self::assertSame( 205c1010edaSGreg Roach [ 206c1010edaSGreg Roach 'NAME' => '/van ’t White/', 207c1010edaSGreg Roach 'SPFX' => 'van ’t', 208c1010edaSGreg Roach 'SURN' => 'White', 209c1010edaSGreg Roach ], 2109797fe2eSGreg Roach $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U') 2119797fe2eSGreg Roach ); 2129797fe2eSGreg Roach } 2139797fe2eSGreg Roach 2149797fe2eSGreg Roach /** 215323788f4SGreg Roach * Test new father names 21617d74f3aSGreg Roach * 21715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 21852348eb8SGreg Roach * 21952348eb8SGreg Roach * @return void 220323788f4SGreg Roach */ 2219b802b22SGreg Roach public function testNewFatherNames(): void 222c1010edaSGreg Roach { 223*5e933c21SGreg Roach self::assertSame( 224c1010edaSGreg Roach [ 225c1010edaSGreg Roach 'NAME' => '/White/', 226c1010edaSGreg Roach 'SURN' => 'White', 227c1010edaSGreg Roach ], 228323788f4SGreg Roach $this->surname_tradition->newParentNames('John /White/', 'M') 229323788f4SGreg Roach ); 230323788f4SGreg Roach } 231323788f4SGreg Roach 232323788f4SGreg Roach /** 233323788f4SGreg Roach * Test new mother names 23417d74f3aSGreg Roach * 23515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 23652348eb8SGreg Roach * 23752348eb8SGreg Roach * @return void 238323788f4SGreg Roach */ 2399b802b22SGreg Roach public function testNewMotherNames(): void 240c1010edaSGreg Roach { 241*5e933c21SGreg Roach self::assertSame( 242c1010edaSGreg Roach [ 243c1010edaSGreg Roach 'NAME' => '//', 244c1010edaSGreg Roach '_MARNM' => '/White/', 245c1010edaSGreg Roach ], 246323788f4SGreg Roach $this->surname_tradition->newParentNames('John /White/', 'F') 247323788f4SGreg Roach ); 248323788f4SGreg Roach } 249323788f4SGreg Roach 250323788f4SGreg Roach /** 251323788f4SGreg Roach * Test new parent names 25217d74f3aSGreg Roach * 25315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 25452348eb8SGreg Roach * 25552348eb8SGreg Roach * @return void 256323788f4SGreg Roach */ 2579b802b22SGreg Roach public function testNewParentNames(): void 258c1010edaSGreg Roach { 259*5e933c21SGreg Roach self::assertSame( 26013abd6f3SGreg Roach ['NAME' => '//'], 261323788f4SGreg Roach $this->surname_tradition->newParentNames('John /White/', 'U') 262323788f4SGreg Roach ); 263323788f4SGreg Roach } 264323788f4SGreg Roach 265323788f4SGreg Roach /** 266323788f4SGreg Roach * Test new husband names 26717d74f3aSGreg Roach * 26815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 26952348eb8SGreg Roach * 27052348eb8SGreg Roach * @return void 271323788f4SGreg Roach */ 2729b802b22SGreg Roach public function testNewHusbandNames(): void 273c1010edaSGreg Roach { 274*5e933c21SGreg Roach self::assertSame( 27513abd6f3SGreg Roach ['NAME' => '//'], 276323788f4SGreg Roach $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') 277323788f4SGreg Roach ); 278323788f4SGreg Roach } 279323788f4SGreg Roach 280323788f4SGreg Roach /** 281323788f4SGreg Roach * Test new wife names 28217d74f3aSGreg Roach * 28315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 28452348eb8SGreg Roach * 28552348eb8SGreg Roach * @return void 286323788f4SGreg Roach */ 2879b802b22SGreg Roach public function testNewWifeNames(): void 288c1010edaSGreg Roach { 289*5e933c21SGreg Roach self::assertSame( 290c1010edaSGreg Roach [ 291c1010edaSGreg Roach 'NAME' => '//', 292c1010edaSGreg Roach '_MARNM' => '/White/', 293c1010edaSGreg Roach ], 294323788f4SGreg Roach $this->surname_tradition->newSpouseNames('John /White/', 'F') 295323788f4SGreg Roach ); 296323788f4SGreg Roach } 297323788f4SGreg Roach 298323788f4SGreg Roach /** 2995b2de99fSGreg Roach * Test new wife names 3005b2de99fSGreg Roach * 30115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 30252348eb8SGreg Roach * 30352348eb8SGreg Roach * @return void 3045b2de99fSGreg Roach */ 3059b802b22SGreg Roach public function testNewWifeNamesWithSpfx(): void 306c1010edaSGreg Roach { 307*5e933c21SGreg Roach self::assertSame( 308c1010edaSGreg Roach [ 309c1010edaSGreg Roach 'NAME' => '//', 310c1010edaSGreg Roach '_MARNM' => '/van der White/', 311c1010edaSGreg Roach ], 3125b2de99fSGreg Roach $this->surname_tradition->newSpouseNames('John /van der White/', 'F') 3135b2de99fSGreg Roach ); 3145b2de99fSGreg Roach } 3155b2de99fSGreg Roach 3165b2de99fSGreg Roach /** 317323788f4SGreg Roach * Test new spouse names 31817d74f3aSGreg Roach * 31915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 32052348eb8SGreg Roach * 32152348eb8SGreg Roach * @return void 322323788f4SGreg Roach */ 3239b802b22SGreg Roach public function testNewSpouseNames(): void 324c1010edaSGreg Roach { 325*5e933c21SGreg Roach self::assertSame( 32613abd6f3SGreg Roach ['NAME' => '//'], 327323788f4SGreg Roach $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') 328323788f4SGreg Roach ); 329323788f4SGreg Roach } 330323788f4SGreg Roach} 331