xref: /webtrees/tests/app/Census/CensusColumnFatherForeignTest.php (revision 3976b4703df669696105ed6b024b96d433c8fbdb)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 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 */
17declare(strict_types=1);
18
19namespace Fisharebest\Webtrees\Census;
20
21use Fisharebest\Webtrees\Family;
22use Fisharebest\Webtrees\Individual;
23use Fisharebest\Webtrees\Place;
24
25/**
26 * Test harness for the class CensusColumnFatherForeign
27 */
28class CensusColumnFatherForeignTest extends \Fisharebest\Webtrees\TestCase
29{
30    /**
31     * Get place mock.
32     *
33     * @param string $place Gedcom Place
34     *
35     * @return Place
36     */
37    private function getPlaceMock($place): Place
38    {
39        $placeMock = $this->createMock(Place::class);
40        $placeMock->method('gedcomName')->willReturn($place);
41
42        return $placeMock;
43    }
44
45    /**
46     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
47     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
48     *
49     * @return void
50     */
51    public function testSameCountry(): void
52    {
53        $father = $this->createMock(Individual::class);
54        $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
55
56        $family = $this->createMock(Family::class);
57        $family->method('husband')->willReturn($father);
58
59        $individual = $this->createMock(Individual::class);
60        $individual->method('primaryChildFamily')->willReturn($family);
61
62        $census = $this->createMock(CensusInterface::class);
63        $census->method('censusPlace')->willReturn('England');
64
65        $column = new CensusColumnFatherForeign($census, '', '');
66
67        $this->assertSame('', $column->generate($individual, $individual));
68    }
69
70    /**
71     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
72     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
73     *
74     * @return void
75     */
76    public function testDifferentCountry(): void
77    {
78        $father = $this->createMock(Individual::class);
79        $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
80
81        $family = $this->createMock(Family::class);
82        $family->method('husband')->willReturn($father);
83
84        $individual = $this->createMock(Individual::class);
85        $individual->method('primaryChildFamily')->willReturn($family);
86
87        $census = $this->createMock(CensusInterface::class);
88        $census->method('censusPlace')->willReturn('Ireland');
89
90        $column = new CensusColumnFatherForeign($census, '', '');
91
92        $this->assertSame('Y', $column->generate($individual, $individual));
93    }
94
95    /**
96     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
97     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
98     *
99     * @return void
100     */
101    public function testPlaceNoParent(): void
102    {
103        $family = $this->createMock(Family::class);
104        $family->method('husband')->willReturn(null);
105
106        $individual = $this->createMock(Individual::class);
107        $individual->method('primaryChildFamily')->willReturn($family);
108
109        $census = $this->createMock(CensusInterface::class);
110        $census->method('censusPlace')->willReturn('England');
111
112        $column = new CensusColumnFatherForeign($census, '', '');
113
114        $this->assertSame('', $column->generate($individual, $individual));
115    }
116
117    /**
118     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
119     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
120     *
121     * @return void
122     */
123    public function testPlaceNoParentFamily(): void
124    {
125        $individual = $this->createMock(Individual::class);
126        $individual->method('primaryChildFamily')->willReturn(null);
127
128        $census = $this->createMock(CensusInterface::class);
129        $census->method('censusPlace')->willReturn('England');
130
131        $column = new CensusColumnFatherForeign($census, '', '');
132
133        $this->assertSame('', $column->generate($individual, $individual));
134    }
135}
136