xref: /webtrees/tests/app/Census/CensusColumnBornForeignPartsTest.php (revision 24931b29a0237a5f5f1b8620af661ea530451af0)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 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 <https://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Census;
21
22use Fisharebest\Webtrees\Individual;
23use Fisharebest\Webtrees\Place;
24use Fisharebest\Webtrees\TestCase;
25use Illuminate\Support\Collection;
26
27/**
28 * Test harness for the class CensusColumnBornForeignParts
29 */
30class CensusColumnBornForeignPartsTest extends TestCase
31{
32    private function getPlaceMock(string $place): Place
33    {
34        $placeParts = explode(', ', $place);
35
36        $placeMock = $this->createMock(Place::class);
37        $placeMock->method('gedcomName')->willReturn($place);
38        $placeMock->method('lastParts')->willReturn((new Collection($placeParts))->slice(-1));
39
40        return $placeMock;
41    }
42
43    /**
44     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
45     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
46     */
47    public function testBornEnglandCensusEngland(): void
48    {
49        $individual = $this->createMock(Individual::class);
50        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
51
52        $census = $this->createMock(CensusInterface::class);
53        $census->method('censusPlace')->willReturn('England');
54
55        $column = new CensusColumnBornForeignParts($census, '', '');
56
57        self::assertSame('', $column->generate($individual, $individual));
58    }
59
60    /**
61     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
62     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
63     */
64    public function testBornWalesCensusEngland(): void
65    {
66        $individual = $this->createMock(Individual::class);
67        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
68
69        $census = $this->createMock(CensusInterface::class);
70        $census->method('censusPlace')->willReturn('England');
71
72        $column = new CensusColumnBornForeignParts($census, '', '');
73
74        self::assertSame('', $column->generate($individual, $individual));
75    }
76
77    /**
78     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
79     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
80     */
81    public function testBornScotlandCensusEngland(): void
82    {
83        $individual = $this->createMock(Individual::class);
84        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
85
86        $census = $this->createMock(CensusInterface::class);
87        $census->method('censusPlace')->willReturn('England');
88
89        $column = new CensusColumnBornForeignParts($census, '', '');
90
91        self::assertSame('S', $column->generate($individual, $individual));
92    }
93
94    /**
95     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
96     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
97     */
98    public function testBornIrelandCensusEngland(): void
99    {
100        $individual = $this->createMock(Individual::class);
101        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
102
103        $census = $this->createMock(CensusInterface::class);
104        $census->method('censusPlace')->willReturn('England');
105
106        $column = new CensusColumnBornForeignParts($census, '', '');
107
108        self::assertSame('I', $column->generate($individual, $individual));
109    }
110
111    /**
112     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
113     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
114     */
115    public function testBornForeignCensusEngland(): void
116    {
117        $individual = $this->createMock(Individual::class);
118        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
119
120        $census = $this->createMock(CensusInterface::class);
121        $census->method('censusPlace')->willReturn('England');
122
123        $column = new CensusColumnBornForeignParts($census, '', '');
124
125        self::assertSame('F', $column->generate($individual, $individual));
126    }
127
128    /**
129     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
130     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
131     */
132    public function testBornEnglandCensusIreland(): void
133    {
134        $individual = $this->createMock(Individual::class);
135        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
136
137        $census = $this->createMock(CensusInterface::class);
138        $census->method('censusPlace')->willReturn('Ireland');
139
140        $column = new CensusColumnBornForeignParts($census, '', '');
141
142        self::assertSame('E', $column->generate($individual, $individual));
143    }
144
145    /**
146     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
147     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
148     */
149    public function testBornWalesCensusIreland(): void
150    {
151        $individual = $this->createMock(Individual::class);
152        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
153
154        $census = $this->createMock(CensusInterface::class);
155        $census->method('censusPlace')->willReturn('Ireland');
156
157        $column = new CensusColumnBornForeignParts($census, '', '');
158
159        self::assertSame('E', $column->generate($individual, $individual));
160    }
161
162    /**
163     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
164     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
165     */
166    public function testBornScotlandCensusIreland(): void
167    {
168        $individual = $this->createMock(Individual::class);
169        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
170
171        $census = $this->createMock(CensusInterface::class);
172        $census->method('censusPlace')->willReturn('Ireland');
173
174        $column = new CensusColumnBornForeignParts($census, '', '');
175
176        self::assertSame('S', $column->generate($individual, $individual));
177    }
178
179    /**
180     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
181     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
182     */
183    public function testBornIrelandCensusIreland(): void
184    {
185        $individual = $this->createMock(Individual::class);
186        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
187
188        $census = $this->createMock(CensusInterface::class);
189        $census->method('censusPlace')->willReturn('Ireland');
190
191        $column = new CensusColumnBornForeignParts($census, '', '');
192
193        self::assertSame('', $column->generate($individual, $individual));
194    }
195
196    /**
197     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
198     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
199     */
200    public function testBornForeignCensusIreland(): void
201    {
202        $individual = $this->createMock(Individual::class);
203        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
204
205        $census = $this->createMock(CensusInterface::class);
206        $census->method('censusPlace')->willReturn('Ireland');
207
208        $column = new CensusColumnBornForeignParts($census, '', '');
209
210        self::assertSame('F', $column->generate($individual, $individual));
211    }
212
213    /**
214     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
215     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
216     */
217    public function testBornEnglandCensusScotland(): void
218    {
219        $individual = $this->createMock(Individual::class);
220        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
221
222        $census = $this->createMock(CensusInterface::class);
223        $census->method('censusPlace')->willReturn('Scotland');
224
225        $column = new CensusColumnBornForeignParts($census, '', '');
226
227        self::assertSame('E', $column->generate($individual, $individual));
228    }
229
230    /**
231     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
232     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
233     */
234    public function testBornWalesCensusScotland(): void
235    {
236        $individual = $this->createMock(Individual::class);
237        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
238
239        $census = $this->createMock(CensusInterface::class);
240        $census->method('censusPlace')->willReturn('Scotland');
241
242        $column = new CensusColumnBornForeignParts($census, '', '');
243
244        self::assertSame('E', $column->generate($individual, $individual));
245    }
246
247    /**
248     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
249     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
250     */
251    public function testBornScotlandCensusScotland(): void
252    {
253        $individual = $this->createMock(Individual::class);
254        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
255
256        $census = $this->createMock(CensusInterface::class);
257        $census->method('censusPlace')->willReturn('Scotland');
258
259        $column = new CensusColumnBornForeignParts($census, '', '');
260
261        self::assertSame('', $column->generate($individual, $individual));
262    }
263
264    /**
265     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
266     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
267     */
268    public function testBornIrelandCensusScotland(): void
269    {
270        $individual = $this->createMock(Individual::class);
271        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
272
273        $census = $this->createMock(CensusInterface::class);
274        $census->method('censusPlace')->willReturn('Scotland');
275
276        $column = new CensusColumnBornForeignParts($census, '', '');
277
278        self::assertSame('I', $column->generate($individual, $individual));
279    }
280
281    /**
282     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
283     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
284     */
285    public function testBornForeignCensusScotland(): void
286    {
287        $individual = $this->createMock(Individual::class);
288        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
289
290        $census = $this->createMock(CensusInterface::class);
291        $census->method('censusPlace')->willReturn('Scotland');
292
293        $column = new CensusColumnBornForeignParts($census, '', '');
294
295        self::assertSame('F', $column->generate($individual, $individual));
296    }
297
298    /**
299     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
300     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
301     */
302    public function testBornEnglandCensusWales(): void
303    {
304        $individual = $this->createMock(Individual::class);
305        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England'));
306
307        $census = $this->createMock(CensusInterface::class);
308        $census->method('censusPlace')->willReturn('Wales');
309
310        $column = new CensusColumnBornForeignParts($census, '', '');
311
312        self::assertSame('', $column->generate($individual, $individual));
313    }
314
315    /**
316     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
317     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
318     */
319    public function testBornWalesCensusWales(): void
320    {
321        $individual = $this->createMock(Individual::class);
322        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Cardiff, Wales'));
323
324        $census = $this->createMock(CensusInterface::class);
325        $census->method('censusPlace')->willReturn('Wales');
326
327        $column = new CensusColumnBornForeignParts($census, '', '');
328
329        self::assertSame('', $column->generate($individual, $individual));
330    }
331
332    /**
333     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
334     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
335     */
336    public function testBornScotlandCensusWales(): void
337    {
338        $individual = $this->createMock(Individual::class);
339        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Edinburgh, Scotland'));
340
341        $census = $this->createMock(CensusInterface::class);
342        $census->method('censusPlace')->willReturn('Wales');
343
344        $column = new CensusColumnBornForeignParts($census, '', '');
345
346        self::assertSame('S', $column->generate($individual, $individual));
347    }
348
349    /**
350     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
351     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
352     */
353    public function testBornIrelandCensusWales(): void
354    {
355        $individual = $this->createMock(Individual::class);
356        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Dublin, Ireland'));
357
358        $census = $this->createMock(CensusInterface::class);
359        $census->method('censusPlace')->willReturn('Wales');
360
361        $column = new CensusColumnBornForeignParts($census, '', '');
362
363        self::assertSame('I', $column->generate($individual, $individual));
364    }
365
366    /**
367     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
368     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
369     */
370    public function testBornForeignCensusWales(): void
371    {
372        $individual = $this->createMock(Individual::class);
373        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Elbonia'));
374
375        $census = $this->createMock(CensusInterface::class);
376        $census->method('censusPlace')->willReturn('Wales');
377
378        $column = new CensusColumnBornForeignParts($census, '', '');
379
380        self::assertSame('F', $column->generate($individual, $individual));
381    }
382
383    /**
384     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
385     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
386     */
387    public function testBornNowhereCensusEngland(): void
388    {
389        $individual = $this->createMock(Individual::class);
390        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock(''));
391
392        $census = $this->createMock(CensusInterface::class);
393        $census->method('censusPlace')->willReturn('England');
394
395        $column = new CensusColumnBornForeignParts($census, '', '');
396
397        self::assertSame('', $column->generate($individual, $individual));
398    }
399
400    /**
401     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
402     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
403     */
404    public function testBornNowhereCensusWales(): void
405    {
406        $individual = $this->createMock(Individual::class);
407        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock(''));
408
409        $census = $this->createMock(CensusInterface::class);
410        $census->method('censusPlace')->willReturn('Wales');
411
412        $column = new CensusColumnBornForeignParts($census, '', '');
413
414        self::assertSame('', $column->generate($individual, $individual));
415    }
416
417    /**
418     * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
419     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
420     */
421    public function testBornNowhereCensusScotland(): void
422    {
423        $individual = $this->createMock(Individual::class);
424        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock(''));
425
426        $census = $this->createMock(CensusInterface::class);
427        $census->method('censusPlace')->willReturn('Scotland');
428
429        $column = new CensusColumnBornForeignParts($census, '', '');
430
431        self::assertSame('', $column->generate($individual, $individual));
432    }
433}
434