181d1be7aSGreg Roach<?php 281d1be7aSGreg Roach 381d1be7aSGreg Roach/** 481d1be7aSGreg Roach * webtrees: online genealogy 56bdf7674SGreg Roach * Copyright (C) 2017 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 */ 2581d1be7aSGreg Roachclass CensusColumnConditionUsTest extends \PHPUnit_Framework_TestCase { 2681d1be7aSGreg Roach /** 2781d1be7aSGreg Roach * Delete mock objects 2881d1be7aSGreg Roach */ 2981d1be7aSGreg Roach public function tearDown() { 3081d1be7aSGreg Roach Mockery::close(); 3181d1be7aSGreg Roach } 3281d1be7aSGreg Roach 3381d1be7aSGreg Roach /** 34*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 35*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3681d1be7aSGreg Roach */ 3700225b98SGreg Roach public function testNoSpouseFamiliesMale() { 3881d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 3900225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 4013abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 4100225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 4281d1be7aSGreg Roach 4381d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 4400225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 4581d1be7aSGreg Roach 4681d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 4781d1be7aSGreg Roach 4881d1be7aSGreg Roach $this->assertSame('S', $column->generate($individual)); 4981d1be7aSGreg Roach } 5081d1be7aSGreg Roach 5181d1be7aSGreg Roach /** 52*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 53*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5481d1be7aSGreg Roach */ 5500225b98SGreg Roach public function testNoSpouseFamiliesFemale() { 5600225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 5700225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 5813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 5900225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 6000225b98SGreg Roach 6100225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 6200225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 6300225b98SGreg Roach 6400225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 6500225b98SGreg Roach 6600225b98SGreg Roach $this->assertSame('S', $column->generate($individual)); 6700225b98SGreg Roach } 6800225b98SGreg Roach 6900225b98SGreg Roach /** 70*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 71*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7200225b98SGreg Roach */ 73e76c0cf0SGreg Roach public function testNoFamilyFactsMale() { 74e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 75e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1850')); 76e76c0cf0SGreg Roach 7781d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 7881d1be7aSGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 7913abd6f3SGreg Roach $family->shouldReceive('getFacts')->andReturn([]); 80e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 8181d1be7aSGreg Roach 8281d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 8300225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 8413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 8581d1be7aSGreg Roach 8681d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 8781d1be7aSGreg Roach 8881d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 8981d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 9081d1be7aSGreg Roach 9181d1be7aSGreg Roach $this->assertSame('M', $column->generate($individual)); 9281d1be7aSGreg Roach } 9381d1be7aSGreg Roach 9481d1be7aSGreg Roach /** 95*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 96*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 9781d1be7aSGreg Roach */ 98e76c0cf0SGreg Roach public function testNoFamilyFactsFemale() { 99e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 100e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1850')); 101e76c0cf0SGreg Roach 10281d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 10381d1be7aSGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 10413abd6f3SGreg Roach $family->shouldReceive('getFacts')->andReturn([]); 105e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 10681d1be7aSGreg Roach 10781d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 10800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 10913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 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 11600225b98SGreg Roach $this->assertSame('M', $column->generate($individual)); 11700225b98SGreg Roach } 11800225b98SGreg Roach 11900225b98SGreg Roach /** 120*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 121*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12200225b98SGreg Roach */ 123e76c0cf0SGreg Roach public function testSpouseDeadMale() { 124e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 125e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 126e76c0cf0SGreg Roach 127e76c0cf0SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 128e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 12913abd6f3SGreg Roach $family->shouldReceive('getFacts')->andReturn([]); 130e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 131e76c0cf0SGreg Roach 132e76c0cf0SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 133e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 13413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 135e76c0cf0SGreg Roach 136e76c0cf0SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 137e76c0cf0SGreg Roach 138e76c0cf0SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 139e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 140e76c0cf0SGreg Roach 141e76c0cf0SGreg Roach $this->assertSame('W', $column->generate($individual)); 142e76c0cf0SGreg Roach } 143e76c0cf0SGreg Roach 144e76c0cf0SGreg Roach /** 145*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 146*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 147e76c0cf0SGreg Roach */ 148e76c0cf0SGreg Roach public function testSpouseDeadFemale() { 149e76c0cf0SGreg Roach $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 150e76c0cf0SGreg Roach $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 151e76c0cf0SGreg Roach 152e76c0cf0SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 153e76c0cf0SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 15413abd6f3SGreg Roach $family->shouldReceive('getFacts')->andReturn([]); 155e76c0cf0SGreg Roach $family->shouldReceive('getSpouse')->andReturn($spouse); 156e76c0cf0SGreg Roach 157e76c0cf0SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 158e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 15913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 160e76c0cf0SGreg Roach 161e76c0cf0SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 162e76c0cf0SGreg Roach 163e76c0cf0SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 164e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 165e76c0cf0SGreg Roach 166e76c0cf0SGreg Roach $this->assertSame('W', $column->generate($individual)); 167e76c0cf0SGreg Roach } 168e76c0cf0SGreg Roach 169e76c0cf0SGreg Roach /** 170*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 171*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 172e76c0cf0SGreg Roach */ 17300225b98SGreg Roach public function testNoFamilyUnmarriedMale() { 17400225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 17500225b98SGreg Roach 17600225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 17700225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 17813abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]); 17900225b98SGreg Roach 18000225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 18100225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 18213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 18300225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 18400225b98SGreg Roach 18500225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 18600225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 18700225b98SGreg Roach 18800225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 18900225b98SGreg Roach 19081d1be7aSGreg Roach $this->assertSame('S', $column->generate($individual)); 19181d1be7aSGreg Roach } 19281d1be7aSGreg Roach 19381d1be7aSGreg Roach /** 194*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 195*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 19681d1be7aSGreg Roach */ 19700225b98SGreg Roach public function testNoFamilyUnmarriedFemale() { 19800225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 19900225b98SGreg Roach 20000225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 20100225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 20213abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]); 20300225b98SGreg Roach 20400225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 20500225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 20613abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 20700225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 20800225b98SGreg Roach 20900225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 21000225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 21100225b98SGreg Roach 21200225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 21300225b98SGreg Roach 21400225b98SGreg Roach $this->assertSame('S', $column->generate($individual)); 21500225b98SGreg Roach } 21600225b98SGreg Roach 21700225b98SGreg Roach /** 218*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 219*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 22000225b98SGreg Roach */ 22100225b98SGreg Roach public function testChildMale() { 22200225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 22300225b98SGreg Roach 22400225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 22500225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 22613abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]); 22700225b98SGreg Roach 22800225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 22900225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 23013abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 23100225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 23200225b98SGreg Roach 23300225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 23400225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 23500225b98SGreg Roach 23600225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 23700225b98SGreg Roach 23800225b98SGreg Roach $this->assertSame('S', $column->generate($individual)); 23900225b98SGreg Roach } 24000225b98SGreg Roach 24100225b98SGreg Roach /** 242*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 243*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24400225b98SGreg Roach */ 24500225b98SGreg Roach public function testChildFemale() { 24600225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 24700225b98SGreg Roach 24800225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 24900225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 25013abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]); 25100225b98SGreg Roach 25200225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 25300225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 25413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 25500225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 25600225b98SGreg Roach 25700225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 25800225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 25900225b98SGreg Roach 26000225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 26100225b98SGreg Roach 26200225b98SGreg Roach $this->assertSame('S', $column->generate($individual)); 26300225b98SGreg Roach } 26400225b98SGreg Roach 26500225b98SGreg Roach /** 266*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 267*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 26800225b98SGreg Roach */ 26900225b98SGreg Roach public function testDivorcedMale() { 27081d1be7aSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 27181d1be7aSGreg Roach 27281d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 27381d1be7aSGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 27413abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([]); 27513abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 27681d1be7aSGreg Roach 27781d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 27800225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 27913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 28000225b98SGreg Roach 28100225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 28200225b98SGreg Roach 28300225b98SGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 28400225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 28500225b98SGreg Roach 28600225b98SGreg Roach $this->assertSame('D', $column->generate($individual)); 28700225b98SGreg Roach } 28800225b98SGreg Roach 28900225b98SGreg Roach /** 290*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs 291*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29200225b98SGreg Roach */ 29300225b98SGreg Roach public function testDivorcedFemale() { 29400225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 29500225b98SGreg Roach 29600225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 29700225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 29813abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([]); 29913abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 30000225b98SGreg Roach 30100225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 30200225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 30313abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 30481d1be7aSGreg Roach 30581d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 30681d1be7aSGreg Roach 30781d1be7aSGreg Roach $column = new CensusColumnConditionUs($census, '', ''); 30881d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 30981d1be7aSGreg Roach 31081d1be7aSGreg Roach $this->assertSame('D', $column->generate($individual)); 31181d1be7aSGreg Roach } 31281d1be7aSGreg Roach} 313