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