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