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\Census; 17 18use Mockery; 19 20/** 21 * Test harness for the class CensusColumnBornForeignParts 22 */ 23class CensusColumnBornForeignPartsTest extends \Fisharebest\Webtrees\TestCase 24{ 25 /** 26 * Delete mock objects 27 */ 28 public function tearDown() 29 { 30 Mockery::close(); 31 } 32 33 /** 34 * Get place mock. 35 * 36 * @param string $place Gedcom Place 37 * 38 * @return \Fisharebest\Webtrees\Place 39 */ 40 private function getPlaceMock($place): \Fisharebest\Webtrees\Place 41 { 42 $placeParts = explode(', ', $place); 43 44 $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place'); 45 $placeMock->shouldReceive('getGedcomName')->andReturn($place); 46 $placeMock->shouldReceive('lastPart')->andReturn(end($placeParts)); 47 48 return $placeMock; 49 } 50 51 /** 52 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 53 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 54 */ 55 public function testBornEnglandCensusEngland() 56 { 57 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 58 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 59 60 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 61 $census->shouldReceive('censusPlace')->andReturn('England'); 62 63 $column = new CensusColumnBornForeignParts($census, '', ''); 64 65 $this->assertSame('', $column->generate($individual, $individual)); 66 } 67 68 /** 69 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 70 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 71 */ 72 public function testBornWalesCensusEngland() 73 { 74 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 75 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales')); 76 77 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 78 $census->shouldReceive('censusPlace')->andReturn('England'); 79 80 $column = new CensusColumnBornForeignParts($census, '', ''); 81 82 $this->assertSame('', $column->generate($individual, $individual)); 83 } 84 85 /** 86 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 87 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 88 */ 89 public function testBornScotlandCensusEngland() 90 { 91 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 92 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland')); 93 94 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 95 $census->shouldReceive('censusPlace')->andReturn('England'); 96 97 $column = new CensusColumnBornForeignParts($census, '', ''); 98 99 $this->assertSame('S', $column->generate($individual, $individual)); 100 } 101 102 /** 103 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 104 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 105 */ 106 public function testBornIrelandCensusEngland() 107 { 108 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 109 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland')); 110 111 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 112 $census->shouldReceive('censusPlace')->andReturn('England'); 113 114 $column = new CensusColumnBornForeignParts($census, '', ''); 115 116 $this->assertSame('I', $column->generate($individual, $individual)); 117 } 118 119 /** 120 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 121 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 122 */ 123 public function testBornForeignCensusEngland() 124 { 125 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 126 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia')); 127 128 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 129 $census->shouldReceive('censusPlace')->andReturn('England'); 130 131 $column = new CensusColumnBornForeignParts($census, '', ''); 132 133 $this->assertSame('F', $column->generate($individual, $individual)); 134 } 135 136 /** 137 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 138 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 139 */ 140 public function testBornEnglandCensusIreland() 141 { 142 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 143 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 144 145 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 146 $census->shouldReceive('censusPlace')->andReturn('Ireland'); 147 148 $column = new CensusColumnBornForeignParts($census, '', ''); 149 150 $this->assertSame('E', $column->generate($individual, $individual)); 151 } 152 153 /** 154 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 155 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 156 */ 157 public function testBornWalesCensusIreland() 158 { 159 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 160 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales')); 161 162 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 163 $census->shouldReceive('censusPlace')->andReturn('Ireland'); 164 165 $column = new CensusColumnBornForeignParts($census, '', ''); 166 167 $this->assertSame('E', $column->generate($individual, $individual)); 168 } 169 170 /** 171 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 172 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 173 */ 174 public function testBornScotlandCensusIreland() 175 { 176 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 177 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland')); 178 179 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 180 $census->shouldReceive('censusPlace')->andReturn('Ireland'); 181 182 $column = new CensusColumnBornForeignParts($census, '', ''); 183 184 $this->assertSame('S', $column->generate($individual, $individual)); 185 } 186 187 /** 188 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 189 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 190 */ 191 public function testBornIrelandCensusIreland() 192 { 193 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 194 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland')); 195 196 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 197 $census->shouldReceive('censusPlace')->andReturn('Ireland'); 198 199 $column = new CensusColumnBornForeignParts($census, '', ''); 200 201 $this->assertSame('', $column->generate($individual, $individual)); 202 } 203 204 /** 205 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 206 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 207 */ 208 public function testBornForeignCensusIreland() 209 { 210 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 211 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia')); 212 213 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 214 $census->shouldReceive('censusPlace')->andReturn('Ireland'); 215 216 $column = new CensusColumnBornForeignParts($census, '', ''); 217 218 $this->assertSame('F', $column->generate($individual, $individual)); 219 } 220 221 /** 222 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 223 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 224 */ 225 public function testBornEnglandCensusScotland() 226 { 227 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 228 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 229 230 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 231 $census->shouldReceive('censusPlace')->andReturn('Scotland'); 232 233 $column = new CensusColumnBornForeignParts($census, '', ''); 234 235 $this->assertSame('E', $column->generate($individual, $individual)); 236 } 237 238 /** 239 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 240 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 241 */ 242 public function testBornWalesCensusScotland() 243 { 244 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 245 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales')); 246 247 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 248 $census->shouldReceive('censusPlace')->andReturn('Scotland'); 249 250 $column = new CensusColumnBornForeignParts($census, '', ''); 251 252 $this->assertSame('E', $column->generate($individual, $individual)); 253 } 254 255 /** 256 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 257 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 258 */ 259 public function testBornScotlandCensusScotland() 260 { 261 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 262 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland')); 263 264 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 265 $census->shouldReceive('censusPlace')->andReturn('Scotland'); 266 267 $column = new CensusColumnBornForeignParts($census, '', ''); 268 269 $this->assertSame('', $column->generate($individual, $individual)); 270 } 271 272 /** 273 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 274 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 275 */ 276 public function testBornIrelandCensusScotland() 277 { 278 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 279 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland')); 280 281 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 282 $census->shouldReceive('censusPlace')->andReturn('Scotland'); 283 284 $column = new CensusColumnBornForeignParts($census, '', ''); 285 286 $this->assertSame('I', $column->generate($individual, $individual)); 287 } 288 289 /** 290 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 291 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 292 */ 293 public function testBornForeignCensusScotland() 294 { 295 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 296 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia')); 297 298 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 299 $census->shouldReceive('censusPlace')->andReturn('Scotland'); 300 301 $column = new CensusColumnBornForeignParts($census, '', ''); 302 303 $this->assertSame('F', $column->generate($individual, $individual)); 304 } 305 306 /** 307 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 308 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 309 */ 310 public function testBornEnglandCensusWales() 311 { 312 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 313 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 314 315 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 316 $census->shouldReceive('censusPlace')->andReturn('Wales'); 317 318 $column = new CensusColumnBornForeignParts($census, '', ''); 319 320 $this->assertSame('', $column->generate($individual, $individual)); 321 } 322 323 /** 324 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 325 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 326 */ 327 public function testBornWalesCensusWales() 328 { 329 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 330 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales')); 331 332 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 333 $census->shouldReceive('censusPlace')->andReturn('Wales'); 334 335 $column = new CensusColumnBornForeignParts($census, '', ''); 336 337 $this->assertSame('', $column->generate($individual, $individual)); 338 } 339 340 /** 341 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 342 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 343 */ 344 public function testBornScotlandCensusWales() 345 { 346 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 347 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland')); 348 349 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 350 $census->shouldReceive('censusPlace')->andReturn('Wales'); 351 352 $column = new CensusColumnBornForeignParts($census, '', ''); 353 354 $this->assertSame('S', $column->generate($individual, $individual)); 355 } 356 357 /** 358 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 359 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 360 */ 361 public function testBornIrelandCensusWales() 362 { 363 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 364 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland')); 365 366 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 367 $census->shouldReceive('censusPlace')->andReturn('Wales'); 368 369 $column = new CensusColumnBornForeignParts($census, '', ''); 370 371 $this->assertSame('I', $column->generate($individual, $individual)); 372 } 373 374 /** 375 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 376 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 377 */ 378 public function testBornForeignCensusWales() 379 { 380 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 381 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia')); 382 383 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 384 $census->shouldReceive('censusPlace')->andReturn('Wales'); 385 386 $column = new CensusColumnBornForeignParts($census, '', ''); 387 388 $this->assertSame('F', $column->generate($individual, $individual)); 389 } 390 391 /** 392 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 393 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 394 */ 395 public function testBornNowhereCensusEngland() 396 { 397 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 398 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('')); 399 400 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 401 $census->shouldReceive('censusPlace')->andReturn('England'); 402 403 $column = new CensusColumnBornForeignParts($census, '', ''); 404 405 $this->assertSame('', $column->generate($individual, $individual)); 406 } 407 408 /** 409 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 410 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 411 */ 412 public function testBornNowhereCensusWales() 413 { 414 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 415 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('')); 416 417 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 418 $census->shouldReceive('censusPlace')->andReturn('Wales'); 419 420 $column = new CensusColumnBornForeignParts($census, '', ''); 421 422 $this->assertSame('', $column->generate($individual, $individual)); 423 } 424 425 /** 426 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts 427 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 428 */ 429 public function testBornNowhereCensusScotland() 430 { 431 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 432 $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('')); 433 434 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 435 $census->shouldReceive('censusPlace')->andReturn('Scotland'); 436 437 $column = new CensusColumnBornForeignParts($census, '', ''); 438 439 $this->assertSame('', $column->generate($individual, $individual)); 440 } 441} 442