181d1be7aSGreg Roach<?php 281d1be7aSGreg Roach/** 381d1be7aSGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 581d1be7aSGreg Roach * This program is free software: you can redistribute it and/or modify 681d1be7aSGreg Roach * it under the terms of the GNU General Public License as published by 781d1be7aSGreg Roach * the Free Software Foundation, either version 3 of the License, or 881d1be7aSGreg Roach * (at your option) any later version. 981d1be7aSGreg Roach * This program is distributed in the hope that it will be useful, 1081d1be7aSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1181d1be7aSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1281d1be7aSGreg Roach * GNU General Public License for more details. 1381d1be7aSGreg Roach * You should have received a copy of the GNU General Public License 1481d1be7aSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1581d1be7aSGreg Roach */ 1681d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census; 1781d1be7aSGreg Roach 1881d1be7aSGreg Roachuse Fisharebest\Webtrees\Date; 1981d1be7aSGreg Roachuse Mockery; 2081d1be7aSGreg Roach 2181d1be7aSGreg Roach/** 2281d1be7aSGreg Roach * Test harness for the class CensusColumnAgeMarried 2381d1be7aSGreg Roach */ 2484e2cf4eSGreg Roachclass CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase 25c1010edaSGreg Roach{ 2681d1be7aSGreg Roach /** 2781d1be7aSGreg Roach * Delete mock objects 28*52348eb8SGreg Roach * 29*52348eb8SGreg Roach * @return void 3081d1be7aSGreg Roach */ 31c1010edaSGreg Roach public function tearDown() 32c1010edaSGreg Roach { 3381d1be7aSGreg Roach Mockery::close(); 3481d1be7aSGreg Roach } 3581d1be7aSGreg Roach 3681d1be7aSGreg Roach /** 3715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 3815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 39*52348eb8SGreg Roach * 40*52348eb8SGreg Roach * @return void 4181d1be7aSGreg Roach */ 42c1010edaSGreg Roach public function testAgeMarried() 43c1010edaSGreg Roach { 4481d1be7aSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 4581d1be7aSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 4681d1be7aSGreg Roach 4781d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 4813abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); 4981d1be7aSGreg Roach 5081d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 5181d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 5213abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 5381d1be7aSGreg Roach 5481d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 5581d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 5681d1be7aSGreg Roach 5781d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 5881d1be7aSGreg Roach 59220febf9SGreg Roach $this->assertSame('19', $column->generate($individual, $individual)); 6081d1be7aSGreg Roach } 6181d1be7aSGreg Roach 6281d1be7aSGreg Roach /** 6315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 6415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 65*52348eb8SGreg Roach * 66*52348eb8SGreg Roach * @return void 6781d1be7aSGreg Roach */ 68c1010edaSGreg Roach public function testNoBirthDate() 69c1010edaSGreg Roach { 703e983931SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 713e983931SGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 723e983931SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 733e983931SGreg Roach 743e983931SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 753e983931SGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 763e983931SGreg Roach 773e983931SGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 783e983931SGreg Roach 79342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 8081d1be7aSGreg Roach } 8181d1be7aSGreg Roach 8281d1be7aSGreg Roach /** 8315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 8415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 85*52348eb8SGreg Roach * 86*52348eb8SGreg Roach * @return void 8781d1be7aSGreg Roach */ 88c1010edaSGreg Roach public function testNoMarriage() 89c1010edaSGreg Roach { 9081d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 9113abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 9281d1be7aSGreg Roach 9381d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 9481d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 9513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 9681d1be7aSGreg Roach 9781d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 9881d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 9981d1be7aSGreg Roach 10081d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 10181d1be7aSGreg Roach 102342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 10381d1be7aSGreg Roach } 10481d1be7aSGreg Roach 10581d1be7aSGreg Roach /** 10615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 10715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 108*52348eb8SGreg Roach * 109*52348eb8SGreg Roach * @return void 11081d1be7aSGreg Roach */ 111c1010edaSGreg Roach public function testNoSpouseFamily() 112c1010edaSGreg Roach { 11381d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 11481d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 11513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 11681d1be7aSGreg Roach 11781d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 11881d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 11981d1be7aSGreg Roach 12081d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 12181d1be7aSGreg Roach 122342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 12381d1be7aSGreg Roach } 12481d1be7aSGreg Roach} 125