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