100225b98SGreg Roach<?php 23976b470SGreg Roach 300225b98SGreg Roach/** 400225b98SGreg Roach * webtrees: online genealogy 55e933c21SGreg Roach * Copyright (C) 2020 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 1500225b98SGreg Roach * along with this program. If not, see <http://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 CensusColumnConditionFrenchVeuve 3100225b98SGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnConditionFrenchVeuveTest extends TestCase 33c1010edaSGreg Roach{ 3400225b98SGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 3900225b98SGreg Roach */ 409b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 41c1010edaSGreg Roach { 425e933c21SGreg Roach $individual = self::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 475e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4900225b98SGreg Roach 5000225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 5100225b98SGreg Roach 525e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 5300225b98SGreg Roach } 5400225b98SGreg Roach 5500225b98SGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 5715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5852348eb8SGreg Roach * 5952348eb8SGreg Roach * @return void 6000225b98SGreg Roach */ 619b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 62c1010edaSGreg Roach { 635e933c21SGreg Roach $individual = self::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 685e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 7000225b98SGreg Roach 7100225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 7200225b98SGreg Roach 735e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 7400225b98SGreg Roach } 7500225b98SGreg Roach 7600225b98SGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 7815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7952348eb8SGreg Roach * 8052348eb8SGreg Roach * @return void 8100225b98SGreg Roach */ 829b802b22SGreg Roach public function testNoFamilyFactsMale(): void 83c1010edaSGreg Roach { 845e933c21SGreg Roach $family = self::createMock(Family::class); 850ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 860ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8700225b98SGreg Roach 885e933c21SGreg Roach $individual = self::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 935e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 9400225b98SGreg Roach 9500225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($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\CensusColumnConditionFrenchVeuve 10315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10452348eb8SGreg Roach * 10552348eb8SGreg Roach * @return void 10600225b98SGreg Roach */ 1079b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 108c1010edaSGreg Roach { 1095e933c21SGreg Roach $family = self::createMock(Family::class); 1100ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1110ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 11200225b98SGreg Roach 1135e933c21SGreg Roach $individual = self::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 1185e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 11900225b98SGreg Roach 12000225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($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\CensusColumnConditionFrenchVeuve 12815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12952348eb8SGreg Roach * 13052348eb8SGreg Roach * @return void 13100225b98SGreg Roach */ 1329b802b22SGreg Roach public function testSpouseDeadMale(): void 133c1010edaSGreg Roach { 1345e933c21SGreg Roach $fact = self::createMock(Fact::class); 1352a6fda60SGreg Roach 1365e933c21SGreg Roach $spouse = self::createMock(Individual::class); 1370ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 138e76c0cf0SGreg Roach 1395e933c21SGreg Roach $family = self::createMock(Family::class); 140*109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 141*109b3e30SGreg Roach $family 142*109b3e30SGreg Roach ->expects(self::exactly(2)) 143*109b3e30SGreg Roach ->method('facts') 144*109b3e30SGreg Roach ->withConsecutive( 145*109b3e30SGreg Roach [['MARR']], 146*109b3e30SGreg Roach [['DIV']] 147*109b3e30SGreg Roach ) 148*109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 149*109b3e30SGreg Roach new Collection([$fact]), 150*109b3e30SGreg Roach new Collection() 151*109b3e30SGreg Roach ); 152*109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 153e76c0cf0SGreg Roach 1545e933c21SGreg Roach $individual = self::createMock(Individual::class); 1550ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1560ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 157e76c0cf0SGreg Roach 1585e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 159e76c0cf0SGreg Roach 160e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 1610ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 162e76c0cf0SGreg Roach 1635e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 164e76c0cf0SGreg Roach } 165e76c0cf0SGreg Roach 166e76c0cf0SGreg Roach /** 16715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 16815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16952348eb8SGreg Roach * 17052348eb8SGreg Roach * @return void 171e76c0cf0SGreg Roach */ 1729b802b22SGreg Roach public function testSpouseDeadFemale(): void 173c1010edaSGreg Roach { 1745e933c21SGreg Roach $fact = self::createMock(Fact::class); 1752a6fda60SGreg Roach 1765e933c21SGreg Roach $spouse = self::createMock(Individual::class); 1770ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 178e76c0cf0SGreg Roach 1795e933c21SGreg Roach $family = self::createMock(Family::class); 180*109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 181*109b3e30SGreg Roach $family 182*109b3e30SGreg Roach ->expects(self::exactly(2)) 183*109b3e30SGreg Roach ->method('facts') 184*109b3e30SGreg Roach ->withConsecutive( 185*109b3e30SGreg Roach [['MARR']], 186*109b3e30SGreg Roach [['DIV']] 187*109b3e30SGreg Roach ) 188*109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 189*109b3e30SGreg Roach new Collection([$fact]), 190*109b3e30SGreg Roach new Collection() 191*109b3e30SGreg Roach ); 192*109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 193e76c0cf0SGreg Roach 1945e933c21SGreg Roach $individual = self::createMock(Individual::class); 1950ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1960ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 197e76c0cf0SGreg Roach 1985e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 199e76c0cf0SGreg Roach 200e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 2010ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 202e76c0cf0SGreg Roach 2035e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 204e76c0cf0SGreg Roach } 205e76c0cf0SGreg Roach 206e76c0cf0SGreg Roach /** 20715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 20815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20952348eb8SGreg Roach * 21052348eb8SGreg Roach * @return void 211e76c0cf0SGreg Roach */ 2129b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 213c1010edaSGreg Roach { 2145e933c21SGreg Roach $family = self::createMock(Family::class); 2150ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2160ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 21700225b98SGreg Roach 2185e933c21SGreg Roach $individual = self::createMock(Individual::class); 2190ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2200ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2210ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22200225b98SGreg Roach 2235e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2240ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 22500225b98SGreg Roach 22600225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 22700225b98SGreg Roach 2285e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 22900225b98SGreg Roach } 23000225b98SGreg Roach 23100225b98SGreg Roach /** 23215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 23315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 23452348eb8SGreg Roach * 23552348eb8SGreg Roach * @return void 23600225b98SGreg Roach */ 2379b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 238c1010edaSGreg Roach { 2395e933c21SGreg Roach $family = self::createMock(Family::class); 2400ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2410ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24200225b98SGreg Roach 2435e933c21SGreg Roach $individual = self::createMock(Individual::class); 2440ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2450ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2460ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 24700225b98SGreg Roach 2485e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2490ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 25000225b98SGreg Roach 25100225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 25200225b98SGreg Roach 2535e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 25400225b98SGreg Roach } 25500225b98SGreg Roach 25600225b98SGreg Roach /** 25715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 25815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 25952348eb8SGreg Roach * 26052348eb8SGreg Roach * @return void 26100225b98SGreg Roach */ 2629b802b22SGreg Roach public function testChildMale(): void 263c1010edaSGreg Roach { 2645e933c21SGreg Roach $family = self::createMock(Family::class); 2650ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2660ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 26700225b98SGreg Roach 2685e933c21SGreg Roach $individual = self::createMock(Individual::class); 2690ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2700ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2710ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27200225b98SGreg Roach 2735e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2740ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 27500225b98SGreg Roach 27600225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 27700225b98SGreg Roach 2785e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 27900225b98SGreg Roach } 28000225b98SGreg Roach 28100225b98SGreg Roach /** 28215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 28315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 28452348eb8SGreg Roach * 28552348eb8SGreg Roach * @return void 28600225b98SGreg Roach */ 2879b802b22SGreg Roach public function testChildFemale(): void 288c1010edaSGreg Roach { 2895e933c21SGreg Roach $family = self::createMock(Family::class); 2900ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2910ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 29200225b98SGreg Roach 2935e933c21SGreg Roach $individual = self::createMock(Individual::class); 2940ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2950ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2960ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 29700225b98SGreg Roach 2985e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2990ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 30000225b98SGreg Roach 30100225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 30200225b98SGreg Roach 3035e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 30400225b98SGreg Roach } 30500225b98SGreg Roach 30600225b98SGreg Roach /** 30715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 30815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 30952348eb8SGreg Roach * 31052348eb8SGreg Roach * @return void 31100225b98SGreg Roach */ 3129b802b22SGreg Roach public function testDivorcedMale(): void 313c1010edaSGreg Roach { 3145e933c21SGreg Roach $fact = self::createMock(Fact::class); 31500225b98SGreg Roach 3165e933c21SGreg Roach $family = self::createMock(Family::class); 317*109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 318*109b3e30SGreg Roach $family 319*109b3e30SGreg Roach ->expects(self::exactly(2)) 320*109b3e30SGreg Roach ->method('facts') 321*109b3e30SGreg Roach ->withConsecutive( 322*109b3e30SGreg Roach [['MARR']], 323*109b3e30SGreg Roach [['DIV']]) 324*109b3e30SGreg Roach ->willReturn( 325*109b3e30SGreg Roach new Collection([$fact]), 326*109b3e30SGreg Roach new Collection([$fact]) 327*109b3e30SGreg Roach ); 32800225b98SGreg Roach 3295e933c21SGreg Roach $individual = self::createMock(Individual::class); 3300ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3310ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33200225b98SGreg Roach 3335e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 33400225b98SGreg Roach 33500225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 3360ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33700225b98SGreg Roach 3385e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 33900225b98SGreg Roach } 34000225b98SGreg Roach 34100225b98SGreg Roach /** 34215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 34315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 34452348eb8SGreg Roach * 34552348eb8SGreg Roach * @return void 34600225b98SGreg Roach */ 3479b802b22SGreg Roach public function testDivorcedFemale(): void 348c1010edaSGreg Roach { 3495e933c21SGreg Roach $fact = self::createMock(Fact::class); 35000225b98SGreg Roach 3515e933c21SGreg Roach $family = self::createMock(Family::class); 352*109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 353*109b3e30SGreg Roach $family 354*109b3e30SGreg Roach ->expects(self::exactly(2)) 355*109b3e30SGreg Roach ->method('facts') 356*109b3e30SGreg Roach ->withConsecutive( 357*109b3e30SGreg Roach [['MARR']], 358*109b3e30SGreg Roach [['DIV']]) 359*109b3e30SGreg Roach ->willReturn( 360*109b3e30SGreg Roach new Collection([$fact]), 361*109b3e30SGreg Roach new Collection([$fact]) 362*109b3e30SGreg Roach ); 36300225b98SGreg Roach 3645e933c21SGreg Roach $individual = self::createMock(Individual::class); 3650ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3660ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 36700225b98SGreg Roach 3685e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 36900225b98SGreg Roach 37000225b98SGreg Roach $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 3710ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 37200225b98SGreg Roach 3735e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 37400225b98SGreg Roach } 37500225b98SGreg Roach} 376