xref: /webtrees/tests/app/Census/CensusColumnBornForeignPartsTest.php (revision ef21b467575956631eb5374fe4f2bfb94e69aaa9)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2015 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 */
17
18namespace Fisharebest\Webtrees\Census;
19
20use Fisharebest\Webtrees\Date;
21use Fisharebest\Webtrees\Individual;
22use Mockery;
23
24/**
25 * Test harness for the class CensusColumnBornForeignParts
26 */
27class CensusColumnBornForeignPartsTest extends \PHPUnit_Framework_TestCase {
28	/**
29	 * Delete mock objects
30	 */
31	public function tearDown() {
32		Mockery::close();
33	}
34
35	/**
36	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
37	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
38	 */
39	public function testBornEnglandCensusEngland() {
40		$individual = Mockery::mock(Individual::class);
41		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
42
43		$census = Mockery::mock(CensusInterface::class);
44		$census->shouldReceive('censusPlace')->andReturn('England');
45
46		$column = new CensusColumnBornForeignParts($census, '', '');
47
48		$this->assertSame('', $column->generate($individual));
49	}
50
51	/**
52	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
53	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
54	 */
55	public function testBornWalesCensusEngland() {
56		$individual = Mockery::mock(Individual::class);
57		$individual->shouldReceive('getBirthPlace')->andReturn('Cardiff, Wales');
58
59		$census = Mockery::mock(CensusInterface::class);
60		$census->shouldReceive('censusPlace')->andReturn('England');
61
62		$column = new CensusColumnBornForeignParts($census, '', '');
63
64		$this->assertSame('', $column->generate($individual));
65	}
66
67	/**
68	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
69	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
70	 */
71	public function testBornScotlandCensusEngland() {
72		$individual = Mockery::mock(Individual::class);
73		$individual->shouldReceive('getBirthPlace')->andReturn('Edinburgh, Scotland');
74
75		$census = Mockery::mock(CensusInterface::class);
76		$census->shouldReceive('censusPlace')->andReturn('England');
77
78		$column = new CensusColumnBornForeignParts($census, '', '');
79
80		$this->assertSame('S', $column->generate($individual));
81	}
82
83	/**
84	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
85	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
86	 */
87	public function testBornIrelandCensusEngland() {
88		$individual = Mockery::mock(Individual::class);
89		$individual->shouldReceive('getBirthPlace')->andReturn('Dublin, Ireland');
90
91		$census = Mockery::mock(CensusInterface::class);
92		$census->shouldReceive('censusPlace')->andReturn('England');
93
94		$column = new CensusColumnBornForeignParts($census, '', '');
95
96		$this->assertSame('I', $column->generate($individual));
97	}
98
99	/**
100	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
101	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
102	 */
103	public function testBornForeignCensusEngland() {
104		$individual = Mockery::mock(Individual::class);
105		$individual->shouldReceive('getBirthPlace')->andReturn('Elbonia');
106
107		$census = Mockery::mock(CensusInterface::class);
108		$census->shouldReceive('censusPlace')->andReturn('England');
109
110		$column = new CensusColumnBornForeignParts($census, '', '');
111
112		$this->assertSame('F', $column->generate($individual));
113	}
114
115	/**
116	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
117	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
118	 */
119	public function testBornEnglandCensusIreland() {
120		$individual = Mockery::mock(Individual::class);
121		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
122
123		$census = Mockery::mock(CensusInterface::class);
124		$census->shouldReceive('censusPlace')->andReturn('Ireland');
125
126		$column = new CensusColumnBornForeignParts($census, '', '');
127
128		$this->assertSame('E', $column->generate($individual));
129	}
130
131	/**
132	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
133	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
134	 */
135	public function testBornWalesCensusIreland() {
136		$individual = Mockery::mock(Individual::class);
137		$individual->shouldReceive('getBirthPlace')->andReturn('Cardiff, Wales');
138
139		$census = Mockery::mock(CensusInterface::class);
140		$census->shouldReceive('censusPlace')->andReturn('Ireland');
141
142		$column = new CensusColumnBornForeignParts($census, '', '');
143
144		$this->assertSame('E', $column->generate($individual));
145	}
146
147	/**
148	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
149	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
150	 */
151	public function testBornScotlandCensusIreland() {
152		$individual = Mockery::mock(Individual::class);
153		$individual->shouldReceive('getBirthPlace')->andReturn('Edinburgh, Scotland');
154
155		$census = Mockery::mock(CensusInterface::class);
156		$census->shouldReceive('censusPlace')->andReturn('Ireland');
157
158		$column = new CensusColumnBornForeignParts($census, '', '');
159
160		$this->assertSame('S', $column->generate($individual));
161	}
162
163	/**
164	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
165	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
166	 */
167	public function testBornIrelandCensusIreland() {
168		$individual = Mockery::mock(Individual::class);
169		$individual->shouldReceive('getBirthPlace')->andReturn('Dublin, Ireland');
170
171		$census = Mockery::mock(CensusInterface::class);
172		$census->shouldReceive('censusPlace')->andReturn('Ireland');
173
174		$column = new CensusColumnBornForeignParts($census, '', '');
175
176		$this->assertSame('', $column->generate($individual));
177	}
178
179	/**
180	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
181	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
182	 */
183	public function testBornForeignCensusIreland() {
184		$individual = Mockery::mock(Individual::class);
185		$individual->shouldReceive('getBirthPlace')->andReturn('Elbonia');
186
187		$census = Mockery::mock(CensusInterface::class);
188		$census->shouldReceive('censusPlace')->andReturn('Ireland');
189
190		$column = new CensusColumnBornForeignParts($census, '', '');
191
192		$this->assertSame('F', $column->generate($individual));
193	}
194
195	/**
196	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
197	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
198	 */
199	public function testBornEnglandCensusScotland() {
200		$individual = Mockery::mock(Individual::class);
201		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
202
203		$census = Mockery::mock(CensusInterface::class);
204		$census->shouldReceive('censusPlace')->andReturn('Scotland');
205
206		$column = new CensusColumnBornForeignParts($census, '', '');
207
208		$this->assertSame('E', $column->generate($individual));
209	}
210
211	/**
212	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
213	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
214	 */
215	public function testBornWalesCensusScotland() {
216		$individual = Mockery::mock(Individual::class);
217		$individual->shouldReceive('getBirthPlace')->andReturn('Cardiff, Wales');
218
219		$census = Mockery::mock(CensusInterface::class);
220		$census->shouldReceive('censusPlace')->andReturn('Scotland');
221
222		$column = new CensusColumnBornForeignParts($census, '', '');
223
224		$this->assertSame('E', $column->generate($individual));
225	}
226
227	/**
228	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
229	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
230	 */
231	public function testBornScotlandCensusScotland() {
232		$individual = Mockery::mock(Individual::class);
233		$individual->shouldReceive('getBirthPlace')->andReturn('Edinburgh, Scotland');
234
235		$census = Mockery::mock(CensusInterface::class);
236		$census->shouldReceive('censusPlace')->andReturn('Scotland');
237
238		$column = new CensusColumnBornForeignParts($census, '', '');
239
240		$this->assertSame('', $column->generate($individual));
241	}
242
243	/**
244	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
245	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
246	 */
247	public function testBornIrelandCensusScotland() {
248		$individual = Mockery::mock(Individual::class);
249		$individual->shouldReceive('getBirthPlace')->andReturn('Dublin, Ireland');
250
251		$census = Mockery::mock(CensusInterface::class);
252		$census->shouldReceive('censusPlace')->andReturn('Scotland');
253
254		$column = new CensusColumnBornForeignParts($census, '', '');
255
256		$this->assertSame('I', $column->generate($individual));
257	}
258
259	/**
260	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
261	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
262	 */
263	public function testBornForeignCensusScotland() {
264		$individual = Mockery::mock(Individual::class);
265		$individual->shouldReceive('getBirthPlace')->andReturn('Elbonia');
266
267		$census = Mockery::mock(CensusInterface::class);
268		$census->shouldReceive('censusPlace')->andReturn('Scotland');
269
270		$column = new CensusColumnBornForeignParts($census, '', '');
271
272		$this->assertSame('F', $column->generate($individual));
273	}
274
275	/**
276	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
277	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
278	 */
279	public function testBornEnglandCensusWales() {
280		$individual = Mockery::mock(Individual::class);
281		$individual->shouldReceive('getBirthPlace')->andReturn('London, England');
282
283		$census = Mockery::mock(CensusInterface::class);
284		$census->shouldReceive('censusPlace')->andReturn('Wales');
285
286		$column = new CensusColumnBornForeignParts($census, '', '');
287
288		$this->assertSame('', $column->generate($individual));
289	}
290
291	/**
292	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
293	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
294	 */
295	public function testBornWalesCensusWales() {
296		$individual = Mockery::mock(Individual::class);
297		$individual->shouldReceive('getBirthPlace')->andReturn('Cardiff, Wales');
298
299		$census = Mockery::mock(CensusInterface::class);
300		$census->shouldReceive('censusPlace')->andReturn('Wales');
301
302		$column = new CensusColumnBornForeignParts($census, '', '');
303
304		$this->assertSame('', $column->generate($individual));
305	}
306
307	/**
308	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
309	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
310	 */
311	public function testBornScotlandCensusWales() {
312		$individual = Mockery::mock(Individual::class);
313		$individual->shouldReceive('getBirthPlace')->andReturn('Edinburgh, Scotland');
314
315		$census = Mockery::mock(CensusInterface::class);
316		$census->shouldReceive('censusPlace')->andReturn('Wales');
317
318		$column = new CensusColumnBornForeignParts($census, '', '');
319
320		$this->assertSame('S', $column->generate($individual));
321	}
322
323	/**
324	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
325	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
326	 */
327	public function testBornIrelandCensusWales() {
328		$individual = Mockery::mock(Individual::class);
329		$individual->shouldReceive('getBirthPlace')->andReturn('Dublin, Ireland');
330
331		$census = Mockery::mock(CensusInterface::class);
332		$census->shouldReceive('censusPlace')->andReturn('Wales');
333
334		$column = new CensusColumnBornForeignParts($census, '', '');
335
336		$this->assertSame('I', $column->generate($individual));
337	}
338
339	/**
340	 * @covers Fisharebest\Webtrees\Census\CensusColumnBornForeignParts
341	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
342	 */
343	public function testBornForeignCensusWales() {
344		$individual = Mockery::mock(Individual::class);
345		$individual->shouldReceive('getBirthPlace')->andReturn('Elbonia');
346
347		$census = Mockery::mock(CensusInterface::class);
348		$census->shouldReceive('censusPlace')->andReturn('Wales');
349
350		$column = new CensusColumnBornForeignParts($census, '', '');
351
352		$this->assertSame('F', $column->generate($individual));
353	}
354}
355