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