xref: /webtrees/tests/app/Census/CensusColumnConditionFrenchFemmeTest.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 CensusColumnConditionFrenchFemme
31 */
32class CensusColumnConditionFrenchFemmeTest extends TestCase
33{
34    /**
35     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
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 CensusColumnConditionFrenchFemme($census, '', '');
49
50        self::assertSame('', $column->generate($individual, $individual));
51    }
52
53    /**
54     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
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 CensusColumnConditionFrenchFemme($census, '', '');
68
69        self::assertSame('', $column->generate($individual, $individual));
70    }
71
72    /**
73     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
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 CensusColumnConditionFrenchFemme($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\CensusColumnConditionFrenchFemme
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 CensusColumnConditionFrenchFemme($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\CensusColumnConditionFrenchFemme
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
131            ->expects(self::exactly(2))
132            ->method('facts')
133            ->with(self::withConsecutive([['MARR'], ['DIV']]))
134            ->willReturnOnConsecutiveCalls(
135                new Collection([$fact]),
136                new Collection()
137            );
138        $family->expects(self::once())->method('spouse')->willReturn($spouse);
139
140        $individual = $this->createMock(Individual::class);
141        $individual->method('sex')->willReturn('M');
142        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
143
144        $census = $this->createMock(CensusInterface::class);
145
146        $column = new CensusColumnConditionFrenchFemme($census, '', '');
147        $census->method('censusDate')->willReturn('30 JUN 1830');
148
149        self::assertSame('', $column->generate($individual, $individual));
150    }
151
152    /**
153     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
154     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
155     */
156    public function testSpouseDeadFemale(): void
157    {
158        $fact = $this->createMock(Fact::class);
159
160        $spouse = $this->createMock(Individual::class);
161        $spouse->method('getDeathDate')->willReturn(new Date('1820'));
162
163        $family = $this->createMock(Family::class);
164        $family
165            ->expects(self::exactly(2))
166            ->method('facts')
167            ->with(self::withConsecutive([['MARR'], ['DIV']]))
168            ->willReturnOnConsecutiveCalls(
169                new Collection([$fact]),
170                new Collection()
171            );
172        $family->expects(self::once())->method('spouse')->willReturn($spouse);
173
174        $individual = $this->createMock(Individual::class);
175        $individual->method('sex')->willReturn('F');
176        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
177
178        $census = $this->createMock(CensusInterface::class);
179
180        $column = new CensusColumnConditionFrenchFemme($census, '', '');
181        $census->method('censusDate')->willReturn('30 JUN 1830');
182
183        self::assertSame('', $column->generate($individual, $individual));
184    }
185
186    /**
187     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
188     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
189     */
190    public function testNoFamilyUnmarriedMale(): void
191    {
192        $family = $this->createMock(Family::class);
193        $family->method('getMarriageDate')->willReturn(new Date(''));
194        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
195
196        $individual = $this->createMock(Individual::class);
197        $individual->method('sex')->willReturn('M');
198        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
199        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
200
201        $census = $this->createMock(CensusInterface::class);
202        $census->method('censusDate')->willReturn('30 JUN 1830');
203
204        $column = new CensusColumnConditionFrenchFemme($census, '', '');
205
206        self::assertSame('', $column->generate($individual, $individual));
207    }
208
209    /**
210     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
211     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
212     */
213    public function testNoFamilyUnmarriedFemale(): void
214    {
215        $family = $this->createMock(Family::class);
216        $family->method('getMarriageDate')->willReturn(new Date(''));
217        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
218
219        $individual = $this->createMock(Individual::class);
220        $individual->method('sex')->willReturn('F');
221        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
222        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
223
224        $census = $this->createMock(CensusInterface::class);
225        $census->method('censusDate')->willReturn('30 JUN 1830');
226
227        $column = new CensusColumnConditionFrenchFemme($census, '', '');
228
229        self::assertSame('', $column->generate($individual, $individual));
230    }
231
232    /**
233     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
234     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
235     */
236    public function testChildMale(): void
237    {
238        $family = $this->createMock(Family::class);
239        $family->method('getMarriageDate')->willReturn(new Date(''));
240        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
241
242        $individual = $this->createMock(Individual::class);
243        $individual->method('sex')->willReturn('M');
244        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
245        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
246
247        $census = $this->createMock(CensusInterface::class);
248        $census->method('censusDate')->willReturn('30 JUN 1830');
249
250        $column = new CensusColumnConditionFrenchFemme($census, '', '');
251
252        self::assertSame('', $column->generate($individual, $individual));
253    }
254
255    /**
256     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
257     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
258     */
259    public function testChildFemale(): void
260    {
261        $family = $this->createMock(Family::class);
262        $family->method('getMarriageDate')->willReturn(new Date(''));
263        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
264
265        $individual = $this->createMock(Individual::class);
266        $individual->method('sex')->willReturn('F');
267        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
268        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
269
270        $census = $this->createMock(CensusInterface::class);
271        $census->method('censusDate')->willReturn('30 JUN 1830');
272
273        $column = new CensusColumnConditionFrenchFemme($census, '', '');
274
275        self::assertSame('', $column->generate($individual, $individual));
276    }
277
278    /**
279     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
280     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
281     */
282    public function testDivorcedMale(): void
283    {
284        $fact = $this->createMock(Fact::class);
285
286        $family = $this->createMock(Family::class);
287        $family
288            ->expects(self::exactly(2))
289            ->method('facts')
290            ->with(self::withConsecutive([['MARR'], ['DIV']]))
291            ->willReturn(
292                new Collection([$fact]),
293                new Collection([$fact])
294            );
295
296        $individual = $this->createMock(Individual::class);
297        $individual->method('sex')->willReturn('M');
298        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
299
300        $census = $this->createMock(CensusInterface::class);
301
302        $column = new CensusColumnConditionFrenchFemme($census, '', '');
303        $census->method('censusDate')->willReturn('30 JUN 1830');
304
305        self::assertSame('', $column->generate($individual, $individual));
306    }
307
308    /**
309     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme
310     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
311     */
312    public function testDivorcedFemale(): void
313    {
314        $fact = $this->createMock(Fact::class);
315
316        $family = $this->createMock(Family::class);
317        $family
318            ->expects(self::exactly(2))
319            ->method('facts')
320            ->with(self::withConsecutive([['MARR'], ['DIV']]))
321            ->willReturn(
322                new Collection([$fact]),
323                new Collection([$fact])
324            );
325
326        $individual = $this->createMock(Individual::class);
327        $individual->method('sex')->willReturn('F');
328        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
329
330        $census = $this->createMock(CensusInterface::class);
331
332        $column = new CensusColumnConditionFrenchFemme($census, '', '');
333        $census->method('censusDate')->willReturn('30 JUN 1830');
334
335        self::assertSame('1', $column->generate($individual, $individual));
336    }
337}
338