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