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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\SurnameTradition; 19 20use Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition; 21use Fisharebest\Webtrees\SurnameTradition\SurnameTraditionInterface; 22 23/** 24 * Test harness for the class PatrilinenalSurnameTradition 25 */ 26class PatrilinealSurnameTraditionTest extends \Fisharebest\Webtrees\TestCase 27{ 28 /** @var SurnameTraditionInterface */ 29 private $surname_tradition; 30 31 /** 32 * Prepare the environment for these tests 33 * 34 * @return void 35 */ 36 public function setUp() 37 { 38 $this->surname_tradition = new PatrilinealSurnameTradition; 39 } 40 41 /** 42 * Test whether married surnames are used 43 * 44 * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition 45 * 46 * @return void 47 */ 48 public function testMarriedSurnames() 49 { 50 $this->assertSame(false, $this->surname_tradition->hasMarriedNames()); 51 } 52 53 /** 54 * Test whether surnames are used 55 * 56 * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition 57 * 58 * @return void 59 */ 60 public function testSurnames() 61 { 62 $this->assertSame(true, $this->surname_tradition->hasSurnames()); 63 } 64 65 /** 66 * Test new son names 67 * 68 * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition 69 * 70 * @return void 71 */ 72 public function testNewSonNames() 73 { 74 $this->assertSame( 75 [ 76 'NAME' => '/White/', 77 'SURN' => 'White', 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\PatrilinealSurnameTradition 87 * 88 * @return void 89 */ 90 public function testNewDaughterNames() 91 { 92 $this->assertSame( 93 [ 94 'NAME' => '/White/', 95 'SURN' => 'White', 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\PatrilinealSurnameTradition 105 * 106 * @return void 107 */ 108 public function testNewChildNames() 109 { 110 $this->assertSame( 111 [ 112 'NAME' => '/White/', 113 'SURN' => 'White', 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\PatrilinealSurnameTradition 123 * 124 * @return void 125 */ 126 public function testNewChildNamesWithSpfx() 127 { 128 $this->assertSame( 129 [ 130 'NAME' => '/de White/', 131 'SPFX' => 'de', 132 'SURN' => 'White', 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\PatrilinealSurnameTradition 142 * 143 * @return void 144 */ 145 public function testNewChildNamesWithNoParentsNames() 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\PatrilinealSurnameTradition 157 * 158 * @return void 159 */ 160 public function testNewFatherNames() 161 { 162 $this->assertSame( 163 [ 164 'NAME' => '/White/', 165 'SURN' => 'White', 166 ], 167 $this->surname_tradition->newParentNames('John /White/', 'M') 168 ); 169 } 170 171 /** 172 * Test new mother names 173 * 174 * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition 175 * 176 * @return void 177 */ 178 public function testNewMotherNames() 179 { 180 $this->assertSame( 181 ['NAME' => '//'], 182 $this->surname_tradition->newParentNames('John /White/', 'F') 183 ); 184 } 185 186 /** 187 * Test new parent names 188 * 189 * @covers \Fisharebest\Webtrees\SurnameTradition\PatrilinealSurnameTradition 190 * 191 * @return void 192 */ 193 public function testNewParentNames() 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\PatrilinealSurnameTradition 205 * 206 * @return void 207 */ 208 public function testNewHusbandNames() 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\PatrilinealSurnameTradition 220 * 221 * @return void 222 */ 223 public function testNewWifeNames() 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\PatrilinealSurnameTradition 235 * 236 * @return void 237 */ 238 public function testNewSpouseNames() 239 { 240 $this->assertSame( 241 ['NAME' => '//'], 242 $this->surname_tradition->newSpouseNames('Chris /Green/', 'U') 243 ); 244 } 245} 246