1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2018 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16namespace Fisharebest\Webtrees\SurnameTradition; 17 18use Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition; 19use Fisharebest\Webtrees\SurnameTradition\SurnameTraditionInterface; 20 21/** 22 * Test harness for the class PaternalSurnameTradition 23 */ 24class PaternalSurnameTraditionTest 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 public function setUp() 35 { 36 $this->surname_tradition = new PaternalSurnameTradition; 37 } 38 39 /** 40 * Test whether married surnames are used 41 * 42 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 43 * 44 * @return void 45 */ 46 public function testMarriedSurnames() 47 { 48 $this->assertSame(true, $this->surname_tradition->hasMarriedNames()); 49 } 50 51 /** 52 * Test whether surnames are used 53 * 54 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 55 * 56 * @return void 57 */ 58 public function testSurnames() 59 { 60 $this->assertSame(true, $this->surname_tradition->hasSurnames()); 61 } 62 63 /** 64 * Test new son names 65 * 66 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 67 * 68 * @return void 69 */ 70 public function testNewSonNames() 71 { 72 $this->assertSame( 73 [ 74 'NAME' => '/White/', 75 'SURN' => 'White', 76 ], 77 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') 78 ); 79 } 80 81 /** 82 * Test new daughter names 83 * 84 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 85 * 86 * @return void 87 */ 88 public function testNewDaughterNames() 89 { 90 $this->assertSame( 91 [ 92 'NAME' => '/White/', 93 'SURN' => 'White', 94 ], 95 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') 96 ); 97 } 98 99 /** 100 * Test new child names 101 * 102 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 103 * 104 * @return void 105 */ 106 public function testNewChildNames() 107 { 108 $this->assertSame( 109 [ 110 'NAME' => '/White/', 111 'SURN' => 'White', 112 ], 113 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') 114 ); 115 } 116 117 /** 118 * Test new child names 119 * 120 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 121 * 122 * @return void 123 */ 124 public function testNewChildNamesWithSpfx() 125 { 126 $this->assertSame( 127 [ 128 'NAME' => '/de White/', 129 'SPFX' => 'de', 130 'SURN' => 'White', 131 ], 132 $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') 133 ); 134 } 135 136 /** 137 * Test new child names 138 * 139 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 140 * 141 * @return void 142 */ 143 public function testNewChildNamesWithMultipleSpfx() 144 { 145 $this->assertSame( 146 [ 147 'NAME' => '/van der White/', 148 'SPFX' => 'van der', 149 'SURN' => 'White', 150 ], 151 $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U') 152 ); 153 } 154 155 /** 156 * Test new child names 157 * 158 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 159 * 160 * @return void 161 */ 162 public function testNewChildNamesWithDutchSpfx() 163 { 164 $this->assertSame( 165 [ 166 'NAME' => '/\'t White/', 167 'SPFX' => '\'t', 168 'SURN' => 'White', 169 ], 170 $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U') 171 ); 172 $this->assertSame( 173 [ 174 'NAME' => '/’t White/', 175 'SPFX' => '’t', 176 'SURN' => 'White', 177 ], 178 $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U') 179 ); 180 } 181 182 /** 183 * Test new child names 184 * 185 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 186 * 187 * @return void 188 */ 189 public function testNewChildNamesWithMultipleDutchSpfx() 190 { 191 $this->assertSame( 192 [ 193 'NAME' => '/van \'t White/', 194 'SPFX' => 'van \'t', 195 'SURN' => 'White', 196 ], 197 $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U') 198 ); 199 $this->assertSame( 200 [ 201 'NAME' => '/van ’t White/', 202 'SPFX' => 'van ’t', 203 'SURN' => 'White', 204 ], 205 $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U') 206 ); 207 } 208 209 /** 210 * Test new father names 211 * 212 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 213 * 214 * @return void 215 */ 216 public function testNewFatherNames() 217 { 218 $this->assertSame( 219 [ 220 'NAME' => '/White/', 221 'SURN' => 'White', 222 ], 223 $this->surname_tradition->newParentNames('John /White/', 'M') 224 ); 225 } 226 227 /** 228 * Test new mother names 229 * 230 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 231 * 232 * @return void 233 */ 234 public function testNewMotherNames() 235 { 236 $this->assertSame( 237 [ 238 'NAME' => '//', 239 '_MARNM' => '/White/', 240 ], 241 $this->surname_tradition->newParentNames('John /White/', 'F') 242 ); 243 } 244 245 /** 246 * Test new parent names 247 * 248 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 249 * 250 * @return void 251 */ 252 public function testNewParentNames() 253 { 254 $this->assertSame( 255 ['NAME' => '//'], 256 $this->surname_tradition->newParentNames('John /White/', 'U') 257 ); 258 } 259 260 /** 261 * Test new husband names 262 * 263 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 264 * 265 * @return void 266 */ 267 public function testNewHusbandNames() 268 { 269 $this->assertSame( 270 ['NAME' => '//'], 271 $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') 272 ); 273 } 274 275 /** 276 * Test new wife names 277 * 278 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 279 * 280 * @return void 281 */ 282 public function testNewWifeNames() 283 { 284 $this->assertSame( 285 [ 286 'NAME' => '//', 287 '_MARNM' => '/White/', 288 ], 289 $this->surname_tradition->newSpouseNames('John /White/', 'F') 290 ); 291 } 292 293 /** 294 * Test new wife names 295 * 296 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 297 * 298 * @return void 299 */ 300 public function testNewWifeNamesWithSpfx() 301 { 302 $this->assertSame( 303 [ 304 'NAME' => '//', 305 '_MARNM' => '/van der White/', 306 ], 307 $this->surname_tradition->newSpouseNames('John /van der White/', 'F') 308 ); 309 } 310 311 /** 312 * Test new spouse names 313 * 314 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 315 * 316 * @return void 317 */ 318 public function testNewSpouseNames() 319 { 320 $this->assertSame( 321 ['NAME' => '//'], 322 $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') 323 ); 324 } 325} 326