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