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 public function setUp() 33 { 34 $this->surname_tradition = new PaternalSurnameTradition; 35 } 36 37 /** 38 * Test whether married surnames are used 39 * 40 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 41 */ 42 public function testMarriedSurnames() 43 { 44 $this->assertSame(true, $this->surname_tradition->hasMarriedNames()); 45 } 46 47 /** 48 * Test whether surnames are used 49 * 50 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 51 */ 52 public function testSurnames() 53 { 54 $this->assertSame(true, $this->surname_tradition->hasSurnames()); 55 } 56 57 /** 58 * Test new son names 59 * 60 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 61 */ 62 public function testNewSonNames() 63 { 64 $this->assertSame( 65 [ 66 'NAME' => '/White/', 67 'SURN' => 'White', 68 ], 69 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'M') 70 ); 71 } 72 73 /** 74 * Test new daughter names 75 * 76 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 77 */ 78 public function testNewDaughterNames() 79 { 80 $this->assertSame( 81 [ 82 'NAME' => '/White/', 83 'SURN' => 'White', 84 ], 85 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'F') 86 ); 87 } 88 89 /** 90 * Test new child names 91 * 92 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 93 */ 94 public function testNewChildNames() 95 { 96 $this->assertSame( 97 [ 98 'NAME' => '/White/', 99 'SURN' => 'White', 100 ], 101 $this->surname_tradition->newChildNames('John /White/', 'Mary /Black/', 'U') 102 ); 103 } 104 105 /** 106 * Test new child names 107 * 108 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 109 */ 110 public function testNewChildNamesWithSpfx() 111 { 112 $this->assertSame( 113 [ 114 'NAME' => '/de White/', 115 'SPFX' => 'de', 116 'SURN' => 'White', 117 ], 118 $this->surname_tradition->newChildNames('John /de White/', 'Mary /van Black/', 'U') 119 ); 120 } 121 122 /** 123 * Test new child names 124 * 125 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 126 */ 127 public function testNewChildNamesWithMultipleSpfx() 128 { 129 $this->assertSame( 130 [ 131 'NAME' => '/van der White/', 132 'SPFX' => 'van der', 133 'SURN' => 'White', 134 ], 135 $this->surname_tradition->newChildNames('John /van der White/', 'Mary /van Black/', 'U') 136 ); 137 } 138 139 /** 140 * Test new child names 141 * 142 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 143 */ 144 public function testNewChildNamesWithDutchSpfx() 145 { 146 $this->assertSame( 147 [ 148 'NAME' => '/\'t White/', 149 'SPFX' => '\'t', 150 'SURN' => 'White', 151 ], 152 $this->surname_tradition->newChildNames('John /\'t White/', 'Mary /van Black/', 'U') 153 ); 154 $this->assertSame( 155 [ 156 'NAME' => '/’t White/', 157 'SPFX' => '’t', 158 'SURN' => 'White', 159 ], 160 $this->surname_tradition->newChildNames('John /’t White/', 'Mary /van Black/', 'U') 161 ); 162 } 163 164 /** 165 * Test new child names 166 * 167 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 168 */ 169 public function testNewChildNamesWithMultipleDutchSpfx() 170 { 171 $this->assertSame( 172 [ 173 'NAME' => '/van \'t White/', 174 'SPFX' => 'van \'t', 175 'SURN' => 'White', 176 ], 177 $this->surname_tradition->newChildNames('John /van \'t White/', 'Mary /van Black/', 'U') 178 ); 179 $this->assertSame( 180 [ 181 'NAME' => '/van ’t White/', 182 'SPFX' => 'van ’t', 183 'SURN' => 'White', 184 ], 185 $this->surname_tradition->newChildNames('John /van ’t White/', 'Mary /van Black/', 'U') 186 ); 187 } 188 189 /** 190 * Test new father names 191 * 192 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 193 */ 194 public function testNewFatherNames() 195 { 196 $this->assertSame( 197 [ 198 'NAME' => '/White/', 199 'SURN' => 'White', 200 ], 201 $this->surname_tradition->newParentNames('John /White/', 'M') 202 ); 203 } 204 205 /** 206 * Test new mother names 207 * 208 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 209 */ 210 public function testNewMotherNames() 211 { 212 $this->assertSame( 213 [ 214 'NAME' => '//', 215 '_MARNM' => '/White/', 216 ], 217 $this->surname_tradition->newParentNames('John /White/', 'F') 218 ); 219 } 220 221 /** 222 * Test new parent names 223 * 224 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 225 */ 226 public function testNewParentNames() 227 { 228 $this->assertSame( 229 ['NAME' => '//'], 230 $this->surname_tradition->newParentNames('John /White/', 'U') 231 ); 232 } 233 234 /** 235 * Test new husband names 236 * 237 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 238 */ 239 public function testNewHusbandNames() 240 { 241 $this->assertSame( 242 ['NAME' => '//'], 243 $this->surname_tradition->newSpouseNames('Mary /Black/', 'M') 244 ); 245 } 246 247 /** 248 * Test new wife names 249 * 250 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 251 */ 252 public function testNewWifeNames() 253 { 254 $this->assertSame( 255 [ 256 'NAME' => '//', 257 '_MARNM' => '/White/', 258 ], 259 $this->surname_tradition->newSpouseNames('John /White/', 'F') 260 ); 261 } 262 263 /** 264 * Test new wife names 265 * 266 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 267 */ 268 public function testNewWifeNamesWithSpfx() 269 { 270 $this->assertSame( 271 [ 272 'NAME' => '//', 273 '_MARNM' => '/van der White/', 274 ], 275 $this->surname_tradition->newSpouseNames('John /van der White/', 'F') 276 ); 277 } 278 279 /** 280 * Test new spouse names 281 * 282 * @covers \Fisharebest\Webtrees\SurnameTradition\PaternalSurnameTradition 283 */ 284 public function testNewSpouseNames() 285 { 286 $this->assertSame( 287 ['NAME' => '//'], 288 $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') 289 ); 290 } 291} 292