xref: /webtrees/tests/app/Census/CensusColumnBirthPlaceSimpleTest.php (revision c314ecc9a18e5e740a1c0fcb7379ef541f969dc5)
1a4500ed5SGreg Roach<?php
2a4500ed5SGreg Roach
3a4500ed5SGreg Roach/**
4a4500ed5SGreg Roach * webtrees: online genealogy
5a4500ed5SGreg Roach * Copyright (C) 2015 webtrees development team
6a4500ed5SGreg Roach * This program is free software: you can redistribute it and/or modify
7a4500ed5SGreg Roach * it under the terms of the GNU General Public License as published by
8a4500ed5SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a4500ed5SGreg Roach * (at your option) any later version.
10a4500ed5SGreg Roach * This program is distributed in the hope that it will be useful,
11a4500ed5SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a4500ed5SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a4500ed5SGreg Roach * GNU General Public License for more details.
14a4500ed5SGreg Roach * You should have received a copy of the GNU General Public License
15a4500ed5SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16a4500ed5SGreg Roach */
17a4500ed5SGreg Roachnamespace Fisharebest\Webtrees\Census;
18a4500ed5SGreg Roach
19a4500ed5SGreg Roachuse Fisharebest\Webtrees\Individual;
20a4500ed5SGreg Roachuse Mockery;
21a4500ed5SGreg Roach
22a4500ed5SGreg Roach/**
23a4500ed5SGreg Roach * Test harness for the class CensusColumnBirthPlaceSimple
24a4500ed5SGreg Roach */
25a4500ed5SGreg Roachclass CensusColumnBirthPlaceSimpleTest extends \PHPUnit_Framework_TestCase {
26a4500ed5SGreg Roach	/**
27a4500ed5SGreg Roach	 * Delete mock objects
28a4500ed5SGreg Roach	 */
29a4500ed5SGreg Roach	public function tearDown() {
30a4500ed5SGreg Roach		Mockery::close();
31a4500ed5SGreg Roach	}
32a4500ed5SGreg Roach
33a4500ed5SGreg Roach	/**
34a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
35a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
36a4500ed5SGreg Roach	 */
37a4500ed5SGreg Roach	public function testForeignCountry() {
38*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
39a4500ed5SGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('Westminster, London, England');
40a4500ed5SGreg Roach
41*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
42a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
43a4500ed5SGreg Roach
44a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
45a4500ed5SGreg Roach
46a4500ed5SGreg Roach		$this->assertSame('England', $column->generate($individual));
47a4500ed5SGreg Roach	}
48a4500ed5SGreg Roach
49a4500ed5SGreg Roach	/**
50a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
51a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
52a4500ed5SGreg Roach	 */
53a4500ed5SGreg Roach	public function testJustCountry() {
54*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
55a4500ed5SGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('United States');
56a4500ed5SGreg Roach
57*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
58a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
59a4500ed5SGreg Roach
60a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
61a4500ed5SGreg Roach
62a4500ed5SGreg Roach		$this->assertSame('', $column->generate($individual));
63a4500ed5SGreg Roach	}
64a4500ed5SGreg Roach
65a4500ed5SGreg Roach	/**
66a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
67a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
68a4500ed5SGreg Roach	 */
69a4500ed5SGreg Roach	public function testKnownState() {
70*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
71a4500ed5SGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('Maryland, United States');
72a4500ed5SGreg Roach
73*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
74a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
75a4500ed5SGreg Roach
76a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
77a4500ed5SGreg Roach
78a4500ed5SGreg Roach		$this->assertSame('Maryland', $column->generate($individual));
79a4500ed5SGreg Roach	}
80a4500ed5SGreg Roach
81a4500ed5SGreg Roach	/**
82a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
83a4500ed5SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
84a4500ed5SGreg Roach	 */
85a4500ed5SGreg Roach	public function testKnownStateAndTown() {
86*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
87a4500ed5SGreg Roach		$individual->shouldReceive('getBirthPlace')->andReturn('Miami, Florida, United States');
88a4500ed5SGreg Roach
89*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
90a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
91a4500ed5SGreg Roach
92a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
93a4500ed5SGreg Roach
94a4500ed5SGreg Roach		$this->assertSame('Florida', $column->generate($individual));
95a4500ed5SGreg Roach	}
96a4500ed5SGreg Roach}
97