1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2017 webtrees development team 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17namespace Fisharebest\Webtrees\Census; 18 19use Fisharebest\Webtrees\Date; 20use Mockery; 21 22/** 23 * Test harness for the class CensusColumnAgeMarried 24 */ 25class CensusColumnAgeMarriedTest extends \PHPUnit_Framework_TestCase { 26 /** 27 * Delete mock objects 28 */ 29 public function tearDown() { 30 Mockery::close(); 31 } 32 33 /** 34 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 35 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 36 */ 37 public function testAgeMarried() { 38 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 39 $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 40 41 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 42 $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); 43 44 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 45 $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 46 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 47 48 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 49 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 50 51 $column = new CensusColumnAgeMarried($census, '', ''); 52 53 $this->assertSame(19, $column->generate($individual)); 54 } 55 56 /** 57 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 58 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 59 */ 60 public function testNoBirthDate() { 61 } 62 63 /** 64 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 65 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 66 */ 67 public function testNoMarriage() { 68 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 69 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 70 71 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 72 $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 73 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 74 75 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 76 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 77 78 $column = new CensusColumnAgeMarried($census, '', ''); 79 80 $this->assertSame('', $column->generate($individual)); 81 } 82 83 /** 84 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 85 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 86 */ 87 public function testNoSpouseFamily() { 88 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 89 $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 90 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 91 92 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 93 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 94 95 $column = new CensusColumnAgeMarried($census, '', ''); 96 97 $this->assertSame('', $column->generate($individual)); 98 } 99} 100