xref: /webtrees/tests/app/Census/CensusColumnFatherForeignTest.php (revision d11be7027e34e3121be11cc025421873364403f9)
1a53db70dSGreg Roach<?php
23976b470SGreg Roach
3a53db70dSGreg Roach/**
4a53db70dSGreg Roach * webtrees: online genealogy
5*d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify
7a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by
8a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a53db70dSGreg Roach * (at your option) any later version.
10a53db70dSGreg Roach * This program is distributed in the hope that it will be useful,
11a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a53db70dSGreg Roach * GNU General Public License for more details.
14a53db70dSGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16a53db70dSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
20a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census;
21a53db70dSGreg Roach
22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
2452348eb8SGreg Roachuse Fisharebest\Webtrees\Place;
253cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
261afbbc50SGreg Roachuse Illuminate\Support\Collection;
27a53db70dSGreg Roach
28a53db70dSGreg Roach/**
29a53db70dSGreg Roach * Test harness for the class CensusColumnFatherForeign
30a53db70dSGreg Roach */
313cfcc809SGreg Roachclass CensusColumnFatherForeignTest extends TestCase
32c1010edaSGreg Roach{
33a53db70dSGreg Roach    /**
3416d0b7f7SRico Sonntag     * Get place mock.
3516d0b7f7SRico Sonntag     *
3616d0b7f7SRico Sonntag     * @param string $place Gedcom Place
3716d0b7f7SRico Sonntag     *
3852348eb8SGreg Roach     * @return Place
3916d0b7f7SRico Sonntag     */
405e933c21SGreg Roach    private function getPlaceMock(string $place): Place
41c1010edaSGreg Roach    {
42cd94ca66SGreg Roach        $placeMock = $this->createMock(Place::class);
430ecdbde6SGreg Roach        $placeMock->method('gedcomName')->willReturn($place);
4416d0b7f7SRico Sonntag
4516d0b7f7SRico Sonntag        return $placeMock;
4616d0b7f7SRico Sonntag    }
4716d0b7f7SRico Sonntag
4816d0b7f7SRico Sonntag    /**
4915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
5015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
5118d7a90dSGreg Roach     *
5218d7a90dSGreg Roach     * @return void
53a53db70dSGreg Roach     */
549b802b22SGreg Roach    public function testSameCountry(): void
55c1010edaSGreg Roach    {
56cd94ca66SGreg Roach        $father = $this->createMock(Individual::class);
570ecdbde6SGreg Roach        $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
58a53db70dSGreg Roach
59cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
600ecdbde6SGreg Roach        $family->method('husband')->willReturn($father);
61a53db70dSGreg Roach
62cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
631afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection([$family]));
64a53db70dSGreg Roach
65cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
660ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
67a53db70dSGreg Roach
68a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
69a53db70dSGreg Roach
705e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
71a53db70dSGreg Roach    }
72a53db70dSGreg Roach
73a53db70dSGreg Roach    /**
7415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
7515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
7618d7a90dSGreg Roach     *
7718d7a90dSGreg Roach     * @return void
78a53db70dSGreg Roach     */
799b802b22SGreg Roach    public function testDifferentCountry(): void
80c1010edaSGreg Roach    {
81cd94ca66SGreg Roach        $father = $this->createMock(Individual::class);
820ecdbde6SGreg Roach        $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
83a53db70dSGreg Roach
84cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
850ecdbde6SGreg Roach        $family->method('husband')->willReturn($father);
86a53db70dSGreg Roach
87cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
881afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection([$family]));
89a53db70dSGreg Roach
90cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
910ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
92a53db70dSGreg Roach
93a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
94a53db70dSGreg Roach
955e933c21SGreg Roach        self::assertSame('Y', $column->generate($individual, $individual));
96a53db70dSGreg Roach    }
97a53db70dSGreg Roach
98a53db70dSGreg Roach    /**
9915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
10015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
10118d7a90dSGreg Roach     *
10218d7a90dSGreg Roach     * @return void
103a53db70dSGreg Roach     */
1049b802b22SGreg Roach    public function testPlaceNoParent(): void
105c1010edaSGreg Roach    {
106cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
1070ecdbde6SGreg Roach        $family->method('husband')->willReturn(null);
108a53db70dSGreg Roach
109cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1101afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection([$family]));
111a53db70dSGreg Roach
112cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1130ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
114a53db70dSGreg Roach
115a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
116a53db70dSGreg Roach
1175e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
118a53db70dSGreg Roach    }
119a53db70dSGreg Roach
120a53db70dSGreg Roach    /**
12115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign
12215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
12318d7a90dSGreg Roach     *
12418d7a90dSGreg Roach     * @return void
125a53db70dSGreg Roach     */
1269b802b22SGreg Roach    public function testPlaceNoParentFamily(): void
127c1010edaSGreg Roach    {
128cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1291afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection());
130a53db70dSGreg Roach
131cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1320ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
133a53db70dSGreg Roach
134a53db70dSGreg Roach        $column = new CensusColumnFatherForeign($census, '', '');
135a53db70dSGreg Roach
1365e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
137a53db70dSGreg Roach    }
138a53db70dSGreg Roach}
139