1101af0b4SGreg Roach<?php 2101af0b4SGreg Roach 3101af0b4SGreg Roach/** 4101af0b4SGreg Roach * webtrees: online genealogy 5369c0ce6SGreg Roach * Copyright (C) 2016 webtrees development team 6101af0b4SGreg Roach * This program is free software: you can redistribute it and/or modify 7101af0b4SGreg Roach * it under the terms of the GNU General Public License as published by 8101af0b4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9101af0b4SGreg Roach * (at your option) any later version. 10101af0b4SGreg Roach * This program is distributed in the hope that it will be useful, 11101af0b4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12101af0b4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13101af0b4SGreg Roach * GNU General Public License for more details. 14101af0b4SGreg Roach * You should have received a copy of the GNU General Public License 15101af0b4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16101af0b4SGreg Roach */ 17101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census; 18101af0b4SGreg Roach 19101af0b4SGreg Roachuse Fisharebest\Webtrees\Date; 2073d4df56SGreg Roachuse Fisharebest\Webtrees\Fact; 2173d4df56SGreg Roachuse Fisharebest\Webtrees\Family; 22101af0b4SGreg Roachuse Fisharebest\Webtrees\Individual; 23101af0b4SGreg Roachuse Mockery; 24101af0b4SGreg Roach 25101af0b4SGreg Roach/** 2673d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish 27101af0b4SGreg Roach */ 28101af0b4SGreg Roachclass CensusColumnConditionDanishTest extends \PHPUnit_Framework_TestCase { 29101af0b4SGreg Roach /** 30101af0b4SGreg Roach * Delete mock objects 31101af0b4SGreg Roach */ 32101af0b4SGreg Roach public function tearDown() { 33101af0b4SGreg Roach Mockery::close(); 34101af0b4SGreg Roach } 35101af0b4SGreg Roach 36101af0b4SGreg Roach /** 3773d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 38*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 39101af0b4SGreg Roach */ 40*00225b98SGreg Roach public function testNoSpouseFamiliesMale() { 41c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 42*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 43e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); 44*00225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 45101af0b4SGreg Roach 46c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 47*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 48101af0b4SGreg Roach 4973d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 50101af0b4SGreg Roach 5173d4df56SGreg Roach $this->assertSame('Ugift', $column->generate($individual)); 5273d4df56SGreg Roach } 5373d4df56SGreg Roach 5473d4df56SGreg Roach /** 5573d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 56*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5773d4df56SGreg Roach */ 58*00225b98SGreg Roach public function testNoSpouseFamiliesFemale() { 59*00225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 60*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 61*00225b98SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); 62*00225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 63*00225b98SGreg Roach 64*00225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 65*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 66*00225b98SGreg Roach 67*00225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 68*00225b98SGreg Roach 69*00225b98SGreg Roach $this->assertSame('Ugift', $column->generate($individual)); 70*00225b98SGreg Roach } 71*00225b98SGreg Roach 72*00225b98SGreg Roach /** 73*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 74*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 75*00225b98SGreg Roach */ 76*00225b98SGreg Roach public function testNoFamilyNoFactsMale() { 77c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 7873d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 79e2052359SGreg Roach $family->shouldReceive('getFacts')->andReturn(array()); 8073d4df56SGreg Roach 81c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 82*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 83e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 8473d4df56SGreg Roach 85c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 8673d4df56SGreg Roach 8773d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 8873d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 8973d4df56SGreg Roach 9073d4df56SGreg Roach $this->assertSame('Gift', $column->generate($individual)); 9173d4df56SGreg Roach } 9273d4df56SGreg Roach 9373d4df56SGreg Roach /** 9473d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 95*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 9673d4df56SGreg Roach */ 97*00225b98SGreg Roach public function testNoFamilyNoFactsFemale() { 98c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 9973d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 100*00225b98SGreg Roach $family->shouldReceive('getFacts')->andReturn(array()); 10173d4df56SGreg Roach 102c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 103*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 104e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 10573d4df56SGreg Roach 106c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 10773d4df56SGreg Roach 10873d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 10973d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 11073d4df56SGreg Roach 111*00225b98SGreg Roach $this->assertSame('Gift', $column->generate($individual)); 112*00225b98SGreg Roach } 113*00225b98SGreg Roach 114*00225b98SGreg Roach /** 115*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 116*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 117*00225b98SGreg Roach */ 118*00225b98SGreg Roach public function testNoFamilyUnmarriedMale() { 119*00225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 120*00225b98SGreg Roach 121*00225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 122*00225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 123*00225b98SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 124*00225b98SGreg Roach 125*00225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 126*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 127*00225b98SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 128*00225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 129*00225b98SGreg Roach 130*00225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 131*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 132*00225b98SGreg Roach 133*00225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 134*00225b98SGreg Roach 13573d4df56SGreg Roach $this->assertSame('Ugift', $column->generate($individual)); 13673d4df56SGreg Roach } 13773d4df56SGreg Roach 13873d4df56SGreg Roach /** 13973d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 140*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 14173d4df56SGreg Roach */ 142*00225b98SGreg Roach public function testNoFamilyUnmarriedFemale() { 143*00225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 144*00225b98SGreg Roach 145*00225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 146*00225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 147*00225b98SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 148*00225b98SGreg Roach 149*00225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 150*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 151*00225b98SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 152*00225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 153*00225b98SGreg Roach 154*00225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 155*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 156*00225b98SGreg Roach 157*00225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 158*00225b98SGreg Roach 159*00225b98SGreg Roach $this->assertSame('Ugift', $column->generate($individual)); 160*00225b98SGreg Roach } 161*00225b98SGreg Roach 162*00225b98SGreg Roach /** 163*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 164*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 165*00225b98SGreg Roach */ 166*00225b98SGreg Roach public function testChildMale() { 167*00225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 168*00225b98SGreg Roach 169*00225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 170*00225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 171*00225b98SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 172*00225b98SGreg Roach 173*00225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 174*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 175*00225b98SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 176*00225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 177*00225b98SGreg Roach 178*00225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 179*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 180*00225b98SGreg Roach 181*00225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 182*00225b98SGreg Roach 183*00225b98SGreg Roach $this->assertSame('', $column->generate($individual)); 184*00225b98SGreg Roach } 185*00225b98SGreg Roach 186*00225b98SGreg Roach /** 187*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 188*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 189*00225b98SGreg Roach */ 190*00225b98SGreg Roach public function testChildFemale() { 191*00225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 192*00225b98SGreg Roach 193*00225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 194*00225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 195*00225b98SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 196*00225b98SGreg Roach 197*00225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 198*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 199*00225b98SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 200*00225b98SGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 201*00225b98SGreg Roach 202*00225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 203*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 204*00225b98SGreg Roach 205*00225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 206*00225b98SGreg Roach 207*00225b98SGreg Roach $this->assertSame('', $column->generate($individual)); 208*00225b98SGreg Roach } 209*00225b98SGreg Roach 210*00225b98SGreg Roach /** 211*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 212*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 213*00225b98SGreg Roach */ 214*00225b98SGreg Roach public function testDivorcedMale() { 215c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 21673d4df56SGreg Roach 217c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 21873d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 219e2052359SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array()); 220e2052359SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact)); 22173d4df56SGreg Roach 222c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 223*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 224*00225b98SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 225*00225b98SGreg Roach 226*00225b98SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 227*00225b98SGreg Roach 228*00225b98SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 229*00225b98SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 230*00225b98SGreg Roach 231*00225b98SGreg Roach $this->assertSame('Skilt', $column->generate($individual)); 232*00225b98SGreg Roach } 233*00225b98SGreg Roach 234*00225b98SGreg Roach /** 235*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 236*00225b98SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 237*00225b98SGreg Roach */ 238*00225b98SGreg Roach public function testDivorcedFemale() { 239*00225b98SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 240*00225b98SGreg Roach 241*00225b98SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 242*00225b98SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 243*00225b98SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array()); 244*00225b98SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact)); 245*00225b98SGreg Roach 246*00225b98SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 247*00225b98SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 248e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 24973d4df56SGreg Roach 250c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 25173d4df56SGreg Roach 25273d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 25373d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 25473d4df56SGreg Roach 25573d4df56SGreg Roach $this->assertSame('Skilt', $column->generate($individual)); 256101af0b4SGreg Roach } 257101af0b4SGreg Roach} 258