xref: /webtrees/tests/app/Census/CensusColumnFatherForeignTest.php (revision db3aeb3eb846bb233f34557aedb1559aadf9275a)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Census;
19
20use Fisharebest\Webtrees\Family;
21use Fisharebest\Webtrees\Individual;
22use Fisharebest\Webtrees\Place;
23
24/**
25 * Test harness for the class CensusColumnFatherForeign
26 */
27class CensusColumnFatherForeignTest extends \Fisharebest\Webtrees\TestCase
28{
29    /**
30     * Get place mock.
31     *
32     * @param string $place Gedcom Place
33     *
34     * @return Place
35     */
36    private function getPlaceMock($place): Place
37    {
38        $placeMock = $this->createMock(Place::class);
39        $placeMock->method('gedcomName')->willReturn($place);
40
41        return $placeMock;
42    }
43
44    /**
45     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
46     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
47     *
48     * @return void
49     */
50    public function testSameCountry(): void
51    {
52        $father = $this->createMock(Individual::class);
53        $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
54
55        $family = $this->createMock(Family::class);
56        $family->method('husband')->willReturn($father);
57
58        $individual = $this->createMock(Individual::class);
59        $individual->method('primaryChildFamily')->willReturn($family);
60
61        $census = $this->createMock(CensusInterface::class);
62        $census->method('censusPlace')->willReturn('England');
63
64        $column = new CensusColumnFatherForeign($census, '', '');
65
66        $this->assertSame('', $column->generate($individual, $individual));
67    }
68
69    /**
70     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
71     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
72     *
73     * @return void
74     */
75    public function testDifferentCountry(): void
76    {
77        $father = $this->createMock(Individual::class);
78        $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
79
80        $family = $this->createMock(Family::class);
81        $family->method('husband')->willReturn($father);
82
83        $individual = $this->createMock(Individual::class);
84        $individual->method('primaryChildFamily')->willReturn($family);
85
86        $census = $this->createMock(CensusInterface::class);
87        $census->method('censusPlace')->willReturn('Ireland');
88
89        $column = new CensusColumnFatherForeign($census, '', '');
90
91        $this->assertSame('Y', $column->generate($individual, $individual));
92    }
93
94    /**
95     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
96     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
97     *
98     * @return void
99     */
100    public function testPlaceNoParent(): void
101    {
102        $family = $this->createMock(Family::class);
103        $family->method('husband')->willReturn(null);
104
105        $individual = $this->createMock(Individual::class);
106        $individual->method('primaryChildFamily')->willReturn($family);
107
108        $census = $this->createMock(CensusInterface::class);
109        $census->method('censusPlace')->willReturn('England');
110
111        $column = new CensusColumnFatherForeign($census, '', '');
112
113        $this->assertSame('', $column->generate($individual, $individual));
114    }
115
116    /**
117     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
118     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
119     *
120     * @return void
121     */
122    public function testPlaceNoParentFamily(): void
123    {
124        $individual = $this->createMock(Individual::class);
125        $individual->method('primaryChildFamily')->willReturn(null);
126
127        $census = $this->createMock(CensusInterface::class);
128        $census->method('censusPlace')->willReturn('England');
129
130        $column = new CensusColumnFatherForeign($census, '', '');
131
132        $this->assertSame('', $column->generate($individual, $individual));
133    }
134}
135