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