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