xref: /webtrees/tests/app/Census/CensusColumnFatherForeignTest.php (revision 52348eb8c11b06a8488e13475e6561273832716a)
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
18*52348eb8SGreg 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
28*52348eb8SGreg Roach     *
29*52348eb8SGreg 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     *
41*52348eb8SGreg Roach     * @return Place
4216d0b7f7SRico Sonntag     */
43*52348eb8SGreg 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
54a53db70dSGreg Roach     */
55c1010edaSGreg Roach    public function testSameCountry()
56c1010edaSGreg Roach    {
57c314ecc9SGreg Roach        $father = Mockery::mock('Fisharebest\Webtrees\Individual');
5816d0b7f7SRico Sonntag        $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
59a53db70dSGreg Roach
60c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
61a53db70dSGreg Roach        $family->shouldReceive('getHusband')->andReturn($father);
62a53db70dSGreg Roach
63c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
64a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
65a53db70dSGreg Roach
66c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
67a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
68a53db70dSGreg Roach
69a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
70a53db70dSGreg Roach
71342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
72a53db70dSGreg Roach    }
73a53db70dSGreg Roach
74a53db70dSGreg Roach    /**
7515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
7615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
77a53db70dSGreg Roach     */
78c1010edaSGreg Roach    public function testDifferentCountry()
79c1010edaSGreg Roach    {
80c314ecc9SGreg Roach        $father = Mockery::mock('Fisharebest\Webtrees\Individual');
8116d0b7f7SRico Sonntag        $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
82a53db70dSGreg Roach
83c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
84a53db70dSGreg Roach        $family->shouldReceive('getHusband')->andReturn($father);
85a53db70dSGreg Roach
86c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
87a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
88a53db70dSGreg Roach
89c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
90a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('Ireland');
91a53db70dSGreg Roach
92a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
93a53db70dSGreg Roach
94342dcecdSGreg Roach        $this->assertSame('Y', $column->generate($individual, $individual));
95a53db70dSGreg Roach    }
96a53db70dSGreg Roach
97a53db70dSGreg Roach    /**
9815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
9915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
100a53db70dSGreg Roach     */
101c1010edaSGreg Roach    public function testPlaceNoParent()
102c1010edaSGreg Roach    {
103c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
104a53db70dSGreg Roach        $family->shouldReceive('getHusband')->andReturn(null);
105a53db70dSGreg Roach
106c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
107a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
108a53db70dSGreg Roach
109c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
110a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
111a53db70dSGreg Roach
112a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
113a53db70dSGreg Roach
114342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
115a53db70dSGreg Roach    }
116a53db70dSGreg Roach
117a53db70dSGreg Roach    /**
11815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
11915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
120a53db70dSGreg Roach     */
121c1010edaSGreg Roach    public function testPlaceNoParentFamily()
122c1010edaSGreg Roach    {
123c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
124a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null);
125a53db70dSGreg Roach
126c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
127a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
128a53db70dSGreg Roach
129a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
130a53db70dSGreg Roach
131342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
132a53db70dSGreg Roach    }
133a53db70dSGreg Roach}
134