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(CensusColumnConditionFrenchVeuve::class)] 31202c018bSGreg Roach#[CoversClass(AbstractCensusColumnCondition::class)] 323cfcc809SGreg Roachclass CensusColumnConditionFrenchVeuveTest 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 CensusColumnConditionFrenchVeuve($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 CensusColumnConditionFrenchVeuve($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 CensusColumnConditionFrenchVeuve($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 CensusColumnConditionFrenchVeuve($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); 110*00ef1d3aSGreg Roach $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); 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 ); 119*00ef1d3aSGreg Roach $family->expects($this->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 CensusColumnConditionFrenchVeuve($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); 141*00ef1d3aSGreg Roach $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); 142109b3e30SGreg Roach $family 143109b3e30SGreg Roach ->expects(self::exactly(2)) 144109b3e30SGreg Roach ->method('facts') 1459aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 146109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 147109b3e30SGreg Roach new Collection([$fact]), 148109b3e30SGreg Roach new Collection() 149109b3e30SGreg Roach ); 150*00ef1d3aSGreg Roach $family->expects($this->once())->method('spouse')->willReturn($spouse); 151e76c0cf0SGreg Roach 152cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1530ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1540ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 155e76c0cf0SGreg Roach 156cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 157e76c0cf0SGreg Roach 158e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 1590ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 160e76c0cf0SGreg Roach 1615e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 162e76c0cf0SGreg Roach } 163e76c0cf0SGreg Roach 1649b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 165c1010edaSGreg Roach { 166cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1670ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1680ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 16900225b98SGreg Roach 170cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1710ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1720ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1730ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 17400225b98SGreg Roach 175cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 1760ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 17700225b98SGreg Roach 17800225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 17900225b98SGreg Roach 1805e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 18100225b98SGreg Roach } 18200225b98SGreg Roach 1839b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 184c1010edaSGreg Roach { 185cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1860ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1870ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 18800225b98SGreg Roach 189cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1900ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1910ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1920ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 19300225b98SGreg Roach 194cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 1950ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 19600225b98SGreg Roach 19700225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 19800225b98SGreg Roach 1995e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 20000225b98SGreg Roach } 20100225b98SGreg Roach 2029b802b22SGreg Roach public function testChildMale(): void 203c1010edaSGreg Roach { 204cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2050ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2060ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 20700225b98SGreg Roach 208cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2090ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2100ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2110ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 21200225b98SGreg Roach 213cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2140ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 21500225b98SGreg Roach 21600225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 21700225b98SGreg Roach 2185e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 21900225b98SGreg Roach } 22000225b98SGreg Roach 2219b802b22SGreg Roach public function testChildFemale(): void 222c1010edaSGreg Roach { 223cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2240ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2250ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 22600225b98SGreg Roach 227cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2280ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2290ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2300ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 23100225b98SGreg Roach 232cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2330ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 23400225b98SGreg Roach 23500225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 23600225b98SGreg Roach 2375e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 23800225b98SGreg Roach } 23900225b98SGreg Roach 2409b802b22SGreg Roach public function testDivorcedMale(): void 241c1010edaSGreg Roach { 242cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 24300225b98SGreg Roach 244cd94ca66SGreg Roach $family = $this->createMock(Family::class); 245*00ef1d3aSGreg Roach $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); 246109b3e30SGreg Roach $family 247109b3e30SGreg Roach ->expects(self::exactly(2)) 248109b3e30SGreg Roach ->method('facts') 2499aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 250109b3e30SGreg Roach ->willReturn( 251109b3e30SGreg Roach new Collection([$fact]), 252109b3e30SGreg Roach new Collection([$fact]) 253109b3e30SGreg Roach ); 25400225b98SGreg Roach 255cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2560ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2570ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 25800225b98SGreg Roach 259cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 26000225b98SGreg Roach 26100225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 2620ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 26300225b98SGreg Roach 2645e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 26500225b98SGreg Roach } 26600225b98SGreg Roach 2679b802b22SGreg Roach public function testDivorcedFemale(): void 268c1010edaSGreg Roach { 269cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 27000225b98SGreg Roach 271cd94ca66SGreg Roach $family = $this->createMock(Family::class); 272*00ef1d3aSGreg Roach $family->expects($this->once())->method('getMarriageDate')->willReturn(new Date('')); 273109b3e30SGreg Roach $family 274109b3e30SGreg Roach ->expects(self::exactly(2)) 275109b3e30SGreg Roach ->method('facts') 2769aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 277109b3e30SGreg Roach ->willReturn( 278109b3e30SGreg Roach new Collection([$fact]), 279109b3e30SGreg Roach new Collection([$fact]) 280109b3e30SGreg Roach ); 28100225b98SGreg Roach 282cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2830ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2840ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 28500225b98SGreg Roach 286cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 28700225b98SGreg Roach 28800225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 2890ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 29000225b98SGreg Roach 2915e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 29200225b98SGreg Roach } 29300225b98SGreg Roach} 294