1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2021 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 <https://www.gnu.org/licenses/>. 16 */ 17 18declare(strict_types=1); 19 20namespace Fisharebest\Webtrees\SurnameTradition; 21 22use Fisharebest\Webtrees\TestCase; 23 24/** 25 * Test harness for the class PortugueseSurnameTradition 26 */ 27class PortugueseSurnameTraditionTest extends TestCase 28{ 29 private SurnameTraditionInterface $surname_tradition; 30 31 /** 32 * Prepare the environment for these tests 33 * 34 * @return void 35 */ 36 protected function setUp(): void 37 { 38 parent::setUp(); 39 40 $this->surname_tradition = new PortugueseSurnameTradition(); 41 } 42 43 /** 44 * Test whether married surnames are used 45 * 46 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 47 * 48 * @return void 49 */ 50 public function testMarriedSurnames(): void 51 { 52 self::assertFalse($this->surname_tradition->hasMarriedNames()); 53 } 54 55 /** 56 * Test whether surnames are used 57 * 58 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 59 * 60 * @return void 61 */ 62 public function testSurnames(): void 63 { 64 self::assertTrue($this->surname_tradition->hasSurnames()); 65 } 66 67 /** 68 * Test new son names 69 * 70 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 71 * 72 * @return void 73 */ 74 public function testNewSonNames(): void 75 { 76 self::assertSame( 77 [ 78 'NAME' => '/Iglesias/ /Lorca/', 79 'SURN' => 'Iglesias,Lorca', 80 ], 81 $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') 82 ); 83 } 84 85 /** 86 * Test new daughter names 87 * 88 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 89 * 90 * @return void 91 */ 92 public function testNewDaughterNames(): void 93 { 94 self::assertSame( 95 [ 96 'NAME' => '/Iglesias/ /Lorca/', 97 'SURN' => 'Iglesias,Lorca', 98 ], 99 $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') 100 ); 101 } 102 103 /** 104 * Test new child names 105 * 106 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 107 * 108 * @return void 109 */ 110 public function testNewChildNames(): void 111 { 112 self::assertSame( 113 [ 114 'NAME' => '/Iglesias/ /Lorca/', 115 'SURN' => 'Iglesias,Lorca', 116 ], 117 $this->surname_tradition->newChildNames('Gabriel /Garcia/ /Iglesias/', 'Maria /Ruiz/ /Lorca/', 'M') 118 ); 119 } 120 121 /** 122 * Test new child names 123 * 124 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 125 * 126 * @return void 127 */ 128 public function testNewChildNamesWithNoParentsNames(): void 129 { 130 self::assertSame( 131 [ 132 'NAME' => '// //', 133 'SURN' => '', 134 ], 135 $this->surname_tradition->newChildNames('', '', 'U') 136 ); 137 } 138 139 /** 140 * Test new child names 141 * 142 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 143 * 144 * @return void 145 */ 146 public function testNewChildNamesCompunds(): void 147 { 148 self::assertSame( 149 [ 150 'NAME' => '/Iglesias/ /Lorca/', 151 'SURN' => 'Iglesias,Lorca', 152 ], 153 $this->surname_tradition->newChildNames('Gabriel /Garcia Iglesias/', 'Maria /Ruiz Lorca/', 'M') 154 ); 155 self::assertSame( 156 [ 157 'NAME' => '/Iglesias/ /Lorca/', 158 'SURN' => 'Iglesias,Lorca', 159 ], 160 $this->surname_tradition->newChildNames('Gabriel /Garcia y Iglesias/', 'Maria /Ruiz y Lorca/', 'M') 161 ); 162 } 163 164 /** 165 * Test new father names 166 * 167 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 168 * 169 * @return void 170 */ 171 public function testNewFatherNames(): void 172 { 173 self::assertSame( 174 [ 175 'NAME' => '// /Garcia/', 176 'SURN' => 'Garcia', 177 ], 178 $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'M') 179 ); 180 } 181 182 /** 183 * Test new mother names 184 * 185 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 186 * 187 * @return void 188 */ 189 public function testNewMotherNames(): void 190 { 191 self::assertSame( 192 [ 193 'NAME' => '// /Iglesias/', 194 'SURN' => 'Iglesias', 195 ], 196 $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'F') 197 ); 198 } 199 200 /** 201 * Test new parent names 202 * 203 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 204 * 205 * @return void 206 */ 207 public function testNewParentNames(): void 208 { 209 self::assertSame( 210 ['NAME' => '// //'], 211 $this->surname_tradition->newParentNames('Gabriel /Garcia/ /Iglesias/', 'U') 212 ); 213 } 214 215 /** 216 * Test new husband names 217 * 218 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 219 * 220 * @return void 221 */ 222 public function testNewHusbandNames(): void 223 { 224 self::assertSame( 225 ['NAME' => '// //'], 226 $this->surname_tradition->newSpouseNames('Maria /Ruiz/ /Lorca/', 'M') 227 ); 228 } 229 230 /** 231 * Test new wife names 232 * 233 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 234 * 235 * @return void 236 */ 237 public function testNewWifeNames(): void 238 { 239 self::assertSame( 240 ['NAME' => '// //'], 241 $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'F') 242 ); 243 } 244 245 /** 246 * Test new spouse names 247 * 248 * @covers \Fisharebest\Webtrees\SurnameTradition\PortugueseSurnameTradition 249 * 250 * @return void 251 */ 252 public function testNewSpouseNames(): void 253 { 254 self::assertSame( 255 ['NAME' => '// //'], 256 $this->surname_tradition->newSpouseNames('Gabriel /Garcia/ /Iglesias/', 'U') 257 ); 258 } 259} 260