1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2016 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 CensusColumnYearsMarried 24 */ 25class CensusColumnYearsMarriedTest 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\CensusColumnYearsMarried 35 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 36 */ 37 public function testNoSpouseFamily() { 38 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 39 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 40 41 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 42 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 43 44 $column = new CensusColumnYearsMarried($census, '', ''); 45 46 $this->assertSame('', $column->generate($individual)); 47 } 48 49 /** 50 * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried 51 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 52 */ 53 public function testNoMarriage() { 54 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 55 $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([]); 56 57 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 58 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 59 60 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 61 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 62 63 $column = new CensusColumnYearsMarried($census, '', ''); 64 65 $this->assertSame('', $column->generate($individual)); 66 } 67 68 /** 69 * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried 70 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 71 */ 72 public function testUndatedMarriage() { 73 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 74 $fact->shouldReceive('getDate')->andReturn(new Date('')); 75 76 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 77 $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); 78 79 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 80 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 81 82 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 83 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 84 85 $column = new CensusColumnYearsMarried($census, '', ''); 86 87 $this->assertSame('', $column->generate($individual)); 88 } 89 90 /** 91 * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried 92 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 93 */ 94 public function testMarriageAfterCensus() { 95 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 96 $fact->shouldReceive('getDate')->andReturn(new Date('1861')); 97 98 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 99 $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); 100 101 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 102 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 103 104 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 105 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 106 107 $column = new CensusColumnYearsMarried($census, '', ''); 108 109 $this->assertSame('', $column->generate($individual)); 110 } 111 112 /** 113 * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried 114 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 115 */ 116 public function testMarriageBeforeCensus() { 117 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 118 $fact->shouldReceive('getDate')->andReturn(new Date('OCT 1851')); 119 120 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 121 $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); 122 123 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 124 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 125 126 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 127 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 128 129 $column = new CensusColumnYearsMarried($census, '', ''); 130 131 $this->assertSame('8', $column->generate($individual)); 132 } 133} 134