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