xref: /webtrees/tests/app/Census/CensusColumnNationalityTest.php (revision 13abd6f3a37322f885d85df150e105d27ad81f8d)
17338314fSGreg Roach<?php
27338314fSGreg Roach
37338314fSGreg Roach/**
47338314fSGreg Roach * webtrees: online genealogy
5369c0ce6SGreg Roach * Copyright (C) 2016 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 Mockery;
217338314fSGreg Roach
227338314fSGreg Roach/**
237338314fSGreg Roach * Test harness for the class CensusColumnNationality
247338314fSGreg Roach */
257338314fSGreg Roachclass CensusColumnNationalityTest extends \PHPUnit_Framework_TestCase {
267338314fSGreg Roach	/**
277338314fSGreg Roach	 * Delete mock objects
287338314fSGreg Roach	 */
297338314fSGreg Roach	public function tearDown() {
307338314fSGreg Roach		Mockery::close();
317338314fSGreg Roach	}
327338314fSGreg Roach
337338314fSGreg Roach	/**
347338314fSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnNationality
357338314fSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
367338314fSGreg Roach	 */
3752f14e58SGreg Roach	public function testNoBirthPlace() {
3852f14e58SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
3952f14e58SGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('');
40*13abd6f3SGreg Roach		$individual->shouldReceive('getFacts')->andReturn([]);
4152f14e58SGreg Roach
4252f14e58SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
4352f14e58SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('Deutschland');
4452f14e58SGreg Roach
4552f14e58SGreg Roach		$column = new CensusColumnNationality($census, '', '');
4652f14e58SGreg Roach
4752f14e58SGreg Roach		$this->assertSame('Deutsch', $column->generate($individual));
4852f14e58SGreg Roach	}
4952f14e58SGreg Roach
5052f14e58SGreg Roach	/**
5152f14e58SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnNationality
5252f14e58SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
5352f14e58SGreg Roach	 */
547338314fSGreg Roach	public function testPlaceCountry() {
55c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
567338314fSGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('Australia');
57*13abd6f3SGreg Roach		$individual->shouldReceive('getFacts')->andReturn([]);
587338314fSGreg Roach
59c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
607338314fSGreg Roach		$census->shouldReceive('censusPlace')->andReturn('England');
617338314fSGreg Roach
627338314fSGreg Roach		$column = new CensusColumnNationality($census, '', '');
637338314fSGreg Roach
647338314fSGreg Roach		$this->assertSame('Australia', $column->generate($individual));
657338314fSGreg Roach	}
667338314fSGreg Roach
677338314fSGreg Roach	/**
687338314fSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnNationality
697338314fSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
707338314fSGreg Roach	 */
717338314fSGreg Roach	public function testBritish() {
72c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
737338314fSGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
74*13abd6f3SGreg Roach		$individual->shouldReceive('getFacts')->andReturn([]);
757338314fSGreg Roach
76c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
777338314fSGreg Roach		$census->shouldReceive('censusPlace')->andReturn('England');
787338314fSGreg Roach
797338314fSGreg Roach		$column = new CensusColumnNationality($census, '', '');
807338314fSGreg Roach
817338314fSGreg Roach		$this->assertSame('British', $column->generate($individual));
827338314fSGreg Roach	}
837338314fSGreg Roach
847338314fSGreg Roach	/**
857338314fSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnNationality
867338314fSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
877338314fSGreg Roach	 */
887338314fSGreg Roach	public function testEmigrated() {
89c314ecc9SGreg Roach		$place1 = Mockery::mock('Fisharebest\Webtrees\Place');
907338314fSGreg Roach		$place1->shouldReceive('getGedcomName')->andReturn('United States');
917338314fSGreg Roach
92c314ecc9SGreg Roach		$fact1 = Mockery::mock('Fisharebest\Webtrees\Fact');
937338314fSGreg Roach		$fact1->shouldReceive('getPlace')->andReturn($place1);
947338314fSGreg Roach		$fact1->shouldReceive('getDate')->andReturn(new Date('1855'));
957338314fSGreg Roach
96c314ecc9SGreg Roach		$place2 = Mockery::mock('Fisharebest\Webtrees\Place');
977338314fSGreg Roach		$place2->shouldReceive('getGedcomName')->andReturn('Australia');
987338314fSGreg Roach
99c314ecc9SGreg Roach		$fact2 = Mockery::mock('Fisharebest\Webtrees\Fact');
1007338314fSGreg Roach		$fact2->shouldReceive('getPlace')->andReturn($place2);
1017338314fSGreg Roach		$fact2->shouldReceive('getDate')->andReturn(new Date('1865'));
1027338314fSGreg Roach
103c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
1047338314fSGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
105*13abd6f3SGreg Roach		$individual->shouldReceive('getFacts')->andReturn([
10652f14e58SGreg Roach			$fact1,
10752f14e58SGreg Roach			$fact2,
108*13abd6f3SGreg Roach		]);
1097338314fSGreg Roach
110c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1117338314fSGreg Roach		$census->shouldReceive('censusPlace')->andReturn('England');
1127338314fSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1137338314fSGreg Roach
1147338314fSGreg Roach		$column = new CensusColumnNationality($census, '', '');
1157338314fSGreg Roach
1167338314fSGreg Roach		$this->assertSame('United States', $column->generate($individual));
1177338314fSGreg Roach	}
1187338314fSGreg Roach}
119