1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2018 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 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 62 $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 63 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 64 65 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 66 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 67 68 $column = new CensusColumnAgeMarried($census, '', ''); 69 70 $this->assertSame('', $column->generate($individual)); 71 } 72 73 /** 74 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 75 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 76 */ 77 public function testNoMarriage() { 78 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 79 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 80 81 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 82 $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 83 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 84 85 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 86 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 87 88 $column = new CensusColumnAgeMarried($census, '', ''); 89 90 $this->assertSame('', $column->generate($individual)); 91 } 92 93 /** 94 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 95 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 96 */ 97 public function testNoSpouseFamily() { 98 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 99 $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); 100 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 101 102 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 103 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 104 105 $column = new CensusColumnAgeMarried($census, '', ''); 106 107 $this->assertSame('', $column->generate($individual)); 108 } 109} 110