1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>. 16 */ 17declare(strict_types=1); 18 19namespace Fisharebest\Webtrees\SurnameTradition; 20 21/** 22 * Test harness for the class PatrilinenalSurnameTradition 23 */ 24class MatrilinealSurnameTraditionTest extends \Fisharebest\Webtrees\TestCase 25{ 26 /** @var SurnameTraditionInterface */ 27 private $surname_tradition; 28 29 /** 30 * Prepare the environment for these tests 31 * 32 * @return void 33 */ 34 protected function setUp(): void 35 { 36 parent::setUp(); 37 38 $this->surname_tradition = new MatrilinealSurnameTradition(); 39 } 40 41 /** 42 * Test whether married surnames are used 43 * 44 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 45 * 46 * @return void 47 */ 48 public function testMarriedSurnames(): void 49 { 50 $this->assertFalse($this->surname_tradition->hasMarriedNames()); 51 } 52 53 /** 54 * Test whether surnames are used 55 * 56 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 57 * 58 * @return void 59 */ 60 public function testSurnames(): void 61 { 62 $this->assertTrue($this->surname_tradition->hasSurnames()); 63 } 64 65 /** 66 * Test new son names 67 * 68 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 69 * 70 * @return void 71 */ 72 public function testNewSonNames(): void 73 { 74 $this->assertSame( 75 [ 76 'NAME' => '/Black/', 77 'SURN' => 'Black', 78 ], 79 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') 80 ); 81 } 82 83 /** 84 * Test new daughter names 85 * 86 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 87 * 88 * @return void 89 */ 90 public function testNewDaughterNames(): void 91 { 92 $this->assertSame( 93 [ 94 'NAME' => '/Black/', 95 'SURN' => 'Black', 96 ], 97 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') 98 ); 99 } 100 101 /** 102 * Test new child names 103 * 104 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 105 * 106 * @return void 107 */ 108 public function testNewChildNames(): void 109 { 110 $this->assertSame( 111 [ 112 'NAME' => '/Black/', 113 'SURN' => 'Black', 114 ], 115 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') 116 ); 117 } 118 119 /** 120 * Test new child names 121 * 122 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 123 * 124 * @return void 125 */ 126 public function testNewChildNamesWithSpfx(): void 127 { 128 $this->assertSame( 129 [ 130 'NAME' => '/van Black/', 131 'SPFX' => 'van', 132 'SURN' => 'Black', 133 ], 134 $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') 135 ); 136 } 137 138 /** 139 * Test new child names 140 * 141 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 142 * 143 * @return void 144 */ 145 public function testNewChildNamesWithNoParentsNames(): void 146 { 147 $this->assertSame( 148 ['NAME' => '//'], 149 $this->surname_tradition->newChildNames('', '', 'U') 150 ); 151 } 152 153 /** 154 * Test new father names 155 * 156 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 157 * 158 * @return void 159 */ 160 public function testNewFatherNames(): void 161 { 162 $this->assertSame( 163 ['NAME' => '//'], 164 $this->surname_tradition->newParentNames('John /White/', 'M') 165 ); 166 } 167 168 /** 169 * Test new mother names 170 * 171 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 172 * 173 * @return void 174 */ 175 public function testNewMotherNames(): void 176 { 177 $this->assertSame( 178 [ 179 'NAME' => '/White/', 180 'SURN' => 'White', 181 ], 182 $this->surname_tradition->newParentNames('John /White/', 'F') 183 ); 184 } 185 186 /** 187 * Test new parent names 188 * 189 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 190 * 191 * @return void 192 */ 193 public function testNewParentNames(): void 194 { 195 $this->assertSame( 196 ['NAME' => '//'], 197 $this->surname_tradition->newParentNames('John /White/', 'U') 198 ); 199 } 200 201 /** 202 * Test new husband names 203 * 204 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 205 * 206 * @return void 207 */ 208 public function testNewHusbandNames(): void 209 { 210 $this->assertSame( 211 ['NAME' => '//'], 212 $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') 213 ); 214 } 215 216 /** 217 * Test new wife names 218 * 219 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 220 * 221 * @return void 222 */ 223 public function testNewWifeNames(): void 224 { 225 $this->assertSame( 226 ['NAME' => '//'], 227 $this->surname_tradition->newSpouseNames('John /White/', 'F') 228 ); 229 } 230 231 /** 232 * Test new spouse names 233 * 234 * @covers \Fisharebest\Webtrees\SurnameTradition\MatrilinealSurnameTradition 235 * 236 * @return void 237 */ 238 public function testNewSpouseNames(): void 239 { 240 $this->assertSame( 241 ['NAME' => '//'], 242 $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') 243 ); 244 } 245} 246