xref: /webtrees/tests/app/Census/CensusColumnFatherForeignTest.php (revision 18d7a90d8a3b33b218801c0b68eb1a5140d7b4e7)
1a53db70dSGreg Roach<?php
2a53db70dSGreg Roach/**
3a53db70dSGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
5a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify
6a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by
7a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or
8a53db70dSGreg Roach * (at your option) any later version.
9a53db70dSGreg Roach * This program is distributed in the hope that it will be useful,
10a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12a53db70dSGreg Roach * GNU General Public License for more details.
13a53db70dSGreg Roach * You should have received a copy of the GNU General Public License
14a53db70dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15a53db70dSGreg Roach */
16a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census;
17a53db70dSGreg Roach
1852348eb8SGreg Roachuse Fisharebest\Webtrees\Place;
19a53db70dSGreg Roachuse Mockery;
20a53db70dSGreg Roach
21a53db70dSGreg Roach/**
22a53db70dSGreg Roach * Test harness for the class CensusColumnFatherForeign
23a53db70dSGreg Roach */
2484e2cf4eSGreg Roachclass CensusColumnFatherForeignTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
26a53db70dSGreg Roach    /**
27a53db70dSGreg Roach     * Delete mock objects
2852348eb8SGreg Roach     *
2952348eb8SGreg Roach     * @return void
30a53db70dSGreg Roach     */
31c1010edaSGreg Roach    public function tearDown()
32c1010edaSGreg Roach    {
33a53db70dSGreg Roach        Mockery::close();
34a53db70dSGreg Roach    }
35a53db70dSGreg Roach
36a53db70dSGreg Roach    /**
3716d0b7f7SRico Sonntag     * Get place mock.
3816d0b7f7SRico Sonntag     *
3916d0b7f7SRico Sonntag     * @param string $place Gedcom Place
4016d0b7f7SRico Sonntag     *
4152348eb8SGreg Roach     * @return Place
4216d0b7f7SRico Sonntag     */
4352348eb8SGreg Roach    private function getPlaceMock($place): Place
44c1010edaSGreg Roach    {
4516d0b7f7SRico Sonntag        $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
4616d0b7f7SRico Sonntag        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
4716d0b7f7SRico Sonntag
4816d0b7f7SRico Sonntag        return $placeMock;
4916d0b7f7SRico Sonntag    }
5016d0b7f7SRico Sonntag
5116d0b7f7SRico Sonntag    /**
5215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
5315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
54*18d7a90dSGreg Roach     *
55*18d7a90dSGreg Roach     * @return void
56a53db70dSGreg Roach     */
57c1010edaSGreg Roach    public function testSameCountry()
58c1010edaSGreg Roach    {
59c314ecc9SGreg Roach        $father = Mockery::mock('Fisharebest\Webtrees\Individual');
6016d0b7f7SRico Sonntag        $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
61a53db70dSGreg Roach
62c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
63a53db70dSGreg Roach        $family->shouldReceive('getHusband')->andReturn($father);
64a53db70dSGreg Roach
65c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
66a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
67a53db70dSGreg Roach
68c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
69a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
70a53db70dSGreg Roach
71a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
72a53db70dSGreg Roach
73342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
74a53db70dSGreg Roach    }
75a53db70dSGreg Roach
76a53db70dSGreg Roach    /**
7715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
7815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
79*18d7a90dSGreg Roach     *
80*18d7a90dSGreg Roach     * @return void
81a53db70dSGreg Roach     */
82c1010edaSGreg Roach    public function testDifferentCountry()
83c1010edaSGreg Roach    {
84c314ecc9SGreg Roach        $father = Mockery::mock('Fisharebest\Webtrees\Individual');
8516d0b7f7SRico Sonntag        $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
86a53db70dSGreg Roach
87c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
88a53db70dSGreg Roach        $family->shouldReceive('getHusband')->andReturn($father);
89a53db70dSGreg Roach
90c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
91a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
92a53db70dSGreg Roach
93c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
94a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('Ireland');
95a53db70dSGreg Roach
96a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
97a53db70dSGreg Roach
98342dcecdSGreg Roach        $this->assertSame('Y', $column->generate($individual, $individual));
99a53db70dSGreg Roach    }
100a53db70dSGreg Roach
101a53db70dSGreg Roach    /**
10215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
10315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
104*18d7a90dSGreg Roach     *
105*18d7a90dSGreg Roach     * @return void
106a53db70dSGreg Roach     */
107c1010edaSGreg Roach    public function testPlaceNoParent()
108c1010edaSGreg Roach    {
109c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
110a53db70dSGreg Roach        $family->shouldReceive('getHusband')->andReturn(null);
111a53db70dSGreg Roach
112c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
113a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
114a53db70dSGreg Roach
115c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
116a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
117a53db70dSGreg Roach
118a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
119a53db70dSGreg Roach
120342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
121a53db70dSGreg Roach    }
122a53db70dSGreg Roach
123a53db70dSGreg Roach    /**
12415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
12515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
126*18d7a90dSGreg Roach     *
127*18d7a90dSGreg Roach     * @return void
128a53db70dSGreg Roach     */
129c1010edaSGreg Roach    public function testPlaceNoParentFamily()
130c1010edaSGreg Roach    {
131c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
132a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null);
133a53db70dSGreg Roach
134c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
135a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
136a53db70dSGreg Roach
137a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
138a53db70dSGreg Roach
139342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
140a53db70dSGreg Roach    }
141a53db70dSGreg Roach}
142