xref: /webtrees/tests/app/Census/CensusColumnBornForeignPartsTest.php (revision 0fd39724ec01f9f77115641c88ab7da1a4b09227)
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	{
41		$placeParts = explode(', ', $place);
42
43		$placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
44		$placeMock->shouldReceive('getGedcomName')->andReturn($place);
45		$placeMock->shouldReceive('lastPart')->andReturn(end($placeParts));
46
47		return $placeMock;
48	}
49
50	/**
51	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
52	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
53	 */
54	public function testBornEnglandCensusEngland() {
55		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
56		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
57
58		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
59		$census->shouldReceive('censusPlace')->andReturn('England');
60
61		$column = new CensusColumnBornForeignParts($census, '', '');
62
63		$this->assertSame('', $column->generate($individual));
64	}
65
66	/**
67	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
68	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
69	 */
70	public function testBornWalesCensusEngland() {
71		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
72		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales'));
73
74		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
75		$census->shouldReceive('censusPlace')->andReturn('England');
76
77		$column = new CensusColumnBornForeignParts($census, '', '');
78
79		$this->assertSame('', $column->generate($individual));
80	}
81
82	/**
83	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
84	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
85	 */
86	public function testBornScotlandCensusEngland() {
87		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
88		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland'));
89
90		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
91		$census->shouldReceive('censusPlace')->andReturn('England');
92
93		$column = new CensusColumnBornForeignParts($census, '', '');
94
95		$this->assertSame('S', $column->generate($individual));
96	}
97
98	/**
99	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
100	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
101	 */
102	public function testBornIrelandCensusEngland() {
103		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
104		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland'));
105
106		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
107		$census->shouldReceive('censusPlace')->andReturn('England');
108
109		$column = new CensusColumnBornForeignParts($census, '', '');
110
111		$this->assertSame('I', $column->generate($individual));
112	}
113
114	/**
115	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
116	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
117	 */
118	public function testBornForeignCensusEngland() {
119		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
120		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia'));
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('F', $column->generate($individual));
128	}
129
130	/**
131	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
132	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
133	 */
134	public function testBornEnglandCensusIreland() {
135		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
136		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
137
138		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
139		$census->shouldReceive('censusPlace')->andReturn('Ireland');
140
141		$column = new CensusColumnBornForeignParts($census, '', '');
142
143		$this->assertSame('E', $column->generate($individual));
144	}
145
146	/**
147	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
148	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
149	 */
150	public function testBornWalesCensusIreland() {
151		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
152		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales'));
153
154		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
155		$census->shouldReceive('censusPlace')->andReturn('Ireland');
156
157		$column = new CensusColumnBornForeignParts($census, '', '');
158
159		$this->assertSame('E', $column->generate($individual));
160	}
161
162	/**
163	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
164	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
165	 */
166	public function testBornScotlandCensusIreland() {
167		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
168		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland'));
169
170		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
171		$census->shouldReceive('censusPlace')->andReturn('Ireland');
172
173		$column = new CensusColumnBornForeignParts($census, '', '');
174
175		$this->assertSame('S', $column->generate($individual));
176	}
177
178	/**
179	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
180	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
181	 */
182	public function testBornIrelandCensusIreland() {
183		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
184		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland'));
185
186		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
187		$census->shouldReceive('censusPlace')->andReturn('Ireland');
188
189		$column = new CensusColumnBornForeignParts($census, '', '');
190
191		$this->assertSame('', $column->generate($individual));
192	}
193
194	/**
195	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
196	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
197	 */
198	public function testBornForeignCensusIreland() {
199		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
200		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia'));
201
202		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
203		$census->shouldReceive('censusPlace')->andReturn('Ireland');
204
205		$column = new CensusColumnBornForeignParts($census, '', '');
206
207		$this->assertSame('F', $column->generate($individual));
208	}
209
210	/**
211	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
212	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
213	 */
214	public function testBornEnglandCensusScotland() {
215		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
216		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
217
218		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
219		$census->shouldReceive('censusPlace')->andReturn('Scotland');
220
221		$column = new CensusColumnBornForeignParts($census, '', '');
222
223		$this->assertSame('E', $column->generate($individual));
224	}
225
226	/**
227	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
228	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
229	 */
230	public function testBornWalesCensusScotland() {
231		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
232		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales'));
233
234		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
235		$census->shouldReceive('censusPlace')->andReturn('Scotland');
236
237		$column = new CensusColumnBornForeignParts($census, '', '');
238
239		$this->assertSame('E', $column->generate($individual));
240	}
241
242	/**
243	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
244	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
245	 */
246	public function testBornScotlandCensusScotland() {
247		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
248		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland'));
249
250		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
251		$census->shouldReceive('censusPlace')->andReturn('Scotland');
252
253		$column = new CensusColumnBornForeignParts($census, '', '');
254
255		$this->assertSame('', $column->generate($individual));
256	}
257
258	/**
259	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
260	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
261	 */
262	public function testBornIrelandCensusScotland() {
263		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
264		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland'));
265
266		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
267		$census->shouldReceive('censusPlace')->andReturn('Scotland');
268
269		$column = new CensusColumnBornForeignParts($census, '', '');
270
271		$this->assertSame('I', $column->generate($individual));
272	}
273
274	/**
275	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
276	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
277	 */
278	public function testBornForeignCensusScotland() {
279		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
280		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia'));
281
282		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
283		$census->shouldReceive('censusPlace')->andReturn('Scotland');
284
285		$column = new CensusColumnBornForeignParts($census, '', '');
286
287		$this->assertSame('F', $column->generate($individual));
288	}
289
290	/**
291	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
292	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
293	 */
294	public function testBornEnglandCensusWales() {
295		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
296		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
297
298		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
299		$census->shouldReceive('censusPlace')->andReturn('Wales');
300
301		$column = new CensusColumnBornForeignParts($census, '', '');
302
303		$this->assertSame('', $column->generate($individual));
304	}
305
306	/**
307	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
308	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
309	 */
310	public function testBornWalesCensusWales() {
311		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
312		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Cardiff, Wales'));
313
314		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
315		$census->shouldReceive('censusPlace')->andReturn('Wales');
316
317		$column = new CensusColumnBornForeignParts($census, '', '');
318
319		$this->assertSame('', $column->generate($individual));
320	}
321
322	/**
323	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
324	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
325	 */
326	public function testBornScotlandCensusWales() {
327		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
328		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Edinburgh, Scotland'));
329
330		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
331		$census->shouldReceive('censusPlace')->andReturn('Wales');
332
333		$column = new CensusColumnBornForeignParts($census, '', '');
334
335		$this->assertSame('S', $column->generate($individual));
336	}
337
338	/**
339	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
340	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
341	 */
342	public function testBornIrelandCensusWales() {
343		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
344		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Dublin, Ireland'));
345
346		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
347		$census->shouldReceive('censusPlace')->andReturn('Wales');
348
349		$column = new CensusColumnBornForeignParts($census, '', '');
350
351		$this->assertSame('I', $column->generate($individual));
352	}
353
354	/**
355	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
356	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
357	 */
358	public function testBornForeignCensusWales() {
359		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
360		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Elbonia'));
361
362		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
363		$census->shouldReceive('censusPlace')->andReturn('Wales');
364
365		$column = new CensusColumnBornForeignParts($census, '', '');
366
367		$this->assertSame('F', $column->generate($individual));
368	}
369
370	/**
371	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
372	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
373	 */
374	public function testBornNowhereCensusEngland() {
375		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
376		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock(''));
377
378		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
379		$census->shouldReceive('censusPlace')->andReturn('England');
380
381		$column = new CensusColumnBornForeignParts($census, '', '');
382
383		$this->assertSame('', $column->generate($individual));
384	}
385
386	/**
387	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
388	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
389	 */
390	public function testBornNowhereCensusWales() {
391		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
392		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock(''));
393
394		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
395		$census->shouldReceive('censusPlace')->andReturn('Wales');
396
397		$column = new CensusColumnBornForeignParts($census, '', '');
398
399		$this->assertSame('', $column->generate($individual));
400	}
401
402	/**
403	 * @covers \Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
404	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
405	 */
406	public function testBornNowhereCensusScotland() {
407		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
408		$individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock(''));
409
410		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
411		$census->shouldReceive('censusPlace')->andReturn('Scotland');
412
413		$column = new CensusColumnBornForeignParts($census, '', '');
414
415		$this->assertSame('', $column->generate($individual));
416	}
417}
418