xref: /webtrees/tests/app/Census/CensusColumnConditionFrenchFemmeTest.php (revision e76c0cf0a1f30c4a8739aa4873bf924d3c49e342)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2016 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 Fisharebest\Webtrees\Date;
20use Fisharebest\Webtrees\Fact;
21use Fisharebest\Webtrees\Family;
22use Fisharebest\Webtrees\Individual;
23use Mockery;
24
25/**
26 * Test harness for the class CensusColumnConditionFrenchFemme
27 */
28class CensusColumnConditionFrenchFemmeTest extends \PHPUnit_Framework_TestCase {
29	/**
30	 * Delete mock objects
31	 */
32	public function tearDown() {
33		Mockery::close();
34	}
35
36	/**
37	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
38	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
39	 */
40	public function testNoSpouseFamiliesMale() {
41		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
42		$individual->shouldReceive('getSex')->andReturn('M');
43		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
44		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
45
46		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
47		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
48
49		$column = new CensusColumnConditionFrenchFemme($census, '', '');
50
51		$this->assertSame('', $column->generate($individual));
52	}
53
54	/**
55	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
56	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
57	 */
58	public function testNoSpouseFamiliesFemale() {
59		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
60		$individual->shouldReceive('getSex')->andReturn('F');
61		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
62		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
63
64		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
65		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
66
67		$column = new CensusColumnConditionFrenchFemme($census, '', '');
68
69		$this->assertSame('', $column->generate($individual));
70	}
71
72	/**
73	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
74	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
75	 */
76	public function testNoFamilyFactsMale() {
77		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
78		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1850'));
79
80		$family = Mockery::mock('Fisharebest\Webtrees\Family');
81		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
82		$family->shouldReceive('getFacts')->andReturn(array());
83		$family->shouldReceive('getSpouse')->andReturn($spouse);
84
85		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
86		$individual->shouldReceive('getSex')->andReturn('M');
87		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
88
89		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
90
91		$column = new CensusColumnConditionFrenchFemme($census, '', '');
92		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
93
94		$this->assertSame('', $column->generate($individual));
95	}
96
97	/**
98	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
99	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
100	 */
101	public function testNoFamilyFactsFemale() {
102		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
103		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1850'));
104
105		$family = Mockery::mock('Fisharebest\Webtrees\Family');
106		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
107		$family->shouldReceive('getFacts')->andReturn(array());
108		$family->shouldReceive('getSpouse')->andReturn($spouse);
109
110		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
111		$individual->shouldReceive('getSex')->andReturn('F');
112		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
113
114		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
115
116		$column = new CensusColumnConditionFrenchFemme($census, '', '');
117		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
118
119		$this->assertSame('1', $column->generate($individual));
120	}
121
122	/**
123	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
124	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
125	 */
126	public function testSpouseDeadMale() {
127		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
128		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
129
130		$family = Mockery::mock('Fisharebest\Webtrees\Family');
131		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
132		$family->shouldReceive('getFacts')->andReturn(array());
133		$family->shouldReceive('getSpouse')->andReturn($spouse);
134
135		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
136		$individual->shouldReceive('getSex')->andReturn('M');
137		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
138
139		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
140
141		$column = new CensusColumnConditionFrenchFemme($census, '', '');
142		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
143
144		$this->assertSame('', $column->generate($individual));
145	}
146
147	/**
148	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
149	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
150	 */
151	public function testSpouseDeadFemale() {
152		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
153		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
154
155		$family = Mockery::mock('Fisharebest\Webtrees\Family');
156		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
157		$family->shouldReceive('getFacts')->andReturn(array());
158		$family->shouldReceive('getSpouse')->andReturn($spouse);
159
160		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
161		$individual->shouldReceive('getSex')->andReturn('F');
162		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
163
164		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
165
166		$column = new CensusColumnConditionFrenchFemme($census, '', '');
167		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
168
169		$this->assertSame('', $column->generate($individual));
170	}
171
172	/**
173	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
174	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
175	 */
176	public function testNoFamilyUnmarriedMale() {
177		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
178
179		$family = Mockery::mock('Fisharebest\Webtrees\Family');
180		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
181		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
182
183		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
184		$individual->shouldReceive('getSex')->andReturn('M');
185		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
186		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
187
188		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
189		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
190
191		$column = new CensusColumnConditionFrenchFemme($census, '', '');
192
193		$this->assertSame('', $column->generate($individual));
194	}
195
196	/**
197	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
198	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
199	 */
200	public function testNoFamilyUnmarriedFemale() {
201		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
202
203		$family = Mockery::mock('Fisharebest\Webtrees\Family');
204		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
205		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
206
207		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
208		$individual->shouldReceive('getSex')->andReturn('F');
209		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
210		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
211
212		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
213		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
214
215		$column = new CensusColumnConditionFrenchFemme($census, '', '');
216
217		$this->assertSame('', $column->generate($individual));
218	}
219
220	/**
221	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
222	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
223	 */
224	public function testChildMale() {
225		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
226
227		$family = Mockery::mock('Fisharebest\Webtrees\Family');
228		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
229		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
230
231		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
232		$individual->shouldReceive('getSex')->andReturn('M');
233		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
234		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
235
236		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
237		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
238
239		$column = new CensusColumnConditionFrenchFemme($census, '', '');
240
241		$this->assertSame('', $column->generate($individual));
242	}
243
244	/**
245	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
246	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
247	 */
248	public function testChildFemale() {
249		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
250
251		$family = Mockery::mock('Fisharebest\Webtrees\Family');
252		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
253		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
254
255		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
256		$individual->shouldReceive('getSex')->andReturn('F');
257		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
258		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
259
260		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
261		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
262
263		$column = new CensusColumnConditionFrenchFemme($census, '', '');
264
265		$this->assertSame('', $column->generate($individual));
266	}
267
268	/**
269	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
270	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
271	 */
272	public function testDivorcedMale() {
273		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
274
275		$family = Mockery::mock('Fisharebest\Webtrees\Family');
276		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
277		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array());
278		$family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact));
279
280		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
281		$individual->shouldReceive('getSex')->andReturn('M');
282		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
283
284		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
285
286		$column = new CensusColumnConditionFrenchFemme($census, '', '');
287		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
288
289		$this->assertSame('', $column->generate($individual));
290	}
291
292	/**
293	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
294	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
295	 */
296	public function testDivorcedFemale() {
297		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
298
299		$family = Mockery::mock('Fisharebest\Webtrees\Family');
300		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
301		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array());
302		$family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact));
303
304		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
305		$individual->shouldReceive('getSex')->andReturn('F');
306		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
307
308		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
309
310		$column = new CensusColumnConditionFrenchFemme($census, '', '');
311		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
312
313		$this->assertSame('1', $column->generate($individual));
314	}
315}
316