xref: /webtrees/tests/app/Census/CensusColumnFatherForeignTest.php (revision a53db70de9092a80529e77db445001f1acf43696)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2015 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 */
17
18namespace Fisharebest\Webtrees\Census;
19
20use Fisharebest\Webtrees\Date;
21use Fisharebest\Webtrees\Family;
22use Fisharebest\Webtrees\Individual;
23use Mockery;
24
25/**
26 * Test harness for the class CensusColumnFatherForeign
27 */
28class CensusColumnFatherForeignTest extends \PHPUnit_Framework_TestCase {
29	/**
30	 * Delete mock objects
31	 */
32	public function tearDown() {
33		Mockery::close();
34	}
35
36	/**
37	 * @covers Fisharebest\Webtrees\Census\CensusColumnFatherForeign
38	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
39	 */
40	public function testSameCountry() {
41		$father = Mockery::mock(Individual::class);
42		$father->shouldReceive('getBirthPlace')->andReturn('London, England');
43
44		$family = Mockery::mock(Family::class);
45		$family->shouldReceive('getHusband')->andReturn($father);
46
47		$individual = Mockery::mock(Individual::class);
48		$individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
49
50		$census = Mockery::mock(CensusInterface::class);
51		$census->shouldReceive('censusPlace')->andReturn('England');
52
53		$column = new CensusColumnFatherForeign($census, '', '');
54
55		$this->assertSame('', $column->generate($individual));
56	}
57
58	/**
59	 * @covers Fisharebest\Webtrees\Census\CensusColumnFatherForeign
60	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
61	 */
62	public function testDifferentCountry() {
63		$father = Mockery::mock(Individual::class);
64		$father->shouldReceive('getBirthPlace')->andReturn('London, England');
65
66		$family = Mockery::mock(Family::class);
67		$family->shouldReceive('getHusband')->andReturn($father);
68
69		$individual = Mockery::mock(Individual::class);
70		$individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
71
72		$census = Mockery::mock(CensusInterface::class);
73		$census->shouldReceive('censusPlace')->andReturn('Ireland');
74
75		$column = new CensusColumnFatherForeign($census, '', '');
76
77		$this->assertSame('Y', $column->generate($individual));
78	}
79
80	/**
81	 * @covers Fisharebest\Webtrees\Census\CensusColumnFatherForeign
82	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
83	 */
84	public function testPlaceNoParent() {
85		$family = Mockery::mock(Family::class);
86		$family->shouldReceive('getHusband')->andReturn(null);
87
88		$individual = Mockery::mock(Individual::class);
89		$individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
90
91		$census = Mockery::mock(CensusInterface::class);
92		$census->shouldReceive('censusPlace')->andReturn('England');
93
94		$column = new CensusColumnFatherForeign($census, '', '');
95
96		$this->assertSame('', $column->generate($individual));
97	}
98
99	/**
100	 * @covers Fisharebest\Webtrees\Census\CensusColumnFatherForeign
101	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
102	 */
103	public function testPlaceNoParentFamily() {
104		$individual = Mockery::mock(Individual::class);
105		$individual->shouldReceive('getPrimaryChildFamily')->andReturn(null);
106
107		$census = Mockery::mock(CensusInterface::class);
108		$census->shouldReceive('censusPlace')->andReturn('England');
109
110		$column = new CensusColumnFatherForeign($census, '', '');
111
112		$this->assertSame('', $column->generate($individual));
113	}
114}
115