1101af0b4SGreg Roach<?php 23976b470SGreg Roach 3101af0b4SGreg Roach/** 4101af0b4SGreg Roach * webtrees: online genealogy 58fcd0d32SGreg Roach * Copyright (C) 2019 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 */ 17*fcfa147eSGreg 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 { 420ecdbde6SGreg 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')); 46101af0b4SGreg Roach 470ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 49101af0b4SGreg Roach 5073d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 51101af0b4SGreg Roach 52342dcecdSGreg Roach $this->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 { 630ecdbde6SGreg 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 680ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 7000225b98SGreg Roach 7100225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 7200225b98SGreg Roach 73342dcecdSGreg Roach $this->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 { 840ecdbde6SGreg 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 880ecdbde6SGreg 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 930ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 9473d4df56SGreg Roach 9573d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 960ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9773d4df56SGreg Roach 98342dcecdSGreg Roach $this->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 { 1090ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1100ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1110ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 112e76c0cf0SGreg Roach 1130ecdbde6SGreg 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'); 117e76c0cf0SGreg Roach 1180ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 119e76c0cf0SGreg Roach 120e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1210ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 122e76c0cf0SGreg Roach 123342dcecdSGreg Roach $this->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 { 1340ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 1352a6fda60SGreg Roach 1360ecdbde6SGreg Roach $spouse = $this->createMock(Individual::class); 1370ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 138e76c0cf0SGreg Roach 1390ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1400ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 1410ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 1420ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 1430ecdbde6SGreg Roach $family->expects($this->at(3))->method('spouse')->willReturn($spouse); 144e76c0cf0SGreg Roach 1450ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1460ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1470ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 148e76c0cf0SGreg Roach 1490ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 150e76c0cf0SGreg Roach 151e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1520ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 153e76c0cf0SGreg Roach 154342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 155e76c0cf0SGreg Roach } 156e76c0cf0SGreg Roach 157e76c0cf0SGreg Roach /** 15815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 15915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16052348eb8SGreg Roach * 16152348eb8SGreg Roach * @return void 162e76c0cf0SGreg Roach */ 1639b802b22SGreg Roach public function testSpouseDeadFemale(): void 164c1010edaSGreg Roach { 1650ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 1662a6fda60SGreg Roach 1670ecdbde6SGreg Roach $spouse = $this->createMock(Individual::class); 1680ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 169e76c0cf0SGreg Roach 1700ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1710ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 1720ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 1730ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 1740ecdbde6SGreg Roach $family->expects($this->at(3))->method('spouse')->willReturn($spouse); 17573d4df56SGreg Roach 1760ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1770ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1780ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 17973d4df56SGreg Roach 1800ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 18173d4df56SGreg Roach 18273d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1830ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 18473d4df56SGreg Roach 185342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 18600225b98SGreg Roach } 18700225b98SGreg Roach 18800225b98SGreg Roach /** 18915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 19015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 19152348eb8SGreg Roach * 19252348eb8SGreg Roach * @return void 19300225b98SGreg Roach */ 1949b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 195c1010edaSGreg Roach { 1960ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1970ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1980ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 19900225b98SGreg Roach 2000ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2010ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2020ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2030ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 20400225b98SGreg Roach 2050ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2060ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 20700225b98SGreg Roach 20800225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 20900225b98SGreg Roach 210342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 21173d4df56SGreg Roach } 21273d4df56SGreg Roach 21373d4df56SGreg Roach /** 21415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 21515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 21652348eb8SGreg Roach * 21752348eb8SGreg Roach * @return void 21873d4df56SGreg Roach */ 2199b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 220c1010edaSGreg Roach { 2210ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2220ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2230ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 22400225b98SGreg Roach 2250ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2260ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2270ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2280ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22900225b98SGreg Roach 2300ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2310ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 23200225b98SGreg Roach 23300225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 23400225b98SGreg Roach 235342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 23600225b98SGreg Roach } 23700225b98SGreg Roach 23800225b98SGreg Roach /** 23915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 24015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24152348eb8SGreg Roach * 24252348eb8SGreg Roach * @return void 24300225b98SGreg Roach */ 2449b802b22SGreg Roach public function testChildMale(): void 245c1010edaSGreg Roach { 2460ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2470ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2480ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24900225b98SGreg Roach 2500ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2510ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2520ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2530ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 25400225b98SGreg Roach 2550ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2560ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 25700225b98SGreg Roach 25800225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 25900225b98SGreg Roach 260342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 26100225b98SGreg Roach } 26200225b98SGreg Roach 26300225b98SGreg Roach /** 26415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 26515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 26652348eb8SGreg Roach * 26752348eb8SGreg Roach * @return void 26800225b98SGreg Roach */ 2699b802b22SGreg Roach public function testChildFemale(): void 270c1010edaSGreg Roach { 2710ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2720ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2730ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 27400225b98SGreg Roach 2750ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2760ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2770ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2780ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27900225b98SGreg Roach 2800ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2810ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 28200225b98SGreg Roach 28300225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 28400225b98SGreg Roach 285342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 28600225b98SGreg Roach } 28700225b98SGreg Roach 28800225b98SGreg Roach /** 28915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 29015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29152348eb8SGreg Roach * 29252348eb8SGreg Roach * @return void 29300225b98SGreg Roach */ 2949b802b22SGreg Roach public function testDivorcedMale(): void 295c1010edaSGreg Roach { 2960ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 29773d4df56SGreg Roach 2980ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2990ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 3000ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 3010ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 30273d4df56SGreg Roach 3030ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 3040ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3050ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 30600225b98SGreg Roach 3070ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 30800225b98SGreg Roach 30900225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 3100ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 31100225b98SGreg Roach 312342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 31300225b98SGreg Roach } 31400225b98SGreg Roach 31500225b98SGreg Roach /** 31615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 31715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 31852348eb8SGreg Roach * 31952348eb8SGreg Roach * @return void 32000225b98SGreg Roach */ 3219b802b22SGreg Roach public function testDivorcedFemale(): void 322c1010edaSGreg Roach { 3230ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 32400225b98SGreg Roach 3250ecdbde6SGreg Roach $family = $this->createMock(Family::class); 3260ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 3270ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 3280ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 32900225b98SGreg Roach 3300ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 3310ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3320ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33373d4df56SGreg Roach 3340ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 33573d4df56SGreg Roach 33673d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 3370ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33873d4df56SGreg Roach 339342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 340101af0b4SGreg Roach } 341101af0b4SGreg Roach} 342