17338314fSGreg Roach<?php 27338314fSGreg Roach 37338314fSGreg Roach/** 47338314fSGreg Roach * webtrees: online genealogy 57338314fSGreg Roach * Copyright (C) 2015 webtrees development team 67338314fSGreg Roach * This program is free software: you can redistribute it and/or modify 77338314fSGreg Roach * it under the terms of the GNU General Public License as published by 87338314fSGreg Roach * the Free Software Foundation, either version 3 of the License, or 97338314fSGreg Roach * (at your option) any later version. 107338314fSGreg Roach * This program is distributed in the hope that it will be useful, 117338314fSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 127338314fSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 137338314fSGreg Roach * GNU General Public License for more details. 147338314fSGreg Roach * You should have received a copy of the GNU General Public License 157338314fSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 167338314fSGreg Roach */ 177338314fSGreg Roachnamespace Fisharebest\Webtrees\Census; 187338314fSGreg Roach 197338314fSGreg Roachuse Fisharebest\Webtrees\Date; 207338314fSGreg Roachuse Fisharebest\Webtrees\Fact; 217338314fSGreg Roachuse Fisharebest\Webtrees\Individual; 227338314fSGreg Roachuse Fisharebest\Webtrees\Place; 237338314fSGreg Roachuse Mockery; 247338314fSGreg Roach 257338314fSGreg Roach/** 267338314fSGreg Roach * Test harness for the class CensusColumnNationality 277338314fSGreg Roach */ 287338314fSGreg Roachclass CensusColumnNationalityTest extends \PHPUnit_Framework_TestCase { 297338314fSGreg Roach /** 307338314fSGreg Roach * Delete mock objects 317338314fSGreg Roach */ 327338314fSGreg Roach public function tearDown() { 337338314fSGreg Roach Mockery::close(); 347338314fSGreg Roach } 357338314fSGreg Roach 367338314fSGreg Roach /** 377338314fSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnNationality 387338314fSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 397338314fSGreg Roach */ 407338314fSGreg Roach public function testPlaceCountry() { 417338314fSGreg Roach $individual = Mockery::mock(Individual::class); 427338314fSGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('Australia'); 43*e2052359SGreg Roach $individual->shouldReceive('getFacts')->andReturn(array()); 447338314fSGreg Roach 457338314fSGreg Roach $census = Mockery::mock(CensusInterface::class); 467338314fSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 477338314fSGreg Roach 487338314fSGreg Roach $column = new CensusColumnNationality($census, '', ''); 497338314fSGreg Roach 507338314fSGreg Roach $this->assertSame('Australia', $column->generate($individual)); 517338314fSGreg Roach } 527338314fSGreg Roach 537338314fSGreg Roach /** 547338314fSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnNationality 557338314fSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 567338314fSGreg Roach */ 577338314fSGreg Roach public function testBritish() { 587338314fSGreg Roach $individual = Mockery::mock(Individual::class); 597338314fSGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('London, England'); 60*e2052359SGreg Roach $individual->shouldReceive('getFacts')->andReturn(array()); 617338314fSGreg Roach 627338314fSGreg Roach $census = Mockery::mock(CensusInterface::class); 637338314fSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 647338314fSGreg Roach 657338314fSGreg Roach $column = new CensusColumnNationality($census, '', ''); 667338314fSGreg Roach 677338314fSGreg Roach $this->assertSame('British', $column->generate($individual)); 687338314fSGreg Roach } 697338314fSGreg Roach 707338314fSGreg Roach /** 717338314fSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnNationality 727338314fSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 737338314fSGreg Roach */ 747338314fSGreg Roach public function testEmigrated() { 757338314fSGreg Roach $place1 = Mockery::mock(Place::class); 767338314fSGreg Roach $place1->shouldReceive('getGedcomName')->andReturn('United States'); 777338314fSGreg Roach 787338314fSGreg Roach $fact1 = Mockery::mock(Fact::class); 797338314fSGreg Roach $fact1->shouldReceive('getPlace')->andReturn($place1); 807338314fSGreg Roach $fact1->shouldReceive('getDate')->andReturn(new Date('1855')); 817338314fSGreg Roach 827338314fSGreg Roach $place2 = Mockery::mock(Place::class); 837338314fSGreg Roach $place2->shouldReceive('getGedcomName')->andReturn('Australia'); 847338314fSGreg Roach 857338314fSGreg Roach $fact2 = Mockery::mock(Fact::class); 867338314fSGreg Roach $fact2->shouldReceive('getPlace')->andReturn($place2); 877338314fSGreg Roach $fact2->shouldReceive('getDate')->andReturn(new Date('1865')); 887338314fSGreg Roach 897338314fSGreg Roach $individual = Mockery::mock(Individual::class); 907338314fSGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('London, England'); 91*e2052359SGreg Roach $individual->shouldReceive('getFacts')->andReturn(array($fact1, $fact2)); 927338314fSGreg Roach 937338314fSGreg Roach $census = Mockery::mock(CensusInterface::class); 947338314fSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 957338314fSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 967338314fSGreg Roach 977338314fSGreg Roach $column = new CensusColumnNationality($census, '', ''); 987338314fSGreg Roach 997338314fSGreg Roach $this->assertSame('United States', $column->generate($individual)); 1007338314fSGreg Roach } 1017338314fSGreg Roach} 102