xref: /webtrees/tests/app/Census/CensusColumnBirthPlaceSimpleTest.php (revision 8d68cabe4cf02d6d8507faf4f53889852be0b6aa)
1a4500ed5SGreg Roach<?php
2a4500ed5SGreg Roach
3a4500ed5SGreg Roach/**
4a4500ed5SGreg Roach * webtrees: online genealogy
56bdf7674SGreg Roach * Copyright (C) 2017 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 Mockery;
20a4500ed5SGreg Roach
21a4500ed5SGreg Roach/**
22a4500ed5SGreg Roach * Test harness for the class CensusColumnBirthPlaceSimple
23a4500ed5SGreg Roach */
24a4500ed5SGreg Roachclass CensusColumnBirthPlaceSimpleTest extends \PHPUnit_Framework_TestCase {
25a4500ed5SGreg Roach	/**
26a4500ed5SGreg Roach	 * Delete mock objects
27a4500ed5SGreg Roach	 */
28a4500ed5SGreg Roach	public function tearDown() {
29a4500ed5SGreg Roach		Mockery::close();
30a4500ed5SGreg Roach	}
31a4500ed5SGreg Roach
32a4500ed5SGreg Roach	/**
3316d0b7f7SRico Sonntag	 * Get place mock.
3416d0b7f7SRico Sonntag	 *
3516d0b7f7SRico Sonntag	 * @param string $place Gedcom Place
3616d0b7f7SRico Sonntag	 *
3716d0b7f7SRico Sonntag	 * @return \Fisharebest\Webtrees\Place
3816d0b7f7SRico Sonntag	 */
39*8d68cabeSGreg Roach	private function getPlaceMock($place) {
4016d0b7f7SRico Sonntag		$placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
4116d0b7f7SRico Sonntag		$placeMock->shouldReceive('getGedcomName')->andReturn($place);
4216d0b7f7SRico Sonntag
4316d0b7f7SRico Sonntag		return $placeMock;
4416d0b7f7SRico Sonntag	}
4516d0b7f7SRico Sonntag
4616d0b7f7SRico Sonntag	/**
4715d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
4815d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
49a4500ed5SGreg Roach	 */
50a4500ed5SGreg Roach	public function testForeignCountry() {
51c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
5216d0b7f7SRico Sonntag		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Westminster, London, England'));
53a4500ed5SGreg Roach
54c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
55a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
56a4500ed5SGreg Roach
57a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
58a4500ed5SGreg Roach
59a4500ed5SGreg Roach		$this->assertSame('England', $column->generate($individual));
60a4500ed5SGreg Roach	}
61a4500ed5SGreg Roach
62a4500ed5SGreg Roach	/**
6315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
6415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
65a4500ed5SGreg Roach	 */
66a4500ed5SGreg Roach	public function testJustCountry() {
67c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
6816d0b7f7SRico Sonntag		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('United States'));
69a4500ed5SGreg Roach
70c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
71a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
72a4500ed5SGreg Roach
73a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
74a4500ed5SGreg Roach
75a4500ed5SGreg Roach		$this->assertSame('', $column->generate($individual));
76a4500ed5SGreg Roach	}
77a4500ed5SGreg Roach
78a4500ed5SGreg Roach	/**
7915d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
8015d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
81a4500ed5SGreg Roach	 */
82a4500ed5SGreg Roach	public function testKnownState() {
83c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
8416d0b7f7SRico Sonntag		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Maryland, United States'));
85a4500ed5SGreg Roach
86c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
87a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
88a4500ed5SGreg Roach
89a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
90a4500ed5SGreg Roach
91a4500ed5SGreg Roach		$this->assertSame('Maryland', $column->generate($individual));
92a4500ed5SGreg Roach	}
93a4500ed5SGreg Roach
94a4500ed5SGreg Roach	/**
9515d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
9615d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
97a4500ed5SGreg Roach	 */
98a4500ed5SGreg Roach	public function testKnownStateAndTown() {
99c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10016d0b7f7SRico Sonntag		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Miami, Florida, United States'));
101a4500ed5SGreg Roach
102c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
103a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
104a4500ed5SGreg Roach
105a4500ed5SGreg Roach		$column = new CensusColumnBirthPlaceSimple($census, '', '');
106a4500ed5SGreg Roach
107a4500ed5SGreg Roach		$this->assertSame('Florida', $column->generate($individual));
108a4500ed5SGreg Roach	}
109a4500ed5SGreg Roach}
110