xref: /webtrees/tests/app/Census/CensusColumnConditionFrenchFilleTest.php (revision b11cdcd45131b1585d66693fab363cfeb18c51a4)
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 CensusColumnConditionFrenchFille
31 */
32class CensusColumnConditionFrenchFilleTest extends TestCase
33{
34    /**
35     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
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 CensusColumnConditionFrenchFille($census, '', '');
51
52        self::assertSame('', $column->generate($individual, $individual));
53    }
54
55    /**
56     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
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 CensusColumnConditionFrenchFille($census, '', '');
72
73        self::assertSame('1', $column->generate($individual, $individual));
74    }
75
76    /**
77     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
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 CensusColumnConditionFrenchFille($census, '', '');
96        $census->method('censusDate')->willReturn('30 JUN 1830');
97
98        self::assertSame('', $column->generate($individual, $individual));
99    }
100
101    /**
102     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
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 CensusColumnConditionFrenchFille($census, '', '');
121        $census->method('censusDate')->willReturn('30 JUN 1830');
122
123        self::assertSame('1', $column->generate($individual, $individual));
124    }
125
126    /**
127     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
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
141            ->expects(self::exactly(2))
142            ->method('facts')
143            ->withConsecutive(
144                [['MARR']],
145                [['DIV']]
146            )
147            ->willReturnOnConsecutiveCalls(
148                new Collection([$fact]),
149                new Collection()
150            );
151        $family->expects(self::once())->method('spouse')->willReturn($spouse);
152
153        $individual = $this->createMock(Individual::class);
154        $individual->method('sex')->willReturn('M');
155        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
156
157        $census = $this->createMock(CensusInterface::class);
158
159        $column = new CensusColumnConditionFrenchFille($census, '', '');
160        $census->method('censusDate')->willReturn('30 JUN 1830');
161
162        self::assertSame('', $column->generate($individual, $individual));
163    }
164
165    /**
166     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
167     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
168     *
169     * @return void
170     */
171    public function testSpouseDeadFemale(): void
172    {
173        $fact = $this->createMock(Fact::class);
174
175        $spouse = $this->createMock(Individual::class);
176        $spouse->method('getDeathDate')->willReturn(new Date('1820'));
177
178        $family = $this->createMock(Family::class);
179        $family
180            ->expects(self::exactly(2))
181            ->method('facts')
182            ->withConsecutive(
183                [['MARR']],
184                [['DIV']]
185            )
186            ->willReturnOnConsecutiveCalls(
187                new Collection([$fact]),
188                new Collection()
189            );
190        $family->expects(self::once())->method('spouse')->willReturn($spouse);
191
192        $individual = $this->createMock(Individual::class);
193        $individual->method('sex')->willReturn('F');
194        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
195
196        $census = $this->createMock(CensusInterface::class);
197
198        $column = new CensusColumnConditionFrenchFille($census, '', '');
199        $census->method('censusDate')->willReturn('30 JUN 1830');
200
201        self::assertSame('', $column->generate($individual, $individual));
202    }
203
204    /**
205     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
206     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
207     *
208     * @return void
209     */
210    public function testNoFamilyUnmarriedMale(): void
211    {
212        $family = $this->createMock(Family::class);
213        $family->method('getMarriageDate')->willReturn(new Date(''));
214        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
215
216        $individual = $this->createMock(Individual::class);
217        $individual->method('sex')->willReturn('M');
218        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
219        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
220
221        $census = $this->createMock(CensusInterface::class);
222        $census->method('censusDate')->willReturn('30 JUN 1830');
223
224        $column = new CensusColumnConditionFrenchFille($census, '', '');
225
226        self::assertSame('', $column->generate($individual, $individual));
227    }
228
229    /**
230     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
231     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
232     *
233     * @return void
234     */
235    public function testNoFamilyUnmarriedFemale(): void
236    {
237        $family = $this->createMock(Family::class);
238        $family->method('getMarriageDate')->willReturn(new Date(''));
239        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
240
241        $individual = $this->createMock(Individual::class);
242        $individual->method('sex')->willReturn('F');
243        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
244        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
245
246        $census = $this->createMock(CensusInterface::class);
247        $census->method('censusDate')->willReturn('30 JUN 1830');
248
249        $column = new CensusColumnConditionFrenchFille($census, '', '');
250
251        self::assertSame('1', $column->generate($individual, $individual));
252    }
253
254    /**
255     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
256     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
257     *
258     * @return void
259     */
260    public function testChildMale(): void
261    {
262        $family = $this->createMock(Family::class);
263        $family->method('getMarriageDate')->willReturn(new Date(''));
264        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
265
266        $individual = $this->createMock(Individual::class);
267        $individual->method('sex')->willReturn('M');
268        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
269        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
270
271        $census = $this->createMock(CensusInterface::class);
272        $census->method('censusDate')->willReturn('30 JUN 1830');
273
274        $column = new CensusColumnConditionFrenchFille($census, '', '');
275
276        self::assertSame('', $column->generate($individual, $individual));
277    }
278
279    /**
280     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
281     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
282     *
283     * @return void
284     */
285    public function testChildFemale(): void
286    {
287        $family = $this->createMock(Family::class);
288        $family->method('getMarriageDate')->willReturn(new Date(''));
289        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
290
291        $individual = $this->createMock(Individual::class);
292        $individual->method('sex')->willReturn('F');
293        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
294        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
295
296        $census = $this->createMock(CensusInterface::class);
297        $census->method('censusDate')->willReturn('30 JUN 1830');
298
299        $column = new CensusColumnConditionFrenchFille($census, '', '');
300
301        self::assertSame('1', $column->generate($individual, $individual));
302    }
303
304    /**
305     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
306     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
307     *
308     * @return void
309     */
310    public function testDivorcedMale(): void
311    {
312        $fact = $this->createMock(Fact::class);
313
314        $family = $this->createMock(Family::class);
315        $family
316            ->expects(self::exactly(2))
317            ->method('facts')
318            ->withConsecutive(
319                [['MARR']],
320                [['DIV']]
321            )
322            ->willReturn(
323                new Collection([$fact]),
324                new Collection([$fact])
325            );
326
327        $individual = $this->createMock(Individual::class);
328        $individual->method('sex')->willReturn('M');
329        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
330
331        $census = $this->createMock(CensusInterface::class);
332
333        $column = new CensusColumnConditionFrenchFille($census, '', '');
334        $census->method('censusDate')->willReturn('30 JUN 1830');
335
336        self::assertSame('', $column->generate($individual, $individual));
337    }
338
339    /**
340     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFille
341     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
342     *
343     * @return void
344     */
345    public function testDivorcedFemale(): void
346    {
347        $fact = $this->createMock(Fact::class);
348
349        $family = $this->createMock(Family::class);
350        $family
351            ->expects(self::exactly(2))
352            ->method('facts')
353            ->withConsecutive(
354                [['MARR']],
355                [['DIV']]
356            )
357            ->willReturn(
358                new Collection([$fact]),
359                new Collection([$fact])
360            );
361
362        $individual = $this->createMock(Individual::class);
363        $individual->method('sex')->willReturn('F');
364        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
365
366        $census = $this->createMock(CensusInterface::class);
367
368        $column = new CensusColumnConditionFrenchFille($census, '', '');
369        $census->method('censusDate')->willReturn('30 JUN 1830');
370
371        self::assertSame('', $column->generate($individual, $individual));
372    }
373}
374