173d4df56SGreg Roach<?php 23976b470SGreg Roach 373d4df56SGreg Roach/** 473d4df56SGreg Roach * webtrees: online genealogy 55e933c21SGreg Roach * Copyright (C) 2020 webtrees development team 673d4df56SGreg Roach * This program is free software: you can redistribute it and/or modify 773d4df56SGreg Roach * it under the terms of the GNU General Public License as published by 873d4df56SGreg Roach * the Free Software Foundation, either version 3 of the License, or 973d4df56SGreg Roach * (at your option) any later version. 1073d4df56SGreg Roach * This program is distributed in the hope that it will be useful, 1173d4df56SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1273d4df56SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1373d4df56SGreg Roach * GNU General Public License for more details. 1473d4df56SGreg Roach * You should have received a copy of the GNU General Public License 1573d4df56SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1673d4df56SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2073d4df56SGreg Roachnamespace Fisharebest\Webtrees\Census; 2173d4df56SGreg Roach 2273d4df56SGreg 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; 2873d4df56SGreg Roach 2973d4df56SGreg Roach/** 3073d4df56SGreg Roach * Test harness for the class CensusColumnConditionEnglish 3173d4df56SGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnConditionEnglishTest extends TestCase 33c1010edaSGreg Roach{ 3473d4df56SGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 3973d4df56SGreg 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')); 4673d4df56SGreg Roach 475e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4973d4df56SGreg Roach 5073d4df56SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 5173d4df56SGreg Roach 525e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 5373d4df56SGreg Roach } 5473d4df56SGreg Roach 5573d4df56SGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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 CensusColumnConditionEnglish($census, '', ''); 7200225b98SGreg Roach 735e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 7400225b98SGreg Roach } 7500225b98SGreg Roach 7600225b98SGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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 CensusColumnConditionEnglish($census, '', ''); 960ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9773d4df56SGreg Roach 985e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 9973d4df56SGreg Roach } 10073d4df56SGreg Roach 10173d4df56SGreg Roach /** 10215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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()); 11273d4df56SGreg 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'); 11773d4df56SGreg Roach 1185e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 11973d4df56SGreg Roach 12073d4df56SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 1210ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 12273d4df56SGreg Roach 1235e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 12400225b98SGreg Roach } 12500225b98SGreg Roach 12600225b98SGreg Roach /** 12715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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); 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 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 CensusColumnConditionEnglish($census, '', ''); 1600ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 161e76c0cf0SGreg Roach 1625e933c21SGreg Roach self::assertSame('Wid', $column->generate($individual, $individual)); 163e76c0cf0SGreg Roach } 164e76c0cf0SGreg Roach 165e76c0cf0SGreg Roach /** 16615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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); 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 1925e933c21SGreg Roach $individual = self::createMock(Individual::class); 1930ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1940ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 195e76c0cf0SGreg Roach 1965e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 197e76c0cf0SGreg Roach 198e76c0cf0SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 1990ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 200e76c0cf0SGreg Roach 2015e933c21SGreg Roach self::assertSame('Wid', $column->generate($individual, $individual)); 202e76c0cf0SGreg Roach } 203e76c0cf0SGreg Roach 204e76c0cf0SGreg Roach /** 20515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 20615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20752348eb8SGreg Roach * 20852348eb8SGreg Roach * @return void 209e76c0cf0SGreg 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 CensusColumnConditionEnglish($census, '', ''); 22500225b98SGreg Roach 2265e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 22773d4df56SGreg Roach } 22873d4df56SGreg Roach 22973d4df56SGreg Roach /** 23015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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 CensusColumnConditionEnglish($census, '', ''); 25000225b98SGreg Roach 2515e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 25200225b98SGreg Roach } 25300225b98SGreg Roach 25400225b98SGreg Roach /** 25515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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 CensusColumnConditionEnglish($census, '', ''); 27500225b98SGreg Roach 2765e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 27700225b98SGreg Roach } 27800225b98SGreg Roach 27900225b98SGreg Roach /** 28015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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 CensusColumnConditionEnglish($census, '', ''); 30000225b98SGreg Roach 3015e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 30200225b98SGreg Roach } 30300225b98SGreg Roach 30400225b98SGreg Roach /** 30515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 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); 315109b3e30SGreg Roach $family 316109b3e30SGreg Roach ->expects(self::exactly(2)) 317109b3e30SGreg Roach ->method('facts') 318109b3e30SGreg Roach ->withConsecutive( 319109b3e30SGreg Roach [['MARR']], 320*2e84ab20SGreg Roach [['DIV']] 321*2e84ab20SGreg Roach ) 322109b3e30SGreg Roach ->willReturn( 323109b3e30SGreg Roach new Collection([$fact]), 324109b3e30SGreg Roach new Collection([$fact]) 325109b3e30SGreg Roach ); 32673d4df56SGreg Roach 3275e933c21SGreg Roach $individual = self::createMock(Individual::class); 3280ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3290ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33000225b98SGreg Roach 3315e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 33200225b98SGreg Roach 33300225b98SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 3340ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33500225b98SGreg Roach 3365e933c21SGreg Roach self::assertSame('Div', $column->generate($individual, $individual)); 33700225b98SGreg Roach } 33800225b98SGreg Roach 33900225b98SGreg Roach /** 34015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 34115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 34252348eb8SGreg Roach * 34352348eb8SGreg Roach * @return void 34400225b98SGreg Roach */ 3459b802b22SGreg Roach public function testDivorcedFemale(): void 346c1010edaSGreg Roach { 3475e933c21SGreg Roach $fact = self::createMock(Fact::class); 34800225b98SGreg Roach 3495e933c21SGreg Roach $family = self::createMock(Family::class); 350109b3e30SGreg Roach $family 351109b3e30SGreg Roach ->expects(self::exactly(2)) 352109b3e30SGreg Roach ->method('facts') 353109b3e30SGreg Roach ->withConsecutive( 354109b3e30SGreg Roach [['MARR']], 355*2e84ab20SGreg Roach [['DIV']] 356*2e84ab20SGreg Roach ) 357109b3e30SGreg Roach ->willReturn( 358109b3e30SGreg Roach new Collection([$fact]), 359109b3e30SGreg Roach new Collection([$fact]) 360109b3e30SGreg Roach ); 36100225b98SGreg Roach 3625e933c21SGreg Roach $individual = self::createMock(Individual::class); 3630ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3640ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 36573d4df56SGreg Roach 3665e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 36773d4df56SGreg Roach 36873d4df56SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 3690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 37073d4df56SGreg Roach 3715e933c21SGreg Roach self::assertSame('Div', $column->generate($individual, $individual)); 37273d4df56SGreg Roach } 37373d4df56SGreg Roach} 374