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\SpanishSurnameTradition; 21use Fisharebest\Webtrees\SurnameTradition\SurnameTraditionInterface; 22 23/** 24 * Test harness for the class SpanishSurnameTradition 25 */ 26class SpanishSurnameTraditionTest 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 SpanishSurnameTradition; 39 } 40 41 /** 42 * Test whether married surnames are used 43 * 44 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 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\SpanishSurnameTradition 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\SpanishSurnameTradition 69 * 70 * @return void 71 */ 72 public function testNewSonNames() 73 { 74 $this->assertSame( 75 [ 76 'NAME' => '/Garcia/ /Ruiz/', 77 'SURN' => 'Garcia,Ruiz', 78 ], 79 $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') 80 ); 81 } 82 83 /** 84 * Test new daughter names 85 * 86 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 87 * 88 * @return void 89 */ 90 public function testNewDaughterNames() 91 { 92 $this->assertSame( 93 [ 94 'NAME' => '/Garcia/ /Ruiz/', 95 'SURN' => 'Garcia,Ruiz', 96 ], 97 $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') 98 ); 99 } 100 101 /** 102 * Test new child names 103 * 104 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 105 * 106 * @return void 107 */ 108 public function testNewChildNames() 109 { 110 $this->assertSame( 111 [ 112 'NAME' => '/Garcia/ /Ruiz/', 113 'SURN' => 'Garcia,Ruiz', 114 ], 115 $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') 116 ); 117 } 118 119 /** 120 * Test new child names 121 * 122 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 123 * 124 * @return void 125 */ 126 public function testNewChildNamesWithNoParentsNames() 127 { 128 $this->assertSame( 129 [ 130 'NAME' => '// //', 131 'SURN' => '', 132 ], 133 $this->surname_tradition->newChildNames('', '', 'U') 134 ); 135 } 136 137 /** 138 * Test new child names 139 * 140 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 141 * 142 * @return void 143 */ 144 public function testNewChildNamesCompunds() 145 { 146 $this->assertSame( 147 [ 148 'NAME' => '/Garcia/ /Ruiz/', 149 'SURN' => 'Garcia,Ruiz', 150 ], 151 $this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M') 152 ); 153 $this->assertSame( 154 [ 155 'NAME' => '/Garcia/ /Ruiz/', 156 'SURN' => 'Garcia,Ruiz', 157 ], 158 $this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M') 159 ); 160 } 161 162 /** 163 * Test new father names 164 * 165 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 166 * 167 * @return void 168 */ 169 public function testNewFatherNames() 170 { 171 $this->assertSame( 172 [ 173 'NAME' => '/Garcia/ //', 174 'SURN' => 'Garcia', 175 ], 176 $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M') 177 ); 178 } 179 180 /** 181 * Test new mother names 182 * 183 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 184 * 185 * @return void 186 */ 187 public function testNewMotherNames() 188 { 189 $this->assertSame( 190 [ 191 'NAME' => '/Iglesias/ //', 192 'SURN' => 'Iglesias', 193 ], 194 $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F') 195 ); 196 } 197 198 /** 199 * Test new parent names 200 * 201 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 202 * 203 * @return void 204 */ 205 public function testNewParentNames() 206 { 207 $this->assertSame( 208 ['NAME' => '// //'], 209 $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U') 210 ); 211 } 212 213 /** 214 * Test new husband names 215 * 216 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 217 * 218 * @return void 219 */ 220 public function testNewHusbandNames() 221 { 222 $this->assertSame( 223 ['NAME' => '// //'], 224 $this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M') 225 ); 226 } 227 228 /** 229 * Test new wife names 230 * 231 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 232 * 233 * @return void 234 */ 235 public function testNewWifeNames() 236 { 237 $this->assertSame( 238 ['NAME' => '// //'], 239 $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'F') 240 ); 241 } 242 243 /** 244 * Test new spouse names 245 * 246 * @covers \Fisharebest\Webtrees\SurnameTradition\SpanishSurnameTradition 247 * 248 * @return void 249 */ 250 public function testNewSpouseNames() 251 { 252 $this->assertSame( 253 ['NAME' => '// //'], 254 $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U') 255 ); 256 } 257} 258