181d1be7aSGreg Roach<?php 23976b470SGreg Roach 381d1be7aSGreg Roach/** 481d1be7aSGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 webtrees development team 681d1be7aSGreg Roach * This program is free software: you can redistribute it and/or modify 781d1be7aSGreg Roach * it under the terms of the GNU General Public License as published by 881d1be7aSGreg Roach * the Free Software Foundation, either version 3 of the License, or 981d1be7aSGreg Roach * (at your option) any later version. 1081d1be7aSGreg Roach * This program is distributed in the hope that it will be useful, 1181d1be7aSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1281d1be7aSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1381d1be7aSGreg Roach * GNU General Public License for more details. 1481d1be7aSGreg 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/>. 1681d1be7aSGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2081d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census; 2181d1be7aSGreg Roach 2281d1be7aSGreg 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; 2881d1be7aSGreg Roach 2981d1be7aSGreg Roach/** 3081d1be7aSGreg Roach * Test harness for the class CensusColumnConditionUs 3181d1be7aSGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnConditionUsTest extends TestCase 33c1010edaSGreg Roach{ 3481d1be7aSGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 3981d1be7aSGreg Roach */ 409b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 41c1010edaSGreg Roach { 42*cd94ca66SGreg 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')); 4681d1be7aSGreg Roach 47*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4981d1be7aSGreg Roach 5081d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 5181d1be7aSGreg Roach 525e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 5381d1be7aSGreg Roach } 5481d1be7aSGreg Roach 5581d1be7aSGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 5715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5852348eb8SGreg Roach * 5952348eb8SGreg Roach * @return void 6081d1be7aSGreg Roach */ 619b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 62c1010edaSGreg Roach { 63*cd94ca66SGreg 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 68*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 7000225b98SGreg Roach 7100225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 7200225b98SGreg Roach 735e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 7400225b98SGreg Roach } 7500225b98SGreg Roach 7600225b98SGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 7815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7952348eb8SGreg Roach * 8052348eb8SGreg Roach * @return void 8100225b98SGreg Roach */ 829b802b22SGreg Roach public function testNoFamilyFactsMale(): void 83c1010edaSGreg Roach { 84*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 850ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 860ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8781d1be7aSGreg Roach 88*cd94ca66SGreg 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'); 9281d1be7aSGreg Roach 93*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 9481d1be7aSGreg Roach 9581d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 960ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9781d1be7aSGreg Roach 985e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 9981d1be7aSGreg Roach } 10081d1be7aSGreg Roach 10181d1be7aSGreg Roach /** 10215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 10315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10452348eb8SGreg Roach * 10552348eb8SGreg Roach * @return void 10681d1be7aSGreg Roach */ 1079b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 108c1010edaSGreg Roach { 109*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 1100ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1110ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 11281d1be7aSGreg Roach 113*cd94ca66SGreg 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'); 11781d1be7aSGreg Roach 118*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 11981d1be7aSGreg Roach 12081d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 1210ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 12281d1be7aSGreg Roach 1235e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 12400225b98SGreg Roach } 12500225b98SGreg Roach 12600225b98SGreg Roach /** 12715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 12815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12952348eb8SGreg Roach * 13052348eb8SGreg Roach * @return void 13100225b98SGreg Roach */ 1329b802b22SGreg Roach public function testSpouseDeadMale(): void 133c1010edaSGreg Roach { 134*cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1352a6fda60SGreg Roach 136*cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1370ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 138e76c0cf0SGreg Roach 139*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 140109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 141109b3e30SGreg Roach $family->expects(self::exactly(2)) 142109b3e30SGreg Roach ->method('facts') 143109b3e30SGreg Roach ->withConsecutive( 144109b3e30SGreg Roach [['MARR']], 1452e84ab20SGreg Roach [['DIV']] 1462e84ab20SGreg 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 153*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1540ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1550ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 156e76c0cf0SGreg Roach 157*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 158e76c0cf0SGreg Roach 159e76c0cf0SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 1600ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 161e76c0cf0SGreg Roach 1625e933c21SGreg Roach self::assertSame('W', $column->generate($individual, $individual)); 163e76c0cf0SGreg Roach } 164e76c0cf0SGreg Roach 165e76c0cf0SGreg Roach /** 16615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 16715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16852348eb8SGreg Roach * 16952348eb8SGreg Roach * @return void 170e76c0cf0SGreg Roach */ 1719b802b22SGreg Roach public function testSpouseDeadFemale(): void 172c1010edaSGreg Roach { 173*cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 1742a6fda60SGreg Roach 175*cd94ca66SGreg Roach $spouse = $this->createMock(Individual::class); 1760ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 177e76c0cf0SGreg Roach 178*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 179109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 180109b3e30SGreg Roach $family 181109b3e30SGreg Roach ->expects(self::exactly(2)) 182109b3e30SGreg Roach ->method('facts') 183109b3e30SGreg Roach ->withConsecutive( 184109b3e30SGreg Roach [['MARR']], 185109b3e30SGreg Roach [['DIV']] 186109b3e30SGreg Roach ) 187109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 188109b3e30SGreg Roach new Collection([$fact]), 189109b3e30SGreg Roach new Collection() 190109b3e30SGreg Roach ); 191109b3e30SGreg Roach $family->expects(self::once())->method('spouse')->willReturn($spouse); 192e76c0cf0SGreg Roach 193*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1940ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1950ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 196e76c0cf0SGreg Roach 197*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 198e76c0cf0SGreg Roach 199e76c0cf0SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 2000ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 201e76c0cf0SGreg Roach 2025e933c21SGreg Roach self::assertSame('W', $column->generate($individual, $individual)); 203e76c0cf0SGreg Roach } 204e76c0cf0SGreg Roach 205e76c0cf0SGreg Roach /** 20615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 20715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20852348eb8SGreg Roach * 20952348eb8SGreg Roach * @return void 210e76c0cf0SGreg Roach */ 2119b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 212c1010edaSGreg Roach { 213*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2140ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2150ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 21600225b98SGreg Roach 217*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2180ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2190ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2200ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22100225b98SGreg Roach 222*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2230ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 22400225b98SGreg Roach 22500225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 22600225b98SGreg Roach 2275e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 22881d1be7aSGreg Roach } 22981d1be7aSGreg Roach 23081d1be7aSGreg Roach /** 23115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 23215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 23352348eb8SGreg Roach * 23452348eb8SGreg Roach * @return void 23581d1be7aSGreg Roach */ 2369b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 237c1010edaSGreg Roach { 238*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2390ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2400ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24100225b98SGreg Roach 242*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2430ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2440ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2450ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 24600225b98SGreg Roach 247*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 24900225b98SGreg Roach 25000225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 25100225b98SGreg Roach 2525e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 25300225b98SGreg Roach } 25400225b98SGreg Roach 25500225b98SGreg Roach /** 25615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 25715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 25852348eb8SGreg Roach * 25952348eb8SGreg Roach * @return void 26000225b98SGreg Roach */ 2619b802b22SGreg Roach public function testChildMale(): void 262c1010edaSGreg Roach { 263*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2640ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2650ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 26600225b98SGreg Roach 267*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2680ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2690ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2700ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27100225b98SGreg Roach 272*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2730ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 27400225b98SGreg Roach 27500225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 27600225b98SGreg Roach 2775e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 27800225b98SGreg Roach } 27900225b98SGreg Roach 28000225b98SGreg Roach /** 28115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 28215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 28352348eb8SGreg Roach * 28452348eb8SGreg Roach * @return void 28500225b98SGreg Roach */ 2869b802b22SGreg Roach public function testChildFemale(): void 287c1010edaSGreg Roach { 288*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 2890ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2900ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 29100225b98SGreg Roach 292*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 2930ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2940ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2950ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 29600225b98SGreg Roach 297*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 2980ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 29900225b98SGreg Roach 30000225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 30100225b98SGreg Roach 3025e933c21SGreg Roach self::assertSame('S', $column->generate($individual, $individual)); 30300225b98SGreg Roach } 30400225b98SGreg Roach 30500225b98SGreg Roach /** 30615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 30715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 30852348eb8SGreg Roach * 30952348eb8SGreg Roach * @return void 31000225b98SGreg Roach */ 3119b802b22SGreg Roach public function testDivorcedMale(): void 312c1010edaSGreg Roach { 313*cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 31481d1be7aSGreg Roach 315*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 316109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 317109b3e30SGreg Roach $family 318109b3e30SGreg Roach ->expects(self::exactly(2)) 319109b3e30SGreg Roach ->method('facts') 320109b3e30SGreg Roach ->withConsecutive( 321109b3e30SGreg Roach [['MARR']], 322109b3e30SGreg Roach [['DIV']] 323109b3e30SGreg Roach )->willReturnOnConsecutiveCalls( 324109b3e30SGreg Roach new Collection([$fact]), 325109b3e30SGreg Roach new Collection([$fact]) 326109b3e30SGreg Roach ); 32781d1be7aSGreg Roach 328*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 3290ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3300ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33100225b98SGreg Roach 332*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 33300225b98SGreg Roach 33400225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 3350ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33600225b98SGreg Roach 3375e933c21SGreg Roach self::assertSame('D', $column->generate($individual, $individual)); 33800225b98SGreg Roach } 33900225b98SGreg Roach 34000225b98SGreg Roach /** 34115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 34215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 34352348eb8SGreg Roach * 34452348eb8SGreg Roach * @return void 34500225b98SGreg Roach */ 3469b802b22SGreg Roach public function testDivorcedFemale(): void 347c1010edaSGreg Roach { 348*cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 34900225b98SGreg Roach 350*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 351109b3e30SGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 352109b3e30SGreg Roach $family 353109b3e30SGreg Roach ->expects(self::exactly(2)) 354109b3e30SGreg Roach ->method('facts') 355109b3e30SGreg Roach ->withConsecutive( 356109b3e30SGreg Roach [['MARR']], 357109b3e30SGreg Roach [['DIV']] 358109b3e30SGreg Roach )->willReturnOnConsecutiveCalls( 359109b3e30SGreg Roach new Collection([$fact]), 360109b3e30SGreg Roach new Collection([$fact]) 361109b3e30SGreg Roach ); 36200225b98SGreg Roach 363*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 3640ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3650ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 36681d1be7aSGreg Roach 367*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 36881d1be7aSGreg Roach 36981d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 3700ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 37181d1be7aSGreg Roach 3725e933c21SGreg Roach self::assertSame('D', $column->generate($individual, $individual)); 37381d1be7aSGreg Roach } 374b72623feSGreg Roach 375b72623feSGreg Roach /** 376b72623feSGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 377b72623feSGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 378b72623feSGreg Roach * 379b72623feSGreg Roach * @return void 380b72623feSGreg Roach */ 381b72623feSGreg Roach public function testMarriedMale(): void 382b72623feSGreg Roach { 383*cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 384b72623feSGreg Roach 385*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 386b72623feSGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 387b72623feSGreg Roach $family 388b72623feSGreg Roach ->expects(self::exactly(2)) 389b72623feSGreg Roach ->method('facts') 390b72623feSGreg Roach ->withConsecutive( 391b72623feSGreg Roach [['MARR']], 392b72623feSGreg Roach [['DIV']] 393b72623feSGreg Roach )->willReturnOnConsecutiveCalls( 394b72623feSGreg Roach new Collection([$fact]), 395b72623feSGreg Roach new Collection() 396b72623feSGreg Roach ); 397b72623feSGreg Roach 398*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 399b72623feSGreg Roach $individual->method('sex')->willReturn('M'); 400b72623feSGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 401b72623feSGreg Roach 402*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 403b72623feSGreg Roach 404b72623feSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 405b72623feSGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 406b72623feSGreg Roach 407b72623feSGreg Roach self::assertSame('M', $column->generate($individual, $individual)); 408b72623feSGreg Roach } 409b72623feSGreg Roach 410b72623feSGreg Roach /** 411b72623feSGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 412b72623feSGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 413b72623feSGreg Roach * 414b72623feSGreg Roach * @return void 415b72623feSGreg Roach */ 416b72623feSGreg Roach public function testMarriedFemale(): void 417b72623feSGreg Roach { 418*cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 419b72623feSGreg Roach 420*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 421b72623feSGreg Roach $family->expects(self::once())->method('getMarriageDate')->willReturn(new Date('')); 422b72623feSGreg Roach $family 423b72623feSGreg Roach ->expects(self::exactly(2)) 424b72623feSGreg Roach ->method('facts') 425b72623feSGreg Roach ->withConsecutive( 426b72623feSGreg Roach [['MARR']], 427b72623feSGreg Roach [['DIV']] 428b72623feSGreg Roach )->willReturnOnConsecutiveCalls( 429b72623feSGreg Roach new Collection([$fact]), 430b72623feSGreg Roach new Collection() 431b72623feSGreg Roach ); 432b72623feSGreg Roach 433*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 434b72623feSGreg Roach $individual->method('sex')->willReturn('F'); 435b72623feSGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 436b72623feSGreg Roach 437*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 438b72623feSGreg Roach 439b72623feSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 440b72623feSGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 441b72623feSGreg Roach 442b72623feSGreg Roach self::assertSame('M', $column->generate($individual, $individual)); 443b72623feSGreg Roach } 44481d1be7aSGreg Roach} 445