1101af0b4SGreg Roach<?php 2101af0b4SGreg Roach/** 3101af0b4SGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 5101af0b4SGreg Roach * This program is free software: you can redistribute it and/or modify 6101af0b4SGreg Roach * it under the terms of the GNU General Public License as published by 7101af0b4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8101af0b4SGreg Roach * (at your option) any later version. 9101af0b4SGreg Roach * This program is distributed in the hope that it will be useful, 10101af0b4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11101af0b4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12101af0b4SGreg Roach * GNU General Public License for more details. 13101af0b4SGreg Roach * You should have received a copy of the GNU General Public License 14101af0b4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15101af0b4SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 18101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census; 19101af0b4SGreg Roach 20101af0b4SGreg Roachuse Fisharebest\Webtrees\Date; 21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 24101af0b4SGreg Roachuse Mockery; 25101af0b4SGreg Roach 26101af0b4SGreg Roach/** 2773d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish 28101af0b4SGreg Roach */ 2984e2cf4eSGreg Roachclass CensusColumnConditionDanishTest extends \Fisharebest\Webtrees\TestCase 30c1010edaSGreg Roach{ 31101af0b4SGreg Roach /** 32101af0b4SGreg Roach * Delete mock objects 3352348eb8SGreg Roach * 3452348eb8SGreg Roach * @return void 35101af0b4SGreg Roach */ 36c1010edaSGreg Roach public function tearDown() 37c1010edaSGreg Roach { 38101af0b4SGreg Roach Mockery::close(); 39101af0b4SGreg Roach } 40101af0b4SGreg Roach 41101af0b4SGreg Roach /** 4215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 4315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 4452348eb8SGreg Roach * 4552348eb8SGreg Roach * @return void 46101af0b4SGreg Roach */ 47*9b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 48c1010edaSGreg Roach { 49ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 5000225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 5113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 5200225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 53101af0b4SGreg Roach 54ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 5500225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 56101af0b4SGreg Roach 5773d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 58101af0b4SGreg Roach 59342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 6073d4df56SGreg Roach } 6173d4df56SGreg Roach 6273d4df56SGreg Roach /** 6315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 6415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 6552348eb8SGreg Roach * 6652348eb8SGreg Roach * @return void 6773d4df56SGreg Roach */ 68*9b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 69c1010edaSGreg Roach { 70ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 7100225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 7213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 7300225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 7400225b98SGreg Roach 75ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 7600225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 7700225b98SGreg Roach 7800225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 7900225b98SGreg Roach 80342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 8100225b98SGreg Roach } 8200225b98SGreg Roach 8300225b98SGreg Roach /** 8415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 8515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 8652348eb8SGreg Roach * 8752348eb8SGreg Roach * @return void 8800225b98SGreg Roach */ 89*9b802b22SGreg Roach public function testNoFamilyFactsMale(): void 90c1010edaSGreg Roach { 91ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 9273d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 938d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 9473d4df56SGreg Roach 95ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 9613abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 972a6fda60SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 982a6fda60SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 9973d4df56SGreg Roach 100ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 10173d4df56SGreg Roach 10273d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 10373d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 10473d4df56SGreg Roach 105342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 10673d4df56SGreg Roach } 10773d4df56SGreg Roach 10873d4df56SGreg Roach /** 10915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 11015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 11152348eb8SGreg Roach * 11252348eb8SGreg Roach * @return void 11373d4df56SGreg Roach */ 114*9b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 115c1010edaSGreg Roach { 116ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 11773d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1188d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 119e76c0cf0SGreg Roach 120ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 12113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1222a6fda60SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 1232a6fda60SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 124e76c0cf0SGreg Roach 125ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 126e76c0cf0SGreg Roach 127e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 128e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 129e76c0cf0SGreg Roach 130342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 131e76c0cf0SGreg Roach } 132e76c0cf0SGreg Roach 133e76c0cf0SGreg Roach /** 13415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 13515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 13652348eb8SGreg Roach * 13752348eb8SGreg Roach * @return void 138e76c0cf0SGreg Roach */ 139*9b802b22SGreg Roach public function testSpouseDeadMale(): void 140c1010edaSGreg Roach { 141ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 1422a6fda60SGreg Roach 143ddf438a5SGreg Roach $spouse = Mockery::mock(Individual::class); 144e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 145e76c0cf0SGreg Roach 146ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 147e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1488d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 1498d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['DIV'])->andReturn([]); 150e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 151e76c0cf0SGreg Roach 152ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 153e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 15413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 155e76c0cf0SGreg Roach 156ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 157e76c0cf0SGreg Roach 158e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 159e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 160e76c0cf0SGreg Roach 161342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 162e76c0cf0SGreg Roach } 163e76c0cf0SGreg Roach 164e76c0cf0SGreg Roach /** 16515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 16615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16752348eb8SGreg Roach * 16852348eb8SGreg Roach * @return void 169e76c0cf0SGreg Roach */ 170*9b802b22SGreg Roach public function testSpouseDeadFemale(): void 171c1010edaSGreg Roach { 172ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 1732a6fda60SGreg Roach 174ddf438a5SGreg Roach $spouse = Mockery::mock(Individual::class); 175e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 176e76c0cf0SGreg Roach 177ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 178e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1798d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 1808d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['DIV'])->andReturn([]); 181e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 18273d4df56SGreg Roach 183ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 18400225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 18513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 18673d4df56SGreg Roach 187ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 18873d4df56SGreg Roach 18973d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 19073d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 19173d4df56SGreg Roach 192342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 19300225b98SGreg Roach } 19400225b98SGreg Roach 19500225b98SGreg Roach /** 19615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 19715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 19852348eb8SGreg Roach * 19952348eb8SGreg Roach * @return void 20000225b98SGreg Roach */ 201*9b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 202c1010edaSGreg Roach { 203ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 20400225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2058d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 20600225b98SGreg Roach 207ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 20800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 20913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 21000225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 21100225b98SGreg Roach 212ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 21300225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 21400225b98SGreg Roach 21500225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 21600225b98SGreg Roach 217342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 21873d4df56SGreg Roach } 21973d4df56SGreg Roach 22073d4df56SGreg Roach /** 22115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 22215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 22352348eb8SGreg Roach * 22452348eb8SGreg Roach * @return void 22573d4df56SGreg Roach */ 226*9b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 227c1010edaSGreg Roach { 228ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 22900225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2308d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 23100225b98SGreg Roach 232ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 23300225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 23413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 23500225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 23600225b98SGreg Roach 237ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 23800225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 23900225b98SGreg Roach 24000225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 24100225b98SGreg Roach 242342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 24300225b98SGreg Roach } 24400225b98SGreg Roach 24500225b98SGreg Roach /** 24615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 24715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24852348eb8SGreg Roach * 24952348eb8SGreg Roach * @return void 25000225b98SGreg Roach */ 251*9b802b22SGreg Roach public function testChildMale(): void 252c1010edaSGreg Roach { 253ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 25400225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2558d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 25600225b98SGreg Roach 257ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 25800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 25913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 26000225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 26100225b98SGreg Roach 262ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 26300225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 26400225b98SGreg Roach 26500225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 26600225b98SGreg Roach 267342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 26800225b98SGreg Roach } 26900225b98SGreg Roach 27000225b98SGreg Roach /** 27115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 27215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 27352348eb8SGreg Roach * 27452348eb8SGreg Roach * @return void 27500225b98SGreg Roach */ 276*9b802b22SGreg Roach public function testChildFemale(): void 277c1010edaSGreg Roach { 278ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 27900225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2808d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 28100225b98SGreg Roach 282ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 28300225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 28413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 28500225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 28600225b98SGreg Roach 287ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 28800225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 28900225b98SGreg Roach 29000225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 29100225b98SGreg Roach 292342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 29300225b98SGreg Roach } 29400225b98SGreg Roach 29500225b98SGreg Roach /** 29615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 29715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29852348eb8SGreg Roach * 29952348eb8SGreg Roach * @return void 30000225b98SGreg Roach */ 301*9b802b22SGreg Roach public function testDivorcedMale(): void 302c1010edaSGreg Roach { 303ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 30473d4df56SGreg Roach 305ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 30673d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 3078d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 3088d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['DIV'])->andReturn([$fact]); 30973d4df56SGreg Roach 310ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 31100225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 31213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 31300225b98SGreg Roach 314ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 31500225b98SGreg Roach 31600225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 31700225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 31800225b98SGreg Roach 319342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 32000225b98SGreg Roach } 32100225b98SGreg Roach 32200225b98SGreg Roach /** 32315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 32415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 32552348eb8SGreg Roach * 32652348eb8SGreg Roach * @return void 32700225b98SGreg Roach */ 328*9b802b22SGreg Roach public function testDivorcedFemale(): void 329c1010edaSGreg Roach { 330ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 33100225b98SGreg Roach 332ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 33300225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 3348d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 3358d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['DIV'])->andReturn([$fact]); 33600225b98SGreg Roach 337ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 33800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 33913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 34073d4df56SGreg Roach 341ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 34273d4df56SGreg Roach 34373d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 34473d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 34573d4df56SGreg Roach 346342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 347101af0b4SGreg Roach } 348101af0b4SGreg Roach} 349