xref: /webtrees/tests/app/Census/CensusColumnMotherBirthPlaceSimpleTest.php (revision 16d0b7f74e80c16cb445079b0322702930031dc7)
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 CensusColumnMotherBirthPlaceSimple
23a4500ed5SGreg Roach */
24a4500ed5SGreg Roachclass CensusColumnMotherBirthPlaceSimpleTest 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	/**
33*16d0b7f7SRico Sonntag	 * Get place mock.
34*16d0b7f7SRico Sonntag	 *
35*16d0b7f7SRico Sonntag	 * @param string $place Gedcom Place
36*16d0b7f7SRico Sonntag	 *
37*16d0b7f7SRico Sonntag	 * @return \Fisharebest\Webtrees\Place
38*16d0b7f7SRico Sonntag	 */
39*16d0b7f7SRico Sonntag	private function getPlaceMock($place)
40*16d0b7f7SRico Sonntag	{
41*16d0b7f7SRico Sonntag		$placeParts = explode(', ', $place);
42*16d0b7f7SRico Sonntag
43*16d0b7f7SRico Sonntag		$placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
44*16d0b7f7SRico Sonntag		$placeMock->shouldReceive('getGedcomName')->andReturn($place);
45*16d0b7f7SRico Sonntag		$placeMock->shouldReceive('lastPart')->andReturn(end($placeParts));
46*16d0b7f7SRico Sonntag
47*16d0b7f7SRico Sonntag		return $placeMock;
48*16d0b7f7SRico Sonntag	}
49*16d0b7f7SRico Sonntag
50*16d0b7f7SRico Sonntag	/**
5115d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlaceSimple
5215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
53a4500ed5SGreg Roach	 */
54a4500ed5SGreg Roach	public function testKnownStateAndTown() {
55c314ecc9SGreg Roach		$father = Mockery::mock('Fisharebest\Webtrees\Individual');
56*16d0b7f7SRico Sonntag		$father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Miami, Florida, United States'));
57a4500ed5SGreg Roach
58c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
59a4500ed5SGreg Roach		$family->shouldReceive('getWife')->andReturn($father);
60a4500ed5SGreg Roach
61c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
62a4500ed5SGreg Roach		$individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
63a4500ed5SGreg Roach
64c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
65a4500ed5SGreg Roach		$census->shouldReceive('censusPlace')->andReturn('United States');
66a4500ed5SGreg Roach
67a4500ed5SGreg Roach		$column = new CensusColumnMotherBirthPlaceSimple($census, '', '');
68a4500ed5SGreg Roach
69a4500ed5SGreg Roach		$this->assertSame('Florida', $column->generate($individual));
70a4500ed5SGreg Roach	}
71a4500ed5SGreg Roach}
72