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