1101af0b4SGreg Roach<?php 23976b470SGreg Roach 3101af0b4SGreg Roach/** 4101af0b4SGreg Roach * webtrees: online genealogy 55e933c21SGreg Roach * Copyright (C) 2020 webtrees development team 6101af0b4SGreg Roach * This program is free software: you can redistribute it and/or modify 7101af0b4SGreg Roach * it under the terms of the GNU General Public License as published by 8101af0b4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9101af0b4SGreg Roach * (at your option) any later version. 10101af0b4SGreg Roach * This program is distributed in the hope that it will be useful, 11101af0b4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12101af0b4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13101af0b4SGreg Roach * GNU General Public License for more details. 14101af0b4SGreg Roach * You should have received a copy of the GNU General Public License 15101af0b4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16101af0b4SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 20101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census; 21101af0b4SGreg Roach 22101af0b4SGreg 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; 28101af0b4SGreg Roach 29101af0b4SGreg Roach/** 3073d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish 31101af0b4SGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnConditionDanishTest extends TestCase 33c1010edaSGreg Roach{ 34101af0b4SGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 39101af0b4SGreg 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')); 46101af0b4SGreg Roach 475e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 49101af0b4SGreg Roach 5073d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 51101af0b4SGreg Roach 525e933c21SGreg Roach self::assertSame('Ugift', $column->generate($individual, $individual)); 5373d4df56SGreg Roach } 5473d4df56SGreg Roach 5573d4df56SGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 5715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5852348eb8SGreg Roach * 5952348eb8SGreg Roach * @return void 6073d4df56SGreg 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 CensusColumnConditionDanish($census, '', ''); 7200225b98SGreg Roach 735e933c21SGreg Roach self::assertSame('Ugift', $column->generate($individual, $individual)); 7400225b98SGreg Roach } 7500225b98SGreg Roach 7600225b98SGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 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()); 8773d4df56SGreg 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'); 9273d4df56SGreg Roach 935e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 9473d4df56SGreg Roach 9573d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 960ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9773d4df56SGreg Roach 985e933c21SGreg Roach self::assertSame('Ugift', $column->generate($individual, $individual)); 9973d4df56SGreg Roach } 10073d4df56SGreg Roach 10173d4df56SGreg Roach /** 10215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 10315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10452348eb8SGreg Roach * 10552348eb8SGreg Roach * @return void 10673d4df56SGreg 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()); 112e76c0cf0SGreg 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'); 117e76c0cf0SGreg Roach 1185e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 119e76c0cf0SGreg Roach 120e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1210ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 122e76c0cf0SGreg Roach 1235e933c21SGreg Roach self::assertSame('Ugift', $column->generate($individual, $individual)); 124e76c0cf0SGreg Roach } 125e76c0cf0SGreg Roach 126e76c0cf0SGreg Roach /** 12715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 12815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12952348eb8SGreg Roach * 13052348eb8SGreg Roach * @return void 131e76c0cf0SGreg 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 141*109b3e30SGreg Roach ->expects(self::exactly(2)) 142*109b3e30SGreg Roach ->method('facts') 143*109b3e30SGreg Roach ->withConsecutive( 144*109b3e30SGreg Roach [['MARR']], 145*109b3e30SGreg Roach [['DIV']] 146*109b3e30SGreg Roach ) 147*109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 148*109b3e30SGreg Roach new Collection([$fact]), 149*109b3e30SGreg Roach new Collection() 150*109b3e30SGreg Roach ); 151*109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 152e76c0cf0SGreg Roach 1535e933c21SGreg Roach $individual = self::createMock(Individual::class); 1540ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1550ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 156e76c0cf0SGreg Roach 1575e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 158e76c0cf0SGreg Roach 159e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1600ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 161e76c0cf0SGreg Roach 1625e933c21SGreg Roach self::assertSame('Gift', $column->generate($individual, $individual)); 163e76c0cf0SGreg Roach } 164e76c0cf0SGreg Roach 165e76c0cf0SGreg Roach /** 16615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 16715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16852348eb8SGreg Roach * 16952348eb8SGreg Roach * @return void 170e76c0cf0SGreg Roach */ 1719b802b22SGreg Roach public function testSpouseDeadFemale(): void 172c1010edaSGreg Roach { 1735e933c21SGreg Roach $fact = self::createMock(Fact::class); 1742a6fda60SGreg Roach 1755e933c21SGreg Roach $spouse = self::createMock(Individual::class); 1760ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 177e76c0cf0SGreg Roach 1785e933c21SGreg Roach $family = self::createMock(Family::class); 179*109b3e30SGreg Roach $family 180*109b3e30SGreg Roach ->expects(self::exactly(2)) 181*109b3e30SGreg Roach ->method('facts') 182*109b3e30SGreg Roach ->withConsecutive( 183*109b3e30SGreg Roach [['MARR']], 184*109b3e30SGreg Roach [['DIV']] 185*109b3e30SGreg Roach ) 186*109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 187*109b3e30SGreg Roach new Collection([$fact]), 188*109b3e30SGreg Roach new Collection() 189*109b3e30SGreg Roach ); 190*109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 19173d4df56SGreg Roach 1925e933c21SGreg Roach $individual = self::createMock(Individual::class); 1930ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1940ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 19573d4df56SGreg Roach 1965e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 19773d4df56SGreg Roach 19873d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1990ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 20073d4df56SGreg Roach 2015e933c21SGreg Roach self::assertSame('Gift', $column->generate($individual, $individual)); 20200225b98SGreg Roach } 20300225b98SGreg Roach 20400225b98SGreg Roach /** 20515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 20615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20752348eb8SGreg Roach * 20852348eb8SGreg Roach * @return void 20900225b98SGreg Roach */ 2109b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 211c1010edaSGreg Roach { 2125e933c21SGreg Roach $family = self::createMock(Family::class); 2130ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2140ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 21500225b98SGreg Roach 2165e933c21SGreg Roach $individual = self::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 2215e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2220ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 22300225b98SGreg Roach 22400225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 22500225b98SGreg Roach 2265e933c21SGreg Roach self::assertSame('Ugift', $column->generate($individual, $individual)); 22773d4df56SGreg Roach } 22873d4df56SGreg Roach 22973d4df56SGreg Roach /** 23015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 23115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 23252348eb8SGreg Roach * 23352348eb8SGreg Roach * @return void 23473d4df56SGreg Roach */ 2359b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 236c1010edaSGreg Roach { 2375e933c21SGreg Roach $family = self::createMock(Family::class); 2380ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2390ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24000225b98SGreg Roach 2415e933c21SGreg Roach $individual = self::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 2465e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2470ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 24800225b98SGreg Roach 24900225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 25000225b98SGreg Roach 2515e933c21SGreg Roach self::assertSame('Ugift', $column->generate($individual, $individual)); 25200225b98SGreg Roach } 25300225b98SGreg Roach 25400225b98SGreg Roach /** 25515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 25615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 25752348eb8SGreg Roach * 25852348eb8SGreg Roach * @return void 25900225b98SGreg Roach */ 2609b802b22SGreg Roach public function testChildMale(): void 261c1010edaSGreg Roach { 2625e933c21SGreg Roach $family = self::createMock(Family::class); 2630ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2640ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 26500225b98SGreg Roach 2665e933c21SGreg Roach $individual = self::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 2715e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2720ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 27300225b98SGreg Roach 27400225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 27500225b98SGreg Roach 2765e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 27700225b98SGreg Roach } 27800225b98SGreg Roach 27900225b98SGreg Roach /** 28015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 28115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 28252348eb8SGreg Roach * 28352348eb8SGreg Roach * @return void 28400225b98SGreg Roach */ 2859b802b22SGreg Roach public function testChildFemale(): void 286c1010edaSGreg Roach { 2875e933c21SGreg Roach $family = self::createMock(Family::class); 2880ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2890ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 29000225b98SGreg Roach 2915e933c21SGreg Roach $individual = self::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 2965e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2970ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 29800225b98SGreg Roach 29900225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 30000225b98SGreg Roach 3015e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 30200225b98SGreg Roach } 30300225b98SGreg Roach 30400225b98SGreg Roach /** 30515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 30615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 30752348eb8SGreg Roach * 30852348eb8SGreg Roach * @return void 30900225b98SGreg Roach */ 3109b802b22SGreg Roach public function testDivorcedMale(): void 311c1010edaSGreg Roach { 3125e933c21SGreg Roach $fact = self::createMock(Fact::class); 31373d4df56SGreg Roach 3145e933c21SGreg Roach $family = self::createMock(Family::class); 315*109b3e30SGreg Roach $family 316*109b3e30SGreg Roach ->expects(self::exactly(2)) 317*109b3e30SGreg Roach ->method('facts') 318*109b3e30SGreg Roach ->withConsecutive( 319*109b3e30SGreg Roach [['MARR']], 320*109b3e30SGreg Roach [['DIV']]) 321*109b3e30SGreg Roach ->willReturn( 322*109b3e30SGreg Roach new Collection([$fact]), 323*109b3e30SGreg Roach new Collection([$fact]) 324*109b3e30SGreg Roach ); 32573d4df56SGreg Roach 3265e933c21SGreg Roach $individual = self::createMock(Individual::class); 3270ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3280ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 32900225b98SGreg Roach 3305e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 33100225b98SGreg Roach 33200225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 3330ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33400225b98SGreg Roach 3355e933c21SGreg Roach self::assertSame('Skilt', $column->generate($individual, $individual)); 33600225b98SGreg Roach } 33700225b98SGreg Roach 33800225b98SGreg Roach /** 33915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 34015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 34152348eb8SGreg Roach * 34252348eb8SGreg Roach * @return void 34300225b98SGreg Roach */ 3449b802b22SGreg Roach public function testDivorcedFemale(): void 345c1010edaSGreg Roach { 3465e933c21SGreg Roach $fact = self::createMock(Fact::class); 34700225b98SGreg Roach 3485e933c21SGreg Roach $family = self::createMock(Family::class); 349*109b3e30SGreg Roach $family 350*109b3e30SGreg Roach ->expects(self::exactly(2)) 351*109b3e30SGreg Roach ->method('facts') 352*109b3e30SGreg Roach ->withConsecutive( 353*109b3e30SGreg Roach [['MARR']], 354*109b3e30SGreg Roach [['DIV']]) 355*109b3e30SGreg Roach ->willReturn( 356*109b3e30SGreg Roach new Collection([$fact]), 357*109b3e30SGreg Roach new Collection([$fact]) 358*109b3e30SGreg Roach ); 35900225b98SGreg Roach 3605e933c21SGreg Roach $individual = self::createMock(Individual::class); 3610ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3620ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 36373d4df56SGreg Roach 3645e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 36573d4df56SGreg Roach 36673d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 3670ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 36873d4df56SGreg Roach 3695e933c21SGreg Roach self::assertSame('Skilt', $column->generate($individual, $individual)); 370101af0b4SGreg Roach } 371101af0b4SGreg Roach} 372