xref: /webtrees/tests/app/Census/CensusColumnConditionFrenchFemmeTest.php (revision 00ef1d3af59aba99c1ae5c92c7e655525c97797b)
100225b98SGreg Roach<?php
23976b470SGreg Roach
300225b98SGreg Roach/**
400225b98SGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
600225b98SGreg Roach * This program is free software: you can redistribute it and/or modify
700225b98SGreg Roach * it under the terms of the GNU General Public License as published by
800225b98SGreg Roach * the Free Software Foundation, either version 3 of the License, or
900225b98SGreg Roach * (at your option) any later version.
1000225b98SGreg Roach * This program is distributed in the hope that it will be useful,
1100225b98SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1200225b98SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1300225b98SGreg Roach * GNU General Public License for more details.
1400225b98SGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
1600225b98SGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
2000225b98SGreg Roachnamespace Fisharebest\Webtrees\Census;
2100225b98SGreg Roach
2200225b98SGreg Roachuse Fisharebest\Webtrees\Date;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact;
24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
25ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
263cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
2739ca88baSGreg Roachuse Illuminate\Support\Collection;
28202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
2900225b98SGreg Roach
30202c018bSGreg Roach#[CoversClass(CensusColumnConditionFrenchFemme::class)]
31202c018bSGreg Roach#[CoversClass(AbstractCensusColumnCondition::class)]
323cfcc809SGreg Roachclass CensusColumnConditionFrenchFemmeTest extends TestCase
33c1010edaSGreg Roach{
349b802b22SGreg Roach    public function testNoSpouseFamiliesMale(): void
35c1010edaSGreg Roach    {
36cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
370ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
380ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
390ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
4000225b98SGreg Roach
41cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
420ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
4300225b98SGreg Roach
4400225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
4500225b98SGreg Roach
465e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
4700225b98SGreg Roach    }
4800225b98SGreg Roach
499b802b22SGreg Roach    public function testNoSpouseFamiliesFemale(): void
50c1010edaSGreg Roach    {
51cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
520ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
530ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
540ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
5500225b98SGreg Roach
56cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
570ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
5800225b98SGreg Roach
5900225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
6000225b98SGreg Roach
615e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
6200225b98SGreg Roach    }
6300225b98SGreg Roach
649b802b22SGreg Roach    public function testNoFamilyFactsMale(): void
65c1010edaSGreg Roach    {
66cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
670ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
680ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
6900225b98SGreg Roach
70cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
710ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
720ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
730ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
7400225b98SGreg Roach
75cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
7600225b98SGreg Roach
7700225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
780ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
7900225b98SGreg Roach
805e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
8100225b98SGreg Roach    }
8200225b98SGreg Roach
839b802b22SGreg Roach    public function testNoFamilyFactsFemale(): void
84c1010edaSGreg Roach    {
85cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
860ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
870ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
8800225b98SGreg Roach
89cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
900ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
910ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
920ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
9300225b98SGreg Roach
94cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
9500225b98SGreg Roach
9600225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
970ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
9800225b98SGreg Roach
995e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
10000225b98SGreg Roach    }
10100225b98SGreg Roach
1029b802b22SGreg Roach    public function testSpouseDeadMale(): void
103c1010edaSGreg Roach    {
104cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
1052a6fda60SGreg Roach
106cd94ca66SGreg Roach        $spouse = $this->createMock(Individual::class);
1070ecdbde6SGreg Roach        $spouse->method('getDeathDate')->willReturn(new Date('1820'));
108e76c0cf0SGreg Roach
109cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
110109b3e30SGreg Roach        $family
111109b3e30SGreg Roach            ->expects(self::exactly(2))
112109b3e30SGreg Roach            ->method('facts')
1139aef375dSGreg Roach            ->with(self::withConsecutive([['MARR'], ['DIV']]))
114109b3e30SGreg Roach            ->willReturnOnConsecutiveCalls(
115109b3e30SGreg Roach                new Collection([$fact]),
116109b3e30SGreg Roach                new Collection()
117109b3e30SGreg Roach            );
118*00ef1d3aSGreg Roach        $family->expects($this->once())->method('spouse')->willReturn($spouse);
119e76c0cf0SGreg Roach
120cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1210ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
1220ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
123e76c0cf0SGreg Roach
124cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
125e76c0cf0SGreg Roach
126e76c0cf0SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
1270ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
128e76c0cf0SGreg Roach
1295e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
130e76c0cf0SGreg Roach    }
131e76c0cf0SGreg Roach
1329b802b22SGreg Roach    public function testSpouseDeadFemale(): void
133c1010edaSGreg Roach    {
134cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
1352a6fda60SGreg Roach
136cd94ca66SGreg Roach        $spouse = $this->createMock(Individual::class);
1370ecdbde6SGreg Roach        $spouse->method('getDeathDate')->willReturn(new Date('1820'));
138e76c0cf0SGreg Roach
139cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
140109b3e30SGreg Roach        $family
141109b3e30SGreg Roach            ->expects(self::exactly(2))
142109b3e30SGreg Roach            ->method('facts')
1439aef375dSGreg Roach            ->with(self::withConsecutive([['MARR'], ['DIV']]))
144109b3e30SGreg Roach            ->willReturnOnConsecutiveCalls(
145109b3e30SGreg Roach                new Collection([$fact]),
146109b3e30SGreg Roach                new Collection()
147109b3e30SGreg Roach            );
148*00ef1d3aSGreg Roach        $family->expects($this->once())->method('spouse')->willReturn($spouse);
149e76c0cf0SGreg Roach
150cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1510ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
1520ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
153e76c0cf0SGreg Roach
154cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
155e76c0cf0SGreg Roach
156e76c0cf0SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
1570ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
158e76c0cf0SGreg Roach
1595e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
160e76c0cf0SGreg Roach    }
161e76c0cf0SGreg Roach
1629b802b22SGreg Roach    public function testNoFamilyUnmarriedMale(): void
163c1010edaSGreg Roach    {
164cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
1650ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
1660ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
16700225b98SGreg Roach
168cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1690ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
1700ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1710ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
17200225b98SGreg Roach
173cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1740ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
17500225b98SGreg Roach
17600225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
17700225b98SGreg Roach
1785e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
17900225b98SGreg Roach    }
18000225b98SGreg Roach
1819b802b22SGreg Roach    public function testNoFamilyUnmarriedFemale(): void
182c1010edaSGreg Roach    {
183cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
1840ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
1850ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
18600225b98SGreg Roach
187cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1880ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
1890ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1900ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
19100225b98SGreg Roach
192cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1930ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
19400225b98SGreg Roach
19500225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
19600225b98SGreg Roach
1975e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
19800225b98SGreg Roach    }
19900225b98SGreg Roach
2009b802b22SGreg Roach    public function testChildMale(): void
201c1010edaSGreg Roach    {
202cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
2030ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
2040ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
20500225b98SGreg Roach
206cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2070ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
2080ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
2090ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
21000225b98SGreg Roach
211cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2120ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
21300225b98SGreg Roach
21400225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
21500225b98SGreg Roach
2165e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
21700225b98SGreg Roach    }
21800225b98SGreg Roach
2199b802b22SGreg Roach    public function testChildFemale(): void
220c1010edaSGreg Roach    {
221cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
2220ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
2230ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
22400225b98SGreg Roach
225cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2260ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
2270ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
2280ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
22900225b98SGreg Roach
230cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
2310ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
23200225b98SGreg Roach
23300225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
23400225b98SGreg Roach
2355e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
23600225b98SGreg Roach    }
23700225b98SGreg Roach
2389b802b22SGreg Roach    public function testDivorcedMale(): void
239c1010edaSGreg Roach    {
240cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
24100225b98SGreg Roach
242cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
243109b3e30SGreg Roach        $family
244109b3e30SGreg Roach            ->expects(self::exactly(2))
245109b3e30SGreg Roach            ->method('facts')
2469aef375dSGreg Roach            ->with(self::withConsecutive([['MARR'], ['DIV']]))
247109b3e30SGreg Roach            ->willReturn(
248109b3e30SGreg Roach                new Collection([$fact]),
249109b3e30SGreg Roach                new Collection([$fact])
250109b3e30SGreg Roach            );
25100225b98SGreg Roach
252cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2530ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
2540ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
25500225b98SGreg Roach
256cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
25700225b98SGreg Roach
25800225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
2590ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
26000225b98SGreg Roach
2615e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
26200225b98SGreg Roach    }
26300225b98SGreg Roach
2649b802b22SGreg Roach    public function testDivorcedFemale(): void
265c1010edaSGreg Roach    {
266cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
26700225b98SGreg Roach
268cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
269109b3e30SGreg Roach        $family
270109b3e30SGreg Roach            ->expects(self::exactly(2))
271109b3e30SGreg Roach            ->method('facts')
2729aef375dSGreg Roach            ->with(self::withConsecutive([['MARR'], ['DIV']]))
273109b3e30SGreg Roach            ->willReturn(
274109b3e30SGreg Roach                new Collection([$fact]),
275109b3e30SGreg Roach                new Collection([$fact])
276109b3e30SGreg Roach            );
27700225b98SGreg Roach
278cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
2790ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
2800ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
28100225b98SGreg Roach
282cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
28300225b98SGreg Roach
28400225b98SGreg Roach        $column = new CensusColumnConditionFrenchFemme($census, '', '');
2850ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
28600225b98SGreg Roach
2875e933c21SGreg Roach        self::assertSame('1', $column->generate($individual, $individual));
28800225b98SGreg Roach    }
28900225b98SGreg Roach}
290