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