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 SpanishSurnameTradition 23 */ 24class SpanishSurnameTraditionTest 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 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(): void 49 { 50 $this->assertFalse($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(): void 61 { 62 $this->assertTrue($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(): void 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(): void 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(): void 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(): void 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(): void 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(): void 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(): void 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(): void 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(): void 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(): void 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(): void 251 { 252 $this->assertSame( 253 ['NAME' => '// //'], 254 $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U') 255 ); 256 } 257} 258