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