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