1101af0b4SGreg Roach<?php 2*3976b470SGreg 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 */ 17e7f56f2aSGreg Roachdeclare(strict_types=1); 18e7f56f2aSGreg Roach 19101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census; 20101af0b4SGreg Roach 21101af0b4SGreg Roachuse Fisharebest\Webtrees\Date; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2539ca88baSGreg Roachuse Illuminate\Support\Collection; 26101af0b4SGreg Roach 27101af0b4SGreg Roach/** 2873d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish 29101af0b4SGreg Roach */ 3084e2cf4eSGreg Roachclass CensusColumnConditionDanishTest extends \Fisharebest\Webtrees\TestCase 31c1010edaSGreg Roach{ 32101af0b4SGreg Roach /** 3315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 3415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3552348eb8SGreg Roach * 3652348eb8SGreg Roach * @return void 37101af0b4SGreg Roach */ 389b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 39c1010edaSGreg Roach { 400ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 410ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 420ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 430ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 44101af0b4SGreg Roach 450ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 460ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 47101af0b4SGreg Roach 4873d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 49101af0b4SGreg Roach 50342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 5173d4df56SGreg Roach } 5273d4df56SGreg Roach 5373d4df56SGreg Roach /** 5415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 5515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5652348eb8SGreg Roach * 5752348eb8SGreg Roach * @return void 5873d4df56SGreg Roach */ 599b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 60c1010edaSGreg Roach { 610ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 620ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 630ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 640ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 6500225b98SGreg Roach 660ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 670ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 6800225b98SGreg Roach 6900225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 7000225b98SGreg Roach 71342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 7200225b98SGreg Roach } 7300225b98SGreg Roach 7400225b98SGreg Roach /** 7515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 7615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7752348eb8SGreg Roach * 7852348eb8SGreg Roach * @return void 7900225b98SGreg Roach */ 809b802b22SGreg Roach public function testNoFamilyFactsMale(): void 81c1010edaSGreg Roach { 820ecdbde6SGreg Roach $family = $this->createMock(Family::class); 830ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 840ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8573d4df56SGreg Roach 860ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 870ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 880ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 890ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 9073d4df56SGreg Roach 910ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 9273d4df56SGreg Roach 9373d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 940ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9573d4df56SGreg Roach 96342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 9773d4df56SGreg Roach } 9873d4df56SGreg Roach 9973d4df56SGreg Roach /** 10015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 10115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10252348eb8SGreg Roach * 10352348eb8SGreg Roach * @return void 10473d4df56SGreg Roach */ 1059b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 106c1010edaSGreg Roach { 1070ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1080ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1090ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 110e76c0cf0SGreg Roach 1110ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1120ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1130ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 1140ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 115e76c0cf0SGreg Roach 1160ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 117e76c0cf0SGreg Roach 118e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1190ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 120e76c0cf0SGreg Roach 121342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 122e76c0cf0SGreg Roach } 123e76c0cf0SGreg Roach 124e76c0cf0SGreg Roach /** 12515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 12615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12752348eb8SGreg Roach * 12852348eb8SGreg Roach * @return void 129e76c0cf0SGreg Roach */ 1309b802b22SGreg Roach public function testSpouseDeadMale(): void 131c1010edaSGreg Roach { 1320ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 1332a6fda60SGreg Roach 1340ecdbde6SGreg Roach $spouse = $this->createMock(Individual::class); 1350ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 136e76c0cf0SGreg Roach 1370ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1380ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 1390ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 1400ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 1410ecdbde6SGreg Roach $family->expects($this->at(3))->method('spouse')->willReturn($spouse); 142e76c0cf0SGreg Roach 1430ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1440ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1450ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 146e76c0cf0SGreg Roach 1470ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 148e76c0cf0SGreg Roach 149e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1500ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 151e76c0cf0SGreg Roach 152342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 153e76c0cf0SGreg Roach } 154e76c0cf0SGreg Roach 155e76c0cf0SGreg Roach /** 15615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 15715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 15852348eb8SGreg Roach * 15952348eb8SGreg Roach * @return void 160e76c0cf0SGreg Roach */ 1619b802b22SGreg Roach public function testSpouseDeadFemale(): void 162c1010edaSGreg Roach { 1630ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 1642a6fda60SGreg Roach 1650ecdbde6SGreg Roach $spouse = $this->createMock(Individual::class); 1660ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 167e76c0cf0SGreg Roach 1680ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1690ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 1700ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 1710ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 1720ecdbde6SGreg Roach $family->expects($this->at(3))->method('spouse')->willReturn($spouse); 17373d4df56SGreg Roach 1740ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1750ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1760ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 17773d4df56SGreg Roach 1780ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 17973d4df56SGreg Roach 18073d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 1810ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 18273d4df56SGreg Roach 183342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 18400225b98SGreg Roach } 18500225b98SGreg Roach 18600225b98SGreg Roach /** 18715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 18815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 18952348eb8SGreg Roach * 19052348eb8SGreg Roach * @return void 19100225b98SGreg Roach */ 1929b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 193c1010edaSGreg Roach { 1940ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1950ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1960ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 19700225b98SGreg Roach 1980ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1990ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2000ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2010ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 20200225b98SGreg Roach 2030ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2040ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 20500225b98SGreg Roach 20600225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 20700225b98SGreg Roach 208342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 20973d4df56SGreg Roach } 21073d4df56SGreg Roach 21173d4df56SGreg Roach /** 21215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 21315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 21452348eb8SGreg Roach * 21552348eb8SGreg Roach * @return void 21673d4df56SGreg Roach */ 2179b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 218c1010edaSGreg Roach { 2190ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2200ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2210ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 22200225b98SGreg Roach 2230ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2240ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2250ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2260ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22700225b98SGreg Roach 2280ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2290ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 23000225b98SGreg Roach 23100225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 23200225b98SGreg Roach 233342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 23400225b98SGreg Roach } 23500225b98SGreg Roach 23600225b98SGreg Roach /** 23715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 23815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 23952348eb8SGreg Roach * 24052348eb8SGreg Roach * @return void 24100225b98SGreg Roach */ 2429b802b22SGreg Roach public function testChildMale(): void 243c1010edaSGreg Roach { 2440ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2450ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2460ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24700225b98SGreg Roach 2480ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2490ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2500ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2510ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 25200225b98SGreg Roach 2530ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2540ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 25500225b98SGreg Roach 25600225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 25700225b98SGreg Roach 258342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 25900225b98SGreg Roach } 26000225b98SGreg Roach 26100225b98SGreg Roach /** 26215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 26315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 26452348eb8SGreg Roach * 26552348eb8SGreg Roach * @return void 26600225b98SGreg Roach */ 2679b802b22SGreg Roach public function testChildFemale(): void 268c1010edaSGreg Roach { 2690ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2700ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2710ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 27200225b98SGreg Roach 2730ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 2740ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2750ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2760ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27700225b98SGreg Roach 2780ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 2790ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 28000225b98SGreg Roach 28100225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 28200225b98SGreg Roach 283342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 28400225b98SGreg Roach } 28500225b98SGreg Roach 28600225b98SGreg Roach /** 28715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 28815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 28952348eb8SGreg Roach * 29052348eb8SGreg Roach * @return void 29100225b98SGreg Roach */ 2929b802b22SGreg Roach public function testDivorcedMale(): void 293c1010edaSGreg Roach { 2940ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 29573d4df56SGreg Roach 2960ecdbde6SGreg Roach $family = $this->createMock(Family::class); 2970ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 2980ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 2990ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 30073d4df56SGreg Roach 3010ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 3020ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3030ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 30400225b98SGreg Roach 3050ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 30600225b98SGreg Roach 30700225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 3080ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 30900225b98SGreg Roach 310342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 31100225b98SGreg Roach } 31200225b98SGreg Roach 31300225b98SGreg Roach /** 31415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 31515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 31652348eb8SGreg Roach * 31752348eb8SGreg Roach * @return void 31800225b98SGreg Roach */ 3199b802b22SGreg Roach public function testDivorcedFemale(): void 320c1010edaSGreg Roach { 3210ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 32200225b98SGreg Roach 3230ecdbde6SGreg Roach $family = $this->createMock(Family::class); 3240ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 3250ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 3260ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 32700225b98SGreg Roach 3280ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 3290ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3300ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33173d4df56SGreg Roach 3320ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 33373d4df56SGreg Roach 33473d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 3350ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33673d4df56SGreg Roach 337342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 338101af0b4SGreg Roach } 339101af0b4SGreg Roach} 340