173d4df56SGreg Roach<?php 273d4df56SGreg Roach/** 373d4df56SGreg Roach * webtrees: online genealogy 4*8fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 573d4df56SGreg Roach * This program is free software: you can redistribute it and/or modify 673d4df56SGreg Roach * it under the terms of the GNU General Public License as published by 773d4df56SGreg Roach * the Free Software Foundation, either version 3 of the License, or 873d4df56SGreg Roach * (at your option) any later version. 973d4df56SGreg Roach * This program is distributed in the hope that it will be useful, 1073d4df56SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1173d4df56SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1273d4df56SGreg Roach * GNU General Public License for more details. 1373d4df56SGreg Roach * You should have received a copy of the GNU General Public License 1473d4df56SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1573d4df56SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1873d4df56SGreg Roachnamespace Fisharebest\Webtrees\Census; 1973d4df56SGreg Roach 2073d4df56SGreg Roachuse Fisharebest\Webtrees\Date; 21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2473d4df56SGreg Roachuse Mockery; 2573d4df56SGreg Roach 2673d4df56SGreg Roach/** 2773d4df56SGreg Roach * Test harness for the class CensusColumnConditionEnglish 2873d4df56SGreg Roach */ 2984e2cf4eSGreg Roachclass CensusColumnConditionEnglishTest extends \Fisharebest\Webtrees\TestCase 30c1010edaSGreg Roach{ 3173d4df56SGreg Roach /** 3273d4df56SGreg Roach * Delete mock objects 3352348eb8SGreg Roach * 3452348eb8SGreg Roach * @return void 3573d4df56SGreg Roach */ 36c1010edaSGreg Roach public function tearDown() 37c1010edaSGreg Roach { 3873d4df56SGreg Roach Mockery::close(); 3973d4df56SGreg Roach } 4073d4df56SGreg Roach 4173d4df56SGreg Roach /** 4215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 4315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 4452348eb8SGreg Roach * 4552348eb8SGreg Roach * @return void 4673d4df56SGreg Roach */ 47c1010edaSGreg Roach public function testNoSpouseFamiliesMale() 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')); 5373d4df56SGreg Roach 54ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 5500225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 5673d4df56SGreg Roach 5773d4df56SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 5873d4df56SGreg Roach 59342dcecdSGreg Roach $this->assertSame('Unm', $column->generate($individual, $individual)); 6073d4df56SGreg Roach } 6173d4df56SGreg Roach 6273d4df56SGreg Roach /** 6315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 6415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 6552348eb8SGreg Roach * 6652348eb8SGreg Roach * @return void 6773d4df56SGreg Roach */ 68c1010edaSGreg Roach public function testNoSpouseFamiliesFemale() 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 CensusColumnConditionEnglish($census, '', ''); 7900225b98SGreg Roach 80342dcecdSGreg Roach $this->assertSame('Unm', $column->generate($individual, $individual)); 8100225b98SGreg Roach } 8200225b98SGreg Roach 8300225b98SGreg Roach /** 8415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 8515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 8652348eb8SGreg Roach * 8752348eb8SGreg Roach * @return void 8800225b98SGreg Roach */ 89c1010edaSGreg Roach public function testNoFamilyFactsMale() 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 CensusColumnConditionEnglish($census, '', ''); 10373d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 10473d4df56SGreg Roach 105342dcecdSGreg Roach $this->assertSame('Unm', $column->generate($individual, $individual)); 10673d4df56SGreg Roach } 10773d4df56SGreg Roach 10873d4df56SGreg Roach /** 10915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 11015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 11152348eb8SGreg Roach * 11252348eb8SGreg Roach * @return void 11373d4df56SGreg Roach */ 114c1010edaSGreg Roach public function testNoFamilyFactsFemale() 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([]); 11973d4df56SGreg 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'); 12473d4df56SGreg Roach 125ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 12673d4df56SGreg Roach 12773d4df56SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 12873d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 12973d4df56SGreg Roach 130342dcecdSGreg Roach $this->assertSame('Unm', $column->generate($individual, $individual)); 13100225b98SGreg Roach } 13200225b98SGreg Roach 13300225b98SGreg Roach /** 13415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 13515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 13652348eb8SGreg Roach * 13752348eb8SGreg Roach * @return void 13800225b98SGreg Roach */ 139c1010edaSGreg Roach public function testSpouseDeadMale() 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 CensusColumnConditionEnglish($census, '', ''); 159e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 160e76c0cf0SGreg Roach 161342dcecdSGreg Roach $this->assertSame('Wid', $column->generate($individual, $individual)); 162e76c0cf0SGreg Roach } 163e76c0cf0SGreg Roach 164e76c0cf0SGreg Roach /** 16515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 16615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16752348eb8SGreg Roach * 16852348eb8SGreg Roach * @return void 169e76c0cf0SGreg Roach */ 170c1010edaSGreg Roach public function testSpouseDeadFemale() 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); 182e76c0cf0SGreg Roach 183ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 184e76c0cf0SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 18513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 186e76c0cf0SGreg Roach 187ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 188e76c0cf0SGreg Roach 189e76c0cf0SGreg Roach $column = new CensusColumnConditionEnglish($census, '', ''); 190e76c0cf0SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 191e76c0cf0SGreg Roach 192342dcecdSGreg Roach $this->assertSame('Wid', $column->generate($individual, $individual)); 193e76c0cf0SGreg Roach } 194e76c0cf0SGreg Roach 195e76c0cf0SGreg Roach /** 19615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 19715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 19852348eb8SGreg Roach * 19952348eb8SGreg Roach * @return void 200e76c0cf0SGreg Roach */ 201c1010edaSGreg Roach public function testNoFamilyUnmarriedMale() 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 CensusColumnConditionEnglish($census, '', ''); 21600225b98SGreg Roach 217342dcecdSGreg Roach $this->assertSame('Unm', $column->generate($individual, $individual)); 21873d4df56SGreg Roach } 21973d4df56SGreg Roach 22073d4df56SGreg Roach /** 22115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 22215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 22352348eb8SGreg Roach * 22452348eb8SGreg Roach * @return void 22573d4df56SGreg Roach */ 226c1010edaSGreg Roach public function testNoFamilyUnmarriedFemale() 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 CensusColumnConditionEnglish($census, '', ''); 24100225b98SGreg Roach 242342dcecdSGreg Roach $this->assertSame('Unm', $column->generate($individual, $individual)); 24300225b98SGreg Roach } 24400225b98SGreg Roach 24500225b98SGreg Roach /** 24615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 24715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24852348eb8SGreg Roach * 24952348eb8SGreg Roach * @return void 25000225b98SGreg Roach */ 251c1010edaSGreg Roach public function testChildMale() 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 CensusColumnConditionEnglish($census, '', ''); 26600225b98SGreg Roach 267342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 26800225b98SGreg Roach } 26900225b98SGreg Roach 27000225b98SGreg Roach /** 27115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 27215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 27352348eb8SGreg Roach * 27452348eb8SGreg Roach * @return void 27500225b98SGreg Roach */ 276c1010edaSGreg Roach public function testChildFemale() 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 CensusColumnConditionEnglish($census, '', ''); 29100225b98SGreg Roach 292342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 29300225b98SGreg Roach } 29400225b98SGreg Roach 29500225b98SGreg Roach /** 29615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 29715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29852348eb8SGreg Roach * 29952348eb8SGreg Roach * @return void 30000225b98SGreg Roach */ 301c1010edaSGreg Roach public function testDivorcedMale() 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 CensusColumnConditionEnglish($census, '', ''); 31700225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 31800225b98SGreg Roach 319342dcecdSGreg Roach $this->assertSame('Div', $column->generate($individual, $individual)); 32000225b98SGreg Roach } 32100225b98SGreg Roach 32200225b98SGreg Roach /** 32315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionEnglish 32415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 32552348eb8SGreg Roach * 32652348eb8SGreg Roach * @return void 32700225b98SGreg Roach */ 328c1010edaSGreg Roach public function testDivorcedFemale() 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 CensusColumnConditionEnglish($census, '', ''); 34473d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 34573d4df56SGreg Roach 346342dcecdSGreg Roach $this->assertSame('Div', $column->generate($individual, $individual)); 34773d4df56SGreg Roach } 34873d4df56SGreg Roach} 349