1101af0b4SGreg Roach<?php 2101af0b4SGreg Roach/** 3101af0b4SGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 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 */ 16101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census; 17101af0b4SGreg Roach 18101af0b4SGreg Roachuse Fisharebest\Webtrees\Date; 19101af0b4SGreg Roachuse Mockery; 20101af0b4SGreg Roach 21101af0b4SGreg Roach/** 2273d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish 23101af0b4SGreg Roach */ 24*84e2cf4eSGreg Roachclass CensusColumnConditionDanishTest extends \Fisharebest\Webtrees\TestCase 25c1010edaSGreg Roach{ 26101af0b4SGreg Roach /** 27101af0b4SGreg Roach * Delete mock objects 28101af0b4SGreg Roach */ 29c1010edaSGreg Roach public function tearDown() 30c1010edaSGreg Roach { 31101af0b4SGreg Roach Mockery::close(); 32101af0b4SGreg Roach } 33101af0b4SGreg Roach 34101af0b4SGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 37101af0b4SGreg Roach */ 38c1010edaSGreg Roach public function testNoSpouseFamiliesMale() 39c1010edaSGreg Roach { 40c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 4100225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 4213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 4300225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 44101af0b4SGreg Roach 45c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 4600225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('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 5673d4df56SGreg Roach */ 57c1010edaSGreg Roach public function testNoSpouseFamiliesFemale() 58c1010edaSGreg Roach { 5900225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 6000225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 6113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 6200225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 6300225b98SGreg Roach 6400225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 6500225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 6600225b98SGreg Roach 6700225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 6800225b98SGreg Roach 69342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 7000225b98SGreg Roach } 7100225b98SGreg Roach 7200225b98SGreg Roach /** 7315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 7415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7500225b98SGreg Roach */ 76c1010edaSGreg Roach public function testNoFamilyFactsMale() 77c1010edaSGreg Roach { 78c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 7973d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 802a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 8173d4df56SGreg Roach 82c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 8313abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 842a6fda60SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 852a6fda60SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 8673d4df56SGreg Roach 87c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 8873d4df56SGreg Roach 8973d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 9073d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 9173d4df56SGreg Roach 92342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 9373d4df56SGreg Roach } 9473d4df56SGreg Roach 9573d4df56SGreg Roach /** 9615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 9715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 9873d4df56SGreg Roach */ 99c1010edaSGreg Roach public function testNoFamilyFactsFemale() 100c1010edaSGreg Roach { 101c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 10273d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1032a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 104e76c0cf0SGreg Roach 105e76c0cf0SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 10613abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1072a6fda60SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 1082a6fda60SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 109e76c0cf0SGreg Roach 110e76c0cf0SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 111e76c0cf0SGreg Roach 112e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 113e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 114e76c0cf0SGreg Roach 115342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 116e76c0cf0SGreg Roach } 117e76c0cf0SGreg Roach 118e76c0cf0SGreg Roach /** 11915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 12015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 121e76c0cf0SGreg Roach */ 122c1010edaSGreg Roach public function testSpouseDeadMale() 123c1010edaSGreg Roach { 1242a6fda60SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 1252a6fda60SGreg Roach 126e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 127e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 128e76c0cf0SGreg Roach 129e76c0cf0SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 130e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1312a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 1322a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 133e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 134e76c0cf0SGreg Roach 135e76c0cf0SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 136e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 13713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 138e76c0cf0SGreg Roach 139e76c0cf0SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 140e76c0cf0SGreg Roach 141e76c0cf0SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 142e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 143e76c0cf0SGreg Roach 144342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 145e76c0cf0SGreg Roach } 146e76c0cf0SGreg Roach 147e76c0cf0SGreg Roach /** 14815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 14915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 150e76c0cf0SGreg Roach */ 151c1010edaSGreg Roach public function testSpouseDeadFemale() 152c1010edaSGreg Roach { 1532a6fda60SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 1542a6fda60SGreg Roach 155e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 156e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 157e76c0cf0SGreg Roach 158e76c0cf0SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 159e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1602a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 1612a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 162e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 16373d4df56SGreg Roach 164c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 16500225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 16613abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 16773d4df56SGreg Roach 168c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 16973d4df56SGreg Roach 17073d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 17173d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 17273d4df56SGreg Roach 173342dcecdSGreg Roach $this->assertSame('Gift', $column->generate($individual, $individual)); 17400225b98SGreg Roach } 17500225b98SGreg Roach 17600225b98SGreg Roach /** 17715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 17815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 17900225b98SGreg Roach */ 180c1010edaSGreg Roach public function testNoFamilyUnmarriedMale() 181c1010edaSGreg Roach { 18200225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 18300225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1842a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 18500225b98SGreg Roach 18600225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 18700225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 18813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 18900225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 19000225b98SGreg Roach 19100225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 19200225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 19300225b98SGreg Roach 19400225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 19500225b98SGreg Roach 196342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 19773d4df56SGreg Roach } 19873d4df56SGreg Roach 19973d4df56SGreg Roach /** 20015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 20115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20273d4df56SGreg Roach */ 203c1010edaSGreg Roach public function testNoFamilyUnmarriedFemale() 204c1010edaSGreg Roach { 20500225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 20600225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2072a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 20800225b98SGreg Roach 20900225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 21000225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 21113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 21200225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 21300225b98SGreg Roach 21400225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 21500225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 21600225b98SGreg Roach 21700225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 21800225b98SGreg Roach 219342dcecdSGreg Roach $this->assertSame('Ugift', $column->generate($individual, $individual)); 22000225b98SGreg Roach } 22100225b98SGreg Roach 22200225b98SGreg Roach /** 22315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 22415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 22500225b98SGreg Roach */ 226c1010edaSGreg Roach public function testChildMale() 227c1010edaSGreg Roach { 22800225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 22900225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2302a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 23100225b98SGreg Roach 23200225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 23300225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 23413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 23500225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 23600225b98SGreg Roach 23700225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 23800225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 23900225b98SGreg Roach 24000225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 24100225b98SGreg Roach 242342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 24300225b98SGreg Roach } 24400225b98SGreg Roach 24500225b98SGreg Roach /** 24615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 24715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24800225b98SGreg Roach */ 249c1010edaSGreg Roach public function testChildFemale() 250c1010edaSGreg Roach { 25100225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 25200225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2532a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 25400225b98SGreg Roach 25500225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 25600225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 25713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 25800225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 25900225b98SGreg Roach 26000225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 26100225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 26200225b98SGreg Roach 26300225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 26400225b98SGreg Roach 265342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 26600225b98SGreg Roach } 26700225b98SGreg Roach 26800225b98SGreg Roach /** 26915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 27015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 27100225b98SGreg Roach */ 272c1010edaSGreg Roach public function testDivorcedMale() 273c1010edaSGreg Roach { 274c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 27573d4df56SGreg Roach 276c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 27773d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2780b4be234SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 27913abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 28073d4df56SGreg Roach 281c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 28200225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 28313abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 28400225b98SGreg Roach 28500225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 28600225b98SGreg Roach 28700225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 28800225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 28900225b98SGreg Roach 290342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 29100225b98SGreg Roach } 29200225b98SGreg Roach 29300225b98SGreg Roach /** 29415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish 29515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29600225b98SGreg Roach */ 297c1010edaSGreg Roach public function testDivorcedFemale() 298c1010edaSGreg Roach { 29900225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 30000225b98SGreg Roach 30100225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 30200225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 3030b4be234SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 30413abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 30500225b98SGreg Roach 30600225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 30700225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 30813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 30973d4df56SGreg Roach 310c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 31173d4df56SGreg Roach 31273d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 31373d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 31473d4df56SGreg Roach 315342dcecdSGreg Roach $this->assertSame('Skilt', $column->generate($individual, $individual)); 316101af0b4SGreg Roach } 317101af0b4SGreg Roach} 318