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