173d4df56SGreg Roach<?php 23976b470SGreg Roach 373d4df56SGreg Roach/** 473d4df56SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 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 1589f7189bSGreg Roach * along with this program. If not, see <https://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 { 42cd94ca66SGreg Roach $individual = $this->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 47cd94ca66SGreg Roach $census = $this->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 { 63cd94ca66SGreg Roach $individual = $this->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 68cd94ca66SGreg Roach $census = $this->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 { 84cd94ca66SGreg Roach $family = $this->createMock(Family::class); 850ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 860ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8773d4df56SGreg Roach 88cd94ca66SGreg Roach $individual = $this->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 93cd94ca66SGreg Roach $census = $this->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 { 109cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1100ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1110ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 11273d4df56SGreg Roach 113cd94ca66SGreg Roach $individual = $this->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 118cd94ca66SGreg Roach $census = $this->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 { 134cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1352a6fda60SGreg Roach 136cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1370ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 138e76c0cf0SGreg Roach 139cd94ca66SGreg Roach $family = $this->createMock(Family::class); 140109b3e30SGreg Roach $family 141109b3e30SGreg Roach ->expects(self::exactly(2)) 142109b3e30SGreg Roach ->method('facts') 143*9aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 144109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 145109b3e30SGreg Roach new Collection([$fact]), 146109b3e30SGreg Roach new Collection() 147109b3e30SGreg Roach ); 148109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 149e76c0cf0SGreg Roach 150cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1510ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1520ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 153e76c0cf0SGreg Roach 154cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 155e76c0cf0SGreg Roach 156e76c0cf0SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 1570ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 158e76c0cf0SGreg Roach 1595e933c21SGreg Roach self::assertSame('Wid', $column->generate($individual, $individual)); 160e76c0cf0SGreg Roach } 161e76c0cf0SGreg Roach 162e76c0cf0SGreg Roach /** 16315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 16415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16552348eb8SGreg Roach * 16652348eb8SGreg Roach * @return void 167e76c0cf0SGreg Roach */ 1689b802b22SGreg Roach public function testSpouseDeadFemale(): void 169c1010edaSGreg Roach { 170cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1712a6fda60SGreg Roach 172cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1730ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 174e76c0cf0SGreg Roach 175cd94ca66SGreg Roach $family = $this->createMock(Family::class); 176109b3e30SGreg Roach $family 177109b3e30SGreg Roach ->expects(self::exactly(2)) 178109b3e30SGreg Roach ->method('facts') 179*9aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 180109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 181109b3e30SGreg Roach new Collection([$fact]), 182109b3e30SGreg Roach new Collection() 183109b3e30SGreg Roach ); 184109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 185e76c0cf0SGreg Roach 186cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1870ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1880ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 189e76c0cf0SGreg Roach 190cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 191e76c0cf0SGreg Roach 192e76c0cf0SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 1930ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 194e76c0cf0SGreg Roach 1955e933c21SGreg Roach self::assertSame('Wid', $column->generate($individual, $individual)); 196e76c0cf0SGreg Roach } 197e76c0cf0SGreg Roach 198e76c0cf0SGreg Roach /** 19915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 20015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20152348eb8SGreg Roach * 20252348eb8SGreg Roach * @return void 203e76c0cf0SGreg Roach */ 2049b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 205c1010edaSGreg Roach { 206cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2070ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2080ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 20900225b98SGreg Roach 210cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2110ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2120ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2130ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 21400225b98SGreg Roach 215cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2160ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 21700225b98SGreg Roach 21800225b98SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 21900225b98SGreg Roach 2205e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 22173d4df56SGreg Roach } 22273d4df56SGreg Roach 22373d4df56SGreg Roach /** 22415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 22515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 22652348eb8SGreg Roach * 22752348eb8SGreg Roach * @return void 22873d4df56SGreg Roach */ 2299b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 230c1010edaSGreg Roach { 231cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2320ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2330ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 23400225b98SGreg Roach 235cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2360ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2370ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2380ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 23900225b98SGreg Roach 240cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2410ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 24200225b98SGreg Roach 24300225b98SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 24400225b98SGreg Roach 2455e933c21SGreg Roach self::assertSame('Unm', $column->generate($individual, $individual)); 24600225b98SGreg Roach } 24700225b98SGreg Roach 24800225b98SGreg Roach /** 24915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 25015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 25152348eb8SGreg Roach * 25252348eb8SGreg Roach * @return void 25300225b98SGreg Roach */ 2549b802b22SGreg Roach public function testChildMale(): void 255c1010edaSGreg Roach { 256cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2570ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2580ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 25900225b98SGreg Roach 260cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2610ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2620ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2630ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 26400225b98SGreg Roach 265cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2660ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 26700225b98SGreg Roach 26800225b98SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 26900225b98SGreg Roach 2705e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 27100225b98SGreg Roach } 27200225b98SGreg Roach 27300225b98SGreg Roach /** 27415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 27515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 27652348eb8SGreg Roach * 27752348eb8SGreg Roach * @return void 27800225b98SGreg Roach */ 2799b802b22SGreg Roach public function testChildFemale(): void 280c1010edaSGreg Roach { 281cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2820ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2830ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 28400225b98SGreg Roach 285cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2860ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2870ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2880ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 28900225b98SGreg Roach 290cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2910ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 29200225b98SGreg Roach 29300225b98SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 29400225b98SGreg Roach 2955e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 29600225b98SGreg Roach } 29700225b98SGreg Roach 29800225b98SGreg Roach /** 29915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 30015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 30152348eb8SGreg Roach * 30252348eb8SGreg Roach * @return void 30300225b98SGreg Roach */ 3049b802b22SGreg Roach public function testDivorcedMale(): void 305c1010edaSGreg Roach { 306cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 30773d4df56SGreg Roach 308cd94ca66SGreg Roach $family = $this->createMock(Family::class); 309109b3e30SGreg Roach $family 310109b3e30SGreg Roach ->expects(self::exactly(2)) 311109b3e30SGreg Roach ->method('facts') 312*9aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 313109b3e30SGreg Roach ->willReturn( 314109b3e30SGreg Roach new Collection([$fact]), 315109b3e30SGreg Roach new Collection([$fact]) 316109b3e30SGreg Roach ); 31773d4df56SGreg Roach 318cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 3190ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3200ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 32100225b98SGreg Roach 322cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 32300225b98SGreg Roach 32400225b98SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 3250ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 32600225b98SGreg Roach 3275e933c21SGreg Roach self::assertSame('Div', $column->generate($individual, $individual)); 32800225b98SGreg Roach } 32900225b98SGreg Roach 33000225b98SGreg Roach /** 33115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 33215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 33352348eb8SGreg Roach * 33452348eb8SGreg Roach * @return void 33500225b98SGreg Roach */ 3369b802b22SGreg Roach public function testDivorcedFemale(): void 337c1010edaSGreg Roach { 338cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 33900225b98SGreg Roach 340cd94ca66SGreg Roach $family = $this->createMock(Family::class); 341109b3e30SGreg Roach $family 342109b3e30SGreg Roach ->expects(self::exactly(2)) 343109b3e30SGreg Roach ->method('facts') 344*9aef375dSGreg Roach ->with(self::withConsecutive([['MARR'], ['DIV']])) 345109b3e30SGreg Roach ->willReturn( 346109b3e30SGreg Roach new Collection([$fact]), 347109b3e30SGreg Roach new Collection([$fact]) 348109b3e30SGreg Roach ); 34900225b98SGreg Roach 350cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 3510ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3520ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 35373d4df56SGreg Roach 354cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 35573d4df56SGreg Roach 35673d4df56SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 3570ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 35873d4df56SGreg Roach 3595e933c21SGreg Roach self::assertSame('Div', $column->generate($individual, $individual)); 36073d4df56SGreg Roach } 36173d4df56SGreg Roach} 362