100225b98SGreg Roach<?php 23976b470SGreg Roach 300225b98SGreg Roach/** 400225b98SGreg Roach * webtrees: online genealogy 5*d11be702SGreg 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; 2800225b98SGreg Roach 2900225b98SGreg Roach/** 3000225b98SGreg Roach * Test harness for the class CensusColumnConditionFrenchFemme 3100225b98SGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnConditionFrenchFemmeTest extends TestCase 33c1010edaSGreg Roach{ 3400225b98SGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 3900225b98SGreg Roach */ 409b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 41c1010edaSGreg Roach { 42cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 430ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 440ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 450ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 4600225b98SGreg Roach 47cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4900225b98SGreg Roach 5000225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 5100225b98SGreg Roach 525e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 5300225b98SGreg Roach } 5400225b98SGreg Roach 5500225b98SGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 5715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5852348eb8SGreg Roach * 5952348eb8SGreg Roach * @return void 6000225b98SGreg Roach */ 619b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 62c1010edaSGreg Roach { 63cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 640ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 650ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 660ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 6700225b98SGreg Roach 68cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 7000225b98SGreg Roach 7100225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 7200225b98SGreg Roach 735e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 7400225b98SGreg Roach } 7500225b98SGreg Roach 7600225b98SGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 7815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7952348eb8SGreg Roach * 8052348eb8SGreg Roach * @return void 8100225b98SGreg Roach */ 829b802b22SGreg Roach public function testNoFamilyFactsMale(): void 83c1010edaSGreg Roach { 84cd94ca66SGreg Roach $family = $this->createMock(Family::class); 850ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 860ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8700225b98SGreg Roach 88cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 890ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 900ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 910ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 9200225b98SGreg Roach 93cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 9400225b98SGreg Roach 9500225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 960ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9700225b98SGreg Roach 985e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 9900225b98SGreg Roach } 10000225b98SGreg Roach 10100225b98SGreg Roach /** 10215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 10315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10452348eb8SGreg Roach * 10552348eb8SGreg Roach * @return void 10600225b98SGreg Roach */ 1079b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 108c1010edaSGreg Roach { 109cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1100ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1110ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 11200225b98SGreg Roach 113cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1140ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1150ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 1160ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 11700225b98SGreg Roach 118cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 11900225b98SGreg Roach 12000225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 1210ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 12200225b98SGreg Roach 1235e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 12400225b98SGreg Roach } 12500225b98SGreg Roach 12600225b98SGreg Roach /** 12715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 12815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12952348eb8SGreg Roach * 13052348eb8SGreg Roach * @return void 13100225b98SGreg Roach */ 1329b802b22SGreg Roach public function testSpouseDeadMale(): 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') 143109b3e30SGreg Roach ->withConsecutive( 144109b3e30SGreg Roach [['MARR']], 145109b3e30SGreg Roach [['DIV']] 146109b3e30SGreg Roach ) 147109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 148109b3e30SGreg Roach new Collection([$fact]), 149109b3e30SGreg Roach new Collection() 150109b3e30SGreg Roach ); 151109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 152e76c0cf0SGreg Roach 153cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1540ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1550ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 156e76c0cf0SGreg Roach 157cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 158e76c0cf0SGreg Roach 159e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 1600ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 161e76c0cf0SGreg Roach 1625e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 163e76c0cf0SGreg Roach } 164e76c0cf0SGreg Roach 165e76c0cf0SGreg Roach /** 16615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 16715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16852348eb8SGreg Roach * 16952348eb8SGreg Roach * @return void 170e76c0cf0SGreg Roach */ 1719b802b22SGreg Roach public function testSpouseDeadFemale(): void 172c1010edaSGreg Roach { 173cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1742a6fda60SGreg Roach 175cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1760ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 177e76c0cf0SGreg Roach 178cd94ca66SGreg Roach $family = $this->createMock(Family::class); 179109b3e30SGreg Roach $family 180109b3e30SGreg Roach ->expects(self::exactly(2)) 181109b3e30SGreg Roach ->method('facts') 182109b3e30SGreg Roach ->withConsecutive( 183109b3e30SGreg Roach [['MARR']], 184109b3e30SGreg Roach [['DIV']] 185109b3e30SGreg Roach ) 186109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 187109b3e30SGreg Roach new Collection([$fact]), 188109b3e30SGreg Roach new Collection() 189109b3e30SGreg Roach ); 190109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 191e76c0cf0SGreg Roach 192cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1930ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1940ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 195e76c0cf0SGreg Roach 196cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 197e76c0cf0SGreg Roach 198e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 1990ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 200e76c0cf0SGreg Roach 2015e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 202e76c0cf0SGreg Roach } 203e76c0cf0SGreg Roach 204e76c0cf0SGreg Roach /** 20515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 20615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20752348eb8SGreg Roach * 20852348eb8SGreg Roach * @return void 209e76c0cf0SGreg Roach */ 2109b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 211c1010edaSGreg Roach { 212cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2130ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2140ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 21500225b98SGreg Roach 216cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2170ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2180ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2190ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22000225b98SGreg Roach 221cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2220ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 22300225b98SGreg Roach 22400225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 22500225b98SGreg Roach 2265e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 22700225b98SGreg Roach } 22800225b98SGreg Roach 22900225b98SGreg Roach /** 23015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 23115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 23252348eb8SGreg Roach * 23352348eb8SGreg Roach * @return void 23400225b98SGreg Roach */ 2359b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 236c1010edaSGreg Roach { 237cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2380ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2390ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24000225b98SGreg Roach 241cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2420ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2430ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2440ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 24500225b98SGreg Roach 246cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2470ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 24800225b98SGreg Roach 24900225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 25000225b98SGreg Roach 2515e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 25200225b98SGreg Roach } 25300225b98SGreg Roach 25400225b98SGreg Roach /** 25515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 25615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 25752348eb8SGreg Roach * 25852348eb8SGreg Roach * @return void 25900225b98SGreg Roach */ 2609b802b22SGreg Roach public function testChildMale(): void 261c1010edaSGreg Roach { 262cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2630ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2640ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 26500225b98SGreg Roach 266cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2670ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2680ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2690ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27000225b98SGreg Roach 271cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2720ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 27300225b98SGreg Roach 27400225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 27500225b98SGreg Roach 2765e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 27700225b98SGreg Roach } 27800225b98SGreg Roach 27900225b98SGreg Roach /** 28015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 28115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 28252348eb8SGreg Roach * 28352348eb8SGreg Roach * @return void 28400225b98SGreg Roach */ 2859b802b22SGreg Roach public function testChildFemale(): void 286c1010edaSGreg Roach { 287cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2880ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2890ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 29000225b98SGreg Roach 291cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2920ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2930ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2940ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 29500225b98SGreg Roach 296cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2970ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 29800225b98SGreg Roach 29900225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 30000225b98SGreg Roach 3015e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 30200225b98SGreg Roach } 30300225b98SGreg Roach 30400225b98SGreg Roach /** 30515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 30615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 30752348eb8SGreg Roach * 30852348eb8SGreg Roach * @return void 30900225b98SGreg Roach */ 3109b802b22SGreg Roach public function testDivorcedMale(): void 311c1010edaSGreg Roach { 312cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 31300225b98SGreg Roach 314cd94ca66SGreg Roach $family = $this->createMock(Family::class); 315109b3e30SGreg Roach $family 316109b3e30SGreg Roach ->expects(self::exactly(2)) 317109b3e30SGreg Roach ->method('facts') 318109b3e30SGreg Roach ->withConsecutive( 319109b3e30SGreg Roach [['MARR']], 3202e84ab20SGreg Roach [['DIV']] 3212e84ab20SGreg Roach ) 322109b3e30SGreg Roach ->willReturn( 323109b3e30SGreg Roach new Collection([$fact]), 324109b3e30SGreg Roach new Collection([$fact]) 325109b3e30SGreg Roach ); 32600225b98SGreg Roach 327cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 3280ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3290ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33000225b98SGreg Roach 331cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 33200225b98SGreg Roach 33300225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 3340ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33500225b98SGreg Roach 3365e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 33700225b98SGreg Roach } 33800225b98SGreg Roach 33900225b98SGreg Roach /** 34015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchFemme 34115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 34252348eb8SGreg Roach * 34352348eb8SGreg Roach * @return void 34400225b98SGreg Roach */ 3459b802b22SGreg Roach public function testDivorcedFemale(): void 346c1010edaSGreg Roach { 347cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 34800225b98SGreg Roach 349cd94ca66SGreg Roach $family = $this->createMock(Family::class); 350109b3e30SGreg Roach $family 351109b3e30SGreg Roach ->expects(self::exactly(2)) 352109b3e30SGreg Roach ->method('facts') 353109b3e30SGreg Roach ->withConsecutive( 354109b3e30SGreg Roach [['MARR']], 3552e84ab20SGreg Roach [['DIV']] 3562e84ab20SGreg Roach ) 357109b3e30SGreg Roach ->willReturn( 358109b3e30SGreg Roach new Collection([$fact]), 359109b3e30SGreg Roach new Collection([$fact]) 360109b3e30SGreg Roach ); 36100225b98SGreg Roach 362cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 3630ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3640ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 36500225b98SGreg Roach 366cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 36700225b98SGreg Roach 36800225b98SGreg Roach $column = new CensusColumnConditionFrenchFemme($census, '', ''); 3690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 37000225b98SGreg Roach 3715e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 37200225b98SGreg Roach } 37300225b98SGreg Roach} 374