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