xref: /webtrees/tests/app/Census/CensusColumnNationalityTest.php (revision c314ecc9a18e5e740a1c0fcb7379ef541f969dc5)
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() {
41*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
427338314fSGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('Australia');
43e2052359SGreg Roach		$individual->shouldReceive('getFacts')->andReturn(array());
447338314fSGreg Roach
45*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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() {
58*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
597338314fSGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
60e2052359SGreg Roach		$individual->shouldReceive('getFacts')->andReturn(array());
617338314fSGreg Roach
62*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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() {
75*c314ecc9SGreg Roach		$place1 = Mockery::mock('Fisharebest\Webtrees\Place');
767338314fSGreg Roach		$place1->shouldReceive('getGedcomName')->andReturn('United States');
777338314fSGreg Roach
78*c314ecc9SGreg Roach		$fact1 = Mockery::mock('Fisharebest\Webtrees\Fact');
797338314fSGreg Roach		$fact1->shouldReceive('getPlace')->andReturn($place1);
807338314fSGreg Roach		$fact1->shouldReceive('getDate')->andReturn(new Date('1855'));
817338314fSGreg Roach
82*c314ecc9SGreg Roach		$place2 = Mockery::mock('Fisharebest\Webtrees\Place');
837338314fSGreg Roach		$place2->shouldReceive('getGedcomName')->andReturn('Australia');
847338314fSGreg Roach
85*c314ecc9SGreg Roach		$fact2 = Mockery::mock('Fisharebest\Webtrees\Fact');
867338314fSGreg Roach		$fact2->shouldReceive('getPlace')->andReturn($place2);
877338314fSGreg Roach		$fact2->shouldReceive('getDate')->andReturn(new Date('1865'));
887338314fSGreg Roach
89*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
907338314fSGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
91e2052359SGreg Roach		$individual->shouldReceive('getFacts')->andReturn(array($fact1, $fact2));
927338314fSGreg Roach
93*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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