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; 28*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 2900225b98SGreg Roach 30*202c018bSGreg Roach 31*202c018bSGreg Roach#[CoversClass(CensusColumnConditionFrenchHomme::class)] 32*202c018bSGreg Roach#[CoversClass(AbstractCensusColumnCondition::class)] 333cfcc809SGreg Roachclass CensusColumnConditionFrenchHommeTest extends TestCase 34c1010edaSGreg Roach{ 359b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 36c1010edaSGreg Roach { 37cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 380ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 390ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 400ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 4100225b98SGreg Roach 42cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 430ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4400225b98SGreg Roach 4500225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 4600225b98SGreg Roach 475e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 4800225b98SGreg Roach } 4900225b98SGreg Roach 509b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 51c1010edaSGreg Roach { 52cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 530ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 540ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 550ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 5600225b98SGreg Roach 57cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 580ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 5900225b98SGreg Roach 6000225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 6100225b98SGreg Roach 625e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 6300225b98SGreg Roach } 6400225b98SGreg Roach 659b802b22SGreg Roach public function testNoFamilyFactsMale(): void 66c1010edaSGreg Roach { 67cd94ca66SGreg Roach $family = $this->createMock(Family::class); 680ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 690ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 7000225b98SGreg Roach 71cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 720ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 730ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 740ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 7500225b98SGreg Roach 76cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 7700225b98SGreg Roach 7800225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 790ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 8000225b98SGreg Roach 815e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 8200225b98SGreg Roach } 8300225b98SGreg Roach 849b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 85c1010edaSGreg Roach { 86cd94ca66SGreg Roach $family = $this->createMock(Family::class); 870ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 880ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 89e76c0cf0SGreg Roach 90cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 910ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 920ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 930ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 94e76c0cf0SGreg Roach 95cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 96e76c0cf0SGreg Roach 97e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 980ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 99e76c0cf0SGreg Roach 1005e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 101e76c0cf0SGreg Roach } 102e76c0cf0SGreg Roach 1039b802b22SGreg Roach public function testSpouseDeadMale(): void 104c1010edaSGreg Roach { 105cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1062a6fda60SGreg Roach 107cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1080ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 109e76c0cf0SGreg Roach 110cd94ca66SGreg Roach $family = $this->createMock(Family::class); 111109b3e30SGreg Roach $family 112109b3e30SGreg Roach ->expects(self::exactly(2)) 113109b3e30SGreg Roach ->method('facts') 1149aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 115109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 116109b3e30SGreg Roach new Collection([$fact]), 117109b3e30SGreg Roach new Collection() 118109b3e30SGreg Roach ); 119109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 120e76c0cf0SGreg Roach 121cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1220ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1230ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 124e76c0cf0SGreg Roach 125cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 126e76c0cf0SGreg Roach 127e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 1280ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 129e76c0cf0SGreg Roach 1305e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 131e76c0cf0SGreg Roach } 132e76c0cf0SGreg Roach 1339b802b22SGreg Roach public function testSpouseDeadFemale(): void 134c1010edaSGreg Roach { 135cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1362a6fda60SGreg Roach 137cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1380ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 139e76c0cf0SGreg Roach 140cd94ca66SGreg Roach $family = $this->createMock(Family::class); 141109b3e30SGreg Roach $family 142109b3e30SGreg Roach ->expects(self::exactly(2)) 143109b3e30SGreg Roach ->method('facts') 1449aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 145109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 146109b3e30SGreg Roach new Collection([$fact]), 147109b3e30SGreg Roach new Collection() 148109b3e30SGreg Roach ); 149109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 15000225b98SGreg Roach 151cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1520ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1530ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 15400225b98SGreg Roach 155cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 15600225b98SGreg Roach 15700225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 1580ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 15900225b98SGreg Roach 1605e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 16100225b98SGreg Roach } 16200225b98SGreg Roach 1639b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 164c1010edaSGreg Roach { 165cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1660ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1670ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 16800225b98SGreg Roach 169cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1700ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1710ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1720ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 17300225b98SGreg Roach 174cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 1750ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 17600225b98SGreg Roach 17700225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 17800225b98SGreg Roach 1795e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 18000225b98SGreg Roach } 18100225b98SGreg Roach 1829b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 183c1010edaSGreg Roach { 184cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1850ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1860ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 18700225b98SGreg Roach 188cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1890ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1900ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1910ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 19200225b98SGreg Roach 193cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 1940ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 19500225b98SGreg Roach 19600225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 19700225b98SGreg Roach 1985e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 19900225b98SGreg Roach } 20000225b98SGreg Roach 2019b802b22SGreg Roach public function testChildMale(): void 202c1010edaSGreg Roach { 203cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2040ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2050ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 20600225b98SGreg Roach 207cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2080ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2090ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2100ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 21100225b98SGreg Roach 212cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2130ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 21400225b98SGreg Roach 21500225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 21600225b98SGreg Roach 2175e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 21800225b98SGreg Roach } 21900225b98SGreg Roach 2209b802b22SGreg Roach public function testChildFemale(): void 221c1010edaSGreg Roach { 222cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2230ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2240ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 22500225b98SGreg Roach 226cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2270ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2280ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2290ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 23000225b98SGreg Roach 231cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2320ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 23300225b98SGreg Roach 23400225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 23500225b98SGreg Roach 2365e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 23700225b98SGreg Roach } 23800225b98SGreg Roach 2399b802b22SGreg Roach public function testDivorcedMale(): void 240c1010edaSGreg Roach { 241cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 24200225b98SGreg Roach 243cd94ca66SGreg Roach $family = $this->createMock(Family::class); 244109b3e30SGreg Roach $family 245109b3e30SGreg Roach ->expects(self::exactly(2)) 246109b3e30SGreg Roach ->method('facts') 2479aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 248109b3e30SGreg Roach ->willReturn( 249109b3e30SGreg Roach new Collection([$fact]), 250109b3e30SGreg Roach new Collection([$fact]) 251109b3e30SGreg Roach ); 25200225b98SGreg Roach 253cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2540ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2550ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 25600225b98SGreg Roach 257cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 25800225b98SGreg Roach 25900225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 2600ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 26100225b98SGreg Roach 2625e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 26300225b98SGreg Roach } 26400225b98SGreg Roach 2659b802b22SGreg Roach public function testDivorcedFemale(): void 266c1010edaSGreg Roach { 267cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 26800225b98SGreg Roach 269cd94ca66SGreg Roach $family = $this->createMock(Family::class); 270109b3e30SGreg Roach $family 271109b3e30SGreg Roach ->expects(self::exactly(2)) 272109b3e30SGreg Roach ->method('facts') 2739aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 274109b3e30SGreg Roach ->willReturn( 275109b3e30SGreg Roach new Collection([$fact]), 276109b3e30SGreg Roach new Collection([$fact]) 277109b3e30SGreg Roach ); 27800225b98SGreg Roach 279cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2800ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2810ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 28200225b98SGreg Roach 283cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 28400225b98SGreg Roach 28500225b98SGreg Roach $column = new CensusColumnConditionFrenchHomme($census, '', ''); 2860ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 28700225b98SGreg Roach 2885e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 28900225b98SGreg Roach } 29000225b98SGreg Roach} 291