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