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