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 */ 24*84e2cf4eSGreg Roachclass CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase 25c1010edaSGreg Roach{ 2681d1be7aSGreg Roach /** 2781d1be7aSGreg Roach * Delete mock objects 2881d1be7aSGreg Roach */ 29c1010edaSGreg Roach public function tearDown() 30c1010edaSGreg Roach { 3181d1be7aSGreg Roach Mockery::close(); 3281d1be7aSGreg Roach } 3381d1be7aSGreg Roach 3481d1be7aSGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3781d1be7aSGreg Roach */ 38c1010edaSGreg Roach public function testAgeMarried() 39c1010edaSGreg Roach { 4081d1be7aSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 4181d1be7aSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 4281d1be7aSGreg Roach 4381d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 4413abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); 4581d1be7aSGreg Roach 4681d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 4781d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 4813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 4981d1be7aSGreg Roach 5081d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 5181d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 5281d1be7aSGreg Roach 5381d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 5481d1be7aSGreg Roach 55220febf9SGreg Roach $this->assertSame('19', $column->generate($individual, $individual)); 5681d1be7aSGreg Roach } 5781d1be7aSGreg Roach 5881d1be7aSGreg Roach /** 5915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 6015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 6181d1be7aSGreg Roach */ 62c1010edaSGreg Roach public function testNoBirthDate() 63c1010edaSGreg Roach { 643e983931SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 653e983931SGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 663e983931SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 673e983931SGreg Roach 683e983931SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 693e983931SGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 703e983931SGreg Roach 713e983931SGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 723e983931SGreg Roach 73342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 7481d1be7aSGreg Roach } 7581d1be7aSGreg Roach 7681d1be7aSGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 7815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 7981d1be7aSGreg Roach */ 80c1010edaSGreg Roach public function testNoMarriage() 81c1010edaSGreg Roach { 8281d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 8313abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 8481d1be7aSGreg Roach 8581d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 8681d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 8713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 8881d1be7aSGreg Roach 8981d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 9081d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 9181d1be7aSGreg Roach 9281d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 9381d1be7aSGreg Roach 94342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 9581d1be7aSGreg Roach } 9681d1be7aSGreg Roach 9781d1be7aSGreg Roach /** 9815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 9915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 10081d1be7aSGreg Roach */ 101c1010edaSGreg Roach public function testNoSpouseFamily() 102c1010edaSGreg Roach { 10381d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 10481d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 10513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 10681d1be7aSGreg Roach 10781d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 10881d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 10981d1be7aSGreg Roach 11081d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 11181d1be7aSGreg Roach 112342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 11381d1be7aSGreg Roach } 11481d1be7aSGreg Roach} 115