xref: /webtrees/tests/app/Census/CensusColumnMotherForeignTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1a53db70dSGreg Roach<?php
23976b470SGreg Roach
3a53db70dSGreg Roach/**
4a53db70dSGreg Roach * webtrees: online genealogy
5d11be702SGreg 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;
27*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
28a53db70dSGreg Roach
29*202c018bSGreg Roach#[CoversClass(CensusColumnMotherForeign::class)]
30*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
313cfcc809SGreg Roachclass CensusColumnMotherForeignTest extends TestCase
32c1010edaSGreg Roach{
335e933c21SGreg Roach    private function getPlaceMock(string $place): Place
34c1010edaSGreg Roach    {
35cd94ca66SGreg Roach        $placeMock = $this->createMock(Place::class);
360ecdbde6SGreg Roach        $placeMock->method('gedcomName')->willReturn($place);
3716d0b7f7SRico Sonntag
3816d0b7f7SRico Sonntag        return $placeMock;
3916d0b7f7SRico Sonntag    }
4016d0b7f7SRico Sonntag
419b802b22SGreg Roach    public function testSameCountry(): void
42c1010edaSGreg Roach    {
43cd94ca66SGreg Roach        $mother = $this->createMock(Individual::class);
440ecdbde6SGreg Roach        $mother->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
45a53db70dSGreg Roach
46cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
470ecdbde6SGreg Roach        $family->method('wife')->willReturn($mother);
48a53db70dSGreg Roach
49cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
501afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection([$family]));
51a53db70dSGreg Roach
52cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
530ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
54a53db70dSGreg Roach
55a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
56a53db70dSGreg Roach
575e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
58a53db70dSGreg Roach    }
59a53db70dSGreg Roach
609b802b22SGreg Roach    public function testDifferentCountry(): void
61c1010edaSGreg Roach    {
62cd94ca66SGreg Roach        $mother = $this->createMock(Individual::class);
630ecdbde6SGreg Roach        $mother->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
64a53db70dSGreg Roach
65cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
660ecdbde6SGreg Roach        $family->method('wife')->willReturn($mother);
67a53db70dSGreg Roach
68cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
691afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection([$family]));
70a53db70dSGreg Roach
71cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
720ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
73a53db70dSGreg Roach
74a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
75a53db70dSGreg Roach
765e933c21SGreg Roach        self::assertSame('Y', $column->generate($individual, $individual));
77a53db70dSGreg Roach    }
78a53db70dSGreg Roach
799b802b22SGreg Roach    public function testPlaceNoParent(): void
80c1010edaSGreg Roach    {
81cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
820ecdbde6SGreg Roach        $family->method('wife')->willReturn(null);
83a53db70dSGreg Roach
84cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
851afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection([$family]));
86a53db70dSGreg Roach
87cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
880ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
89a53db70dSGreg Roach
90a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
91a53db70dSGreg Roach
925e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
93a53db70dSGreg Roach    }
94a53db70dSGreg Roach
959b802b22SGreg Roach    public function testPlaceNoParentFamily(): void
96c1010edaSGreg Roach    {
97cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
981afbbc50SGreg Roach        $individual->method('childFamilies')->willReturn(new Collection());
99a53db70dSGreg Roach
100cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1010ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
102a53db70dSGreg Roach
103a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
104a53db70dSGreg Roach
1055e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
106a53db70dSGreg Roach    }
107a53db70dSGreg Roach}
108