1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2018 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16namespace Fisharebest\Webtrees\Census; 17 18use Fisharebest\Webtrees\Date; 19use Mockery; 20 21/** 22 * Test harness for the class CensusColumnMarriedWithinYear 23 */ 24class CensusColumnMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase 25{ 26 /** 27 * Delete mock objects 28 * 29 * @return void 30 */ 31 public function tearDown() 32 { 33 Mockery::close(); 34 } 35 36 /** 37 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 38 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 39 * 40 * @return void 41 */ 42 public function testMarriedWithinYear() 43 { 44 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 45 $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 46 47 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 48 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 49 50 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 51 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 52 53 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 54 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 55 56 $column = new CensusColumnMarriedWithinYear($census, '', ''); 57 58 $this->assertSame('Y', $column->generate($individual, $individual)); 59 } 60 61 /** 62 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 63 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 64 * 65 * @return void 66 */ 67 public function testMarriedOverYearBeforeTheCensus() 68 { 69 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 70 $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859')); 71 72 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 73 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 74 75 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 76 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 77 78 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 79 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 80 81 $column = new CensusColumnMarriedWithinYear($census, '', ''); 82 83 $this->assertSame('', $column->generate($individual, $individual)); 84 } 85 86 /** 87 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 88 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 89 * 90 * @return void 91 */ 92 public function testMarriedAfterTheCensus() 93 { 94 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 95 $fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860')); 96 97 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 98 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 99 100 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 101 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 102 103 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 104 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 105 106 $column = new CensusColumnMarriedWithinYear($census, '', ''); 107 108 $this->assertSame('', $column->generate($individual, $individual)); 109 } 110 111 /** 112 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 113 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 114 * 115 * @return void 116 */ 117 public function testNoMarriage() 118 { 119 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 120 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 121 122 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 123 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 124 125 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 126 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 127 128 $column = new CensusColumnMarriedWithinYear($census, '', ''); 129 130 $this->assertSame('', $column->generate($individual, $individual)); 131 } 132 133 /** 134 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 135 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 136 * 137 * @return void 138 */ 139 public function testNoSpouseFamily() 140 { 141 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 142 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 143 144 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 145 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 146 147 $column = new CensusColumnMarriedWithinYear($census, '', ''); 148 149 $this->assertSame('', $column->generate($individual, $individual)); 150 } 151} 152