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