xref: /webtrees/tests/app/Census/CensusColumnBornForeignPartsTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1db7d25eeSGreg Roach<?php
23976b470SGreg Roach
3db7d25eeSGreg Roach/**
4db7d25eeSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify
7db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by
8db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9db7d25eeSGreg Roach * (at your option) any later version.
10db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful,
11db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13db7d25eeSGreg Roach * GNU General Public License for more details.
14db7d25eeSGreg 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/>.
16db7d25eeSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
20db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
21db7d25eeSGreg Roach
22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
2352348eb8SGreg Roachuse Fisharebest\Webtrees\Place;
243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
25392561bbSGreg Roachuse Illuminate\Support\Collection;
26*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
27db7d25eeSGreg Roach
28*202c018bSGreg Roach#[CoversClass(CensusColumnBornForeignParts::class)]
29*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
303cfcc809SGreg Roachclass CensusColumnBornForeignPartsTest extends TestCase
31c1010edaSGreg Roach{
325e933c21SGreg Roach    private function getPlaceMock(string $place): Place
33c1010edaSGreg Roach    {
3416d0b7f7SRico Sonntag        $placeParts = explode(', ', $place);
3516d0b7f7SRico Sonntag
36cd94ca66SGreg Roach        $placeMock = $this->createMock(Place::class);
370ecdbde6SGreg Roach        $placeMock->method('gedcomName')->willReturn($place);
380ecdbde6SGreg Roach        $placeMock->method('lastParts')->willReturn((new Collection($placeParts))->slice(-1));
3916d0b7f7SRico Sonntag
4016d0b7f7SRico Sonntag        return $placeMock;
4116d0b7f7SRico Sonntag    }
4216d0b7f7SRico Sonntag
439b802b22SGreg Roach    public function testBornEnglandCensusEngland(): void
44c1010edaSGreg Roach    {
45cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
460ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
47db7d25eeSGreg Roach
48cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
490ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
50db7d25eeSGreg Roach
51ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
52db7d25eeSGreg Roach
535e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
54db7d25eeSGreg Roach    }
55db7d25eeSGreg Roach
569b802b22SGreg Roach    public function testBornWalesCensusEngland(): void
57c1010edaSGreg Roach    {
58cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
590ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
60db7d25eeSGreg Roach
61cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
620ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
63db7d25eeSGreg Roach
64ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
65db7d25eeSGreg Roach
665e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
67db7d25eeSGreg Roach    }
68db7d25eeSGreg Roach
699b802b22SGreg Roach    public function testBornScotlandCensusEngland(): void
70c1010edaSGreg Roach    {
71cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
720ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
73db7d25eeSGreg Roach
74cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
750ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
76db7d25eeSGreg Roach
77ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
78db7d25eeSGreg Roach
795e933c21SGreg Roach        self::assertSame('S', $column->generate($individual, $individual));
80db7d25eeSGreg Roach    }
81db7d25eeSGreg Roach
829b802b22SGreg Roach    public function testBornIrelandCensusEngland(): void
83c1010edaSGreg Roach    {
84cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
850ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
86db7d25eeSGreg Roach
87cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
880ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
89db7d25eeSGreg Roach
90ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
91db7d25eeSGreg Roach
925e933c21SGreg Roach        self::assertSame('I', $column->generate($individual, $individual));
93db7d25eeSGreg Roach    }
94db7d25eeSGreg Roach
959b802b22SGreg Roach    public function testBornForeignCensusEngland(): void
96c1010edaSGreg Roach    {
97cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
980ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
99db7d25eeSGreg Roach
100cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1010ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
102db7d25eeSGreg Roach
103ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
104db7d25eeSGreg Roach
1055e933c21SGreg Roach        self::assertSame('F', $column->generate($individual, $individual));
106db7d25eeSGreg Roach    }
107db7d25eeSGreg Roach
1089b802b22SGreg Roach    public function testBornEnglandCensusIreland(): void
109c1010edaSGreg Roach    {
110cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1110ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
112db7d25eeSGreg Roach
113cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1140ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
115db7d25eeSGreg Roach
116ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
117db7d25eeSGreg Roach
1185e933c21SGreg Roach        self::assertSame('E', $column->generate($individual, $individual));
119db7d25eeSGreg Roach    }
120db7d25eeSGreg Roach
1219b802b22SGreg Roach    public function testBornWalesCensusIreland(): void
122c1010edaSGreg Roach    {
123cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1240ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
125db7d25eeSGreg Roach
126cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1270ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
128db7d25eeSGreg Roach
129ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
130db7d25eeSGreg Roach
1315e933c21SGreg Roach        self::assertSame('E', $column->generate($individual, $individual));
132db7d25eeSGreg Roach    }
133db7d25eeSGreg Roach
1349b802b22SGreg Roach    public function testBornScotlandCensusIreland(): void
135c1010edaSGreg Roach    {
136cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1370ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
138db7d25eeSGreg Roach
139cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1400ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
141db7d25eeSGreg Roach
142ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
143db7d25eeSGreg Roach
1445e933c21SGreg Roach        self::assertSame('S', $column->generate($individual, $individual));
145db7d25eeSGreg Roach    }
146db7d25eeSGreg Roach
1479b802b22SGreg Roach    public function testBornIrelandCensusIreland(): void
148c1010edaSGreg Roach    {
149cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1500ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
151db7d25eeSGreg Roach
152cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1530ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
154db7d25eeSGreg Roach
155ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
156db7d25eeSGreg Roach
1575e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
158db7d25eeSGreg Roach    }
159db7d25eeSGreg Roach
1609b802b22SGreg Roach    public function testBornForeignCensusIreland(): void
161c1010edaSGreg Roach    {
162cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1630ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
164db7d25eeSGreg Roach
165cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1660ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Ireland');
167db7d25eeSGreg Roach
168ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
169db7d25eeSGreg Roach
1705e933c21SGreg Roach        self::assertSame('F', $column->generate($individual, $individual));
171db7d25eeSGreg Roach    }
172db7d25eeSGreg Roach
1739b802b22SGreg Roach    public function testBornEnglandCensusScotland(): void
174c1010edaSGreg Roach    {
175cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1760ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
177db7d25eeSGreg Roach
178cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1790ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Scotland');
180db7d25eeSGreg Roach
181ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
182db7d25eeSGreg Roach
1835e933c21SGreg Roach        self::assertSame('E', $column->generate($individual, $individual));
184db7d25eeSGreg Roach    }
185db7d25eeSGreg Roach
1869b802b22SGreg Roach    public function testBornWalesCensusScotland(): void
187c1010edaSGreg Roach    {
188cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1890ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
190db7d25eeSGreg Roach
191cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1920ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Scotland');
193db7d25eeSGreg Roach
194ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
195db7d25eeSGreg Roach
1965e933c21SGreg Roach        self::assertSame('E', $column->generate($individual, $individual));
197db7d25eeSGreg Roach    }
198db7d25eeSGreg Roach
1999b802b22SGreg Roach    public function testBornScotlandCensusScotland(): void
200c1010edaSGreg Roach    {
201cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2020ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
203db7d25eeSGreg Roach
204cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2050ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Scotland');
206db7d25eeSGreg Roach
207ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
208db7d25eeSGreg Roach
2095e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
210db7d25eeSGreg Roach    }
211db7d25eeSGreg Roach
2129b802b22SGreg Roach    public function testBornIrelandCensusScotland(): void
213c1010edaSGreg Roach    {
214cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2150ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
216db7d25eeSGreg Roach
217cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2180ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Scotland');
219db7d25eeSGreg Roach
220ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
221db7d25eeSGreg Roach
2225e933c21SGreg Roach        self::assertSame('I', $column->generate($individual, $individual));
223db7d25eeSGreg Roach    }
224db7d25eeSGreg Roach
2259b802b22SGreg Roach    public function testBornForeignCensusScotland(): void
226c1010edaSGreg Roach    {
227cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2280ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
229db7d25eeSGreg Roach
230cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2310ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Scotland');
232db7d25eeSGreg Roach
233ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
234db7d25eeSGreg Roach
2355e933c21SGreg Roach        self::assertSame('F', $column->generate($individual, $individual));
236db7d25eeSGreg Roach    }
237db7d25eeSGreg Roach
2389b802b22SGreg Roach    public function testBornEnglandCensusWales(): void
239c1010edaSGreg Roach    {
240cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2410ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
242db7d25eeSGreg Roach
243cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2440ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Wales');
245db7d25eeSGreg Roach
246ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
247db7d25eeSGreg Roach
2485e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
249db7d25eeSGreg Roach    }
250db7d25eeSGreg Roach
2519b802b22SGreg Roach    public function testBornWalesCensusWales(): void
252c1010edaSGreg Roach    {
253cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2540ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
255db7d25eeSGreg Roach
256cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2570ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Wales');
258db7d25eeSGreg Roach
259ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
260db7d25eeSGreg Roach
2615e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
262db7d25eeSGreg Roach    }
263db7d25eeSGreg Roach
2649b802b22SGreg Roach    public function testBornScotlandCensusWales(): void
265c1010edaSGreg Roach    {
266cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2670ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
268db7d25eeSGreg Roach
269cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2700ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Wales');
271db7d25eeSGreg Roach
272ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
273db7d25eeSGreg Roach
2745e933c21SGreg Roach        self::assertSame('S', $column->generate($individual, $individual));
275db7d25eeSGreg Roach    }
276db7d25eeSGreg Roach
2779b802b22SGreg Roach    public function testBornIrelandCensusWales(): void
278c1010edaSGreg Roach    {
279cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2800ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
281db7d25eeSGreg Roach
282cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2830ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Wales');
284db7d25eeSGreg Roach
285ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
286db7d25eeSGreg Roach
2875e933c21SGreg Roach        self::assertSame('I', $column->generate($individual, $individual));
288db7d25eeSGreg Roach    }
289db7d25eeSGreg Roach
2909b802b22SGreg Roach    public function testBornForeignCensusWales(): void
291c1010edaSGreg Roach    {
292cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2930ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
294db7d25eeSGreg Roach
295cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2960ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Wales');
297db7d25eeSGreg Roach
298ef21b467SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
299db7d25eeSGreg Roach
3005e933c21SGreg Roach        self::assertSame('F', $column->generate($individual, $individual));
301db7d25eeSGreg Roach    }
302b164ca57SGreg Roach
3039b802b22SGreg Roach    public function testBornNowhereCensusEngland(): void
304c1010edaSGreg Roach    {
305cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
3060ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock(''));
307b164ca57SGreg Roach
308cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
3090ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('England');
310b164ca57SGreg Roach
311b164ca57SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
312b164ca57SGreg Roach
3135e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
314b164ca57SGreg Roach    }
315b164ca57SGreg Roach
3169b802b22SGreg Roach    public function testBornNowhereCensusWales(): void
317c1010edaSGreg Roach    {
318cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
3190ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock(''));
320b164ca57SGreg Roach
321cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
3220ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Wales');
323b164ca57SGreg Roach
324b164ca57SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
325b164ca57SGreg Roach
3265e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
327b164ca57SGreg Roach    }
328b164ca57SGreg Roach
3299b802b22SGreg Roach    public function testBornNowhereCensusScotland(): void
330c1010edaSGreg Roach    {
331cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
3320ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock(''));
333b164ca57SGreg Roach
334cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
3350ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('Scotland');
336b164ca57SGreg Roach
337b164ca57SGreg Roach        $column = new CensusColumnBornForeignParts($census, '', '');
338b164ca57SGreg Roach
3395e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
340b164ca57SGreg Roach    }
341db7d25eeSGreg Roach}
342