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 */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1881d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census; 1981d1be7aSGreg Roach 2081d1be7aSGreg Roachuse Fisharebest\Webtrees\Date; 2181d1be7aSGreg Roachuse Mockery; 2281d1be7aSGreg Roach 2381d1be7aSGreg Roach/** 2481d1be7aSGreg Roach * Test harness for the class CensusColumnAgeMarried 2581d1be7aSGreg Roach */ 2684e2cf4eSGreg Roachclass CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase 27c1010edaSGreg Roach{ 2881d1be7aSGreg Roach /** 2981d1be7aSGreg Roach * Delete mock objects 3052348eb8SGreg Roach * 3152348eb8SGreg Roach * @return void 3281d1be7aSGreg Roach */ 33c1010edaSGreg Roach public function tearDown() 34c1010edaSGreg Roach { 3581d1be7aSGreg Roach Mockery::close(); 3681d1be7aSGreg Roach } 3781d1be7aSGreg Roach 3881d1be7aSGreg Roach /** 3915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 4015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 4152348eb8SGreg Roach * 4252348eb8SGreg Roach * @return void 4381d1be7aSGreg Roach */ 44c1010edaSGreg Roach public function testAgeMarried() 45c1010edaSGreg Roach { 4681d1be7aSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 472decada7SGreg Roach $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859')); 4881d1be7aSGreg Roach 4981d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 50*8d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'], true)->andReturn([$fact]); 5181d1be7aSGreg Roach 5281d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 5381d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 5413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 5581d1be7aSGreg Roach 5681d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 5781d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 5881d1be7aSGreg Roach 5981d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 6081d1be7aSGreg Roach 61220febf9SGreg Roach $this->assertSame('19', $column->generate($individual, $individual)); 6281d1be7aSGreg Roach } 6381d1be7aSGreg Roach 6481d1be7aSGreg Roach /** 6515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 6615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 6752348eb8SGreg Roach * 6852348eb8SGreg Roach * @return void 6981d1be7aSGreg Roach */ 70c1010edaSGreg Roach public function testNoBirthDate() 71c1010edaSGreg Roach { 723e983931SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 733e983931SGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 743e983931SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 753e983931SGreg Roach 763e983931SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 773e983931SGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 783e983931SGreg Roach 793e983931SGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 803e983931SGreg Roach 81342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 8281d1be7aSGreg Roach } 8381d1be7aSGreg Roach 8481d1be7aSGreg Roach /** 8515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 8615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 8752348eb8SGreg Roach * 8852348eb8SGreg Roach * @return void 8981d1be7aSGreg Roach */ 90c1010edaSGreg Roach public function testNoMarriage() 91c1010edaSGreg Roach { 9281d1be7aSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 93*8d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 9481d1be7aSGreg Roach 9581d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 9681d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 9713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 9881d1be7aSGreg Roach 9981d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 10081d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 10181d1be7aSGreg Roach 10281d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 10381d1be7aSGreg Roach 104342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 10581d1be7aSGreg Roach } 10681d1be7aSGreg Roach 10781d1be7aSGreg Roach /** 10815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 10915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 11052348eb8SGreg Roach * 11152348eb8SGreg Roach * @return void 11281d1be7aSGreg Roach */ 113c1010edaSGreg Roach public function testNoSpouseFamily() 114c1010edaSGreg Roach { 11581d1be7aSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 11681d1be7aSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 11713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 11881d1be7aSGreg Roach 11981d1be7aSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 12081d1be7aSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 12181d1be7aSGreg Roach 12281d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 12381d1be7aSGreg Roach 124342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 12581d1be7aSGreg Roach } 12681d1be7aSGreg Roach} 127