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