181d1be7aSGreg Roach<?php 281d1be7aSGreg Roach 381d1be7aSGreg Roach/** 481d1be7aSGreg Roach * webtrees: online genealogy 51062a142SGreg Roach * Copyright (C) 2018 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 1581d1be7aSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1681d1be7aSGreg Roach */ 1781d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census; 1881d1be7aSGreg Roach 1981d1be7aSGreg Roachuse Fisharebest\Webtrees\Date; 2081d1be7aSGreg Roachuse Mockery; 2181d1be7aSGreg Roach 2281d1be7aSGreg Roach/** 2381d1be7aSGreg Roach * Test harness for the class CensusColumnConditionUs 2481d1be7aSGreg Roach */ 25c1010edaSGreg Roachclass CensusColumnConditionUsTest extends \PHPUnit\Framework\TestCase 26c1010edaSGreg Roach{ 2781d1be7aSGreg Roach /** 2881d1be7aSGreg Roach * Delete mock objects 2981d1be7aSGreg Roach */ 30c1010edaSGreg Roach public function tearDown() 31c1010edaSGreg Roach { 3281d1be7aSGreg Roach Mockery::close(); 3381d1be7aSGreg Roach } 3481d1be7aSGreg Roach 3581d1be7aSGreg Roach /** 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 3715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3881d1be7aSGreg Roach */ 39c1010edaSGreg Roach public function testNoSpouseFamiliesMale() 40c1010edaSGreg Roach { 4181d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 4200225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 4313abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 4400225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 4581d1be7aSGreg Roach 4681d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 4700225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 4881d1be7aSGreg Roach 4981d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 5081d1be7aSGreg Roach 51*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 5281d1be7aSGreg Roach } 5381d1be7aSGreg Roach 5481d1be7aSGreg Roach /** 5515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5781d1be7aSGreg Roach */ 58c1010edaSGreg Roach public function testNoSpouseFamiliesFemale() 59c1010edaSGreg Roach { 6000225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 6100225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 6213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 6300225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 6400225b98SGreg Roach 6500225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 6600225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 6700225b98SGreg Roach 6800225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 6900225b98SGreg Roach 70*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 7100225b98SGreg Roach } 7200225b98SGreg Roach 7300225b98SGreg Roach /** 7415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 7515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7600225b98SGreg Roach */ 77c1010edaSGreg Roach public function testNoFamilyFactsMale() 78c1010edaSGreg Roach { 7981d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 8081d1be7aSGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 812a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 8281d1be7aSGreg Roach 8381d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 8413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 852a6fda60SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 862a6fda60SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 8781d1be7aSGreg Roach 8881d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 8981d1be7aSGreg Roach 9081d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 9181d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 9281d1be7aSGreg Roach 93*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 9481d1be7aSGreg Roach } 9581d1be7aSGreg Roach 9681d1be7aSGreg Roach /** 9715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 9815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 9981d1be7aSGreg Roach */ 100c1010edaSGreg Roach public function testNoFamilyFactsFemale() 101c1010edaSGreg Roach { 10281d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 10381d1be7aSGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1042a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 10581d1be7aSGreg Roach 10681d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 10713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1082a6fda60SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 1092a6fda60SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 11081d1be7aSGreg Roach 11181d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 11281d1be7aSGreg Roach 11381d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 11481d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 11581d1be7aSGreg Roach 116*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 11700225b98SGreg Roach } 11800225b98SGreg Roach 11900225b98SGreg Roach /** 12015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 12115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12200225b98SGreg Roach */ 123c1010edaSGreg Roach public function testSpouseDeadMale() 124c1010edaSGreg Roach { 1252a6fda60SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 1262a6fda60SGreg Roach 127e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 128e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 129e76c0cf0SGreg Roach 130e76c0cf0SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 131e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1322a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 1332a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 134e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 135e76c0cf0SGreg Roach 136e76c0cf0SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 137e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 13813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 139e76c0cf0SGreg Roach 140e76c0cf0SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 141e76c0cf0SGreg Roach 142e76c0cf0SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 143e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 144e76c0cf0SGreg Roach 145*342dcecdSGreg Roach $this->assertSame('W', $column->generate($individual, $individual)); 146e76c0cf0SGreg Roach } 147e76c0cf0SGreg Roach 148e76c0cf0SGreg Roach /** 14915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 15015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 151e76c0cf0SGreg Roach */ 152c1010edaSGreg Roach public function testSpouseDeadFemale() 153c1010edaSGreg Roach { 1542a6fda60SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 1552a6fda60SGreg Roach 156e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 157e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 158e76c0cf0SGreg Roach 159e76c0cf0SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 160e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1612a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 1622a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 163e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 164e76c0cf0SGreg Roach 165e76c0cf0SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 166e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 16713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 168e76c0cf0SGreg Roach 169e76c0cf0SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 170e76c0cf0SGreg Roach 171e76c0cf0SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 172e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 173e76c0cf0SGreg Roach 174*342dcecdSGreg Roach $this->assertSame('W', $column->generate($individual, $individual)); 175e76c0cf0SGreg Roach } 176e76c0cf0SGreg Roach 177e76c0cf0SGreg Roach /** 17815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 17915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 180e76c0cf0SGreg Roach */ 181c1010edaSGreg Roach public function testNoFamilyUnmarriedMale() 182c1010edaSGreg Roach { 18300225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 18400225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 1852a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 18600225b98SGreg Roach 18700225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 18800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 18913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 19000225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 19100225b98SGreg Roach 19200225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 19300225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 19400225b98SGreg Roach 19500225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 19600225b98SGreg Roach 197*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 19881d1be7aSGreg Roach } 19981d1be7aSGreg Roach 20081d1be7aSGreg Roach /** 20115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 20215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 20381d1be7aSGreg Roach */ 204c1010edaSGreg Roach public function testNoFamilyUnmarriedFemale() 205c1010edaSGreg Roach { 20600225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 20700225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2082a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 20900225b98SGreg Roach 21000225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 21100225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 21213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 21300225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 21400225b98SGreg Roach 21500225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 21600225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 21700225b98SGreg Roach 21800225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 21900225b98SGreg Roach 220*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 22100225b98SGreg Roach } 22200225b98SGreg Roach 22300225b98SGreg Roach /** 22415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 22515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 22600225b98SGreg Roach */ 227c1010edaSGreg Roach public function testChildMale() 228c1010edaSGreg Roach { 22900225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 23000225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2312a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 23200225b98SGreg Roach 23300225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 23400225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 23513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 23600225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 23700225b98SGreg Roach 23800225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 23900225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 24000225b98SGreg Roach 24100225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 24200225b98SGreg Roach 243*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 24400225b98SGreg Roach } 24500225b98SGreg Roach 24600225b98SGreg Roach /** 24715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 24815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24900225b98SGreg Roach */ 250c1010edaSGreg Roach public function testChildFemale() 251c1010edaSGreg Roach { 25200225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 25300225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2542a6fda60SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 25500225b98SGreg Roach 25600225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 25700225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 25813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 25900225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 26000225b98SGreg Roach 26100225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 26200225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 26300225b98SGreg Roach 26400225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 26500225b98SGreg Roach 266*342dcecdSGreg Roach $this->assertSame('S', $column->generate($individual, $individual)); 26700225b98SGreg Roach } 26800225b98SGreg Roach 26900225b98SGreg Roach /** 27015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 27115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 27200225b98SGreg Roach */ 273c1010edaSGreg Roach public function testDivorcedMale() 274c1010edaSGreg Roach { 27581d1be7aSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 27681d1be7aSGreg Roach 27781d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 27881d1be7aSGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 2790b4be234SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 28013abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 28181d1be7aSGreg Roach 28281d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 28300225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 28413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 28500225b98SGreg Roach 28600225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 28700225b98SGreg Roach 28800225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 28900225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 29000225b98SGreg Roach 291*342dcecdSGreg Roach $this->assertSame('D', $column->generate($individual, $individual)); 29200225b98SGreg Roach } 29300225b98SGreg Roach 29400225b98SGreg Roach /** 29515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 29615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29700225b98SGreg Roach */ 298c1010edaSGreg Roach public function testDivorcedFemale() 299c1010edaSGreg Roach { 30000225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 30100225b98SGreg Roach 30200225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 30300225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 3040b4be234SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 30513abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 30600225b98SGreg Roach 30700225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 30800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 30913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 31081d1be7aSGreg Roach 31181d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 31281d1be7aSGreg Roach 31381d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 31481d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 31581d1be7aSGreg Roach 316*342dcecdSGreg Roach $this->assertSame('D', $column->generate($individual, $individual)); 31781d1be7aSGreg Roach } 31881d1be7aSGreg Roach} 319