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 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Census; 19 20use Fisharebest\Webtrees\Date; 21use Mockery; 22 23/** 24 * Test harness for the class CensusColumnMonthIfMarriedWithinYear 25 */ 26class CensusColumnMonthIfMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase 27{ 28 /** 29 * Delete mock objects 30 * 31 * @return void 32 */ 33 public function tearDown() 34 { 35 Mockery::close(); 36 } 37 38 /** 39 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 40 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 41 * 42 * @return void 43 */ 44 public function testMarriedWithinYear() 45 { 46 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 47 $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859')); 48 49 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 50 $family->shouldReceive('facts')->with('MARR')->andReturn([$fact]); 51 52 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 53 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 54 55 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 56 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 57 58 $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 59 60 $this->assertSame('Dec', $column->generate($individual, $individual)); 61 } 62 63 /** 64 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 65 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 66 * 67 * @return void 68 */ 69 public function testMarriedOverYearBeforeTheCensus() 70 { 71 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 72 $fact->shouldReceive('date')->andReturn(new Date('01 JAN 1859')); 73 74 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 75 $family->shouldReceive('facts')->with('MARR')->andReturn([$fact]); 76 77 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 78 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 79 80 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 81 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 82 83 $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 84 85 $this->assertSame('', $column->generate($individual, $individual)); 86 } 87 88 /** 89 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 90 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 91 * 92 * @return void 93 */ 94 public function testMarriedAfterTheCensus() 95 { 96 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 97 $fact->shouldReceive('date')->andReturn(new Date('02 JUN 1860')); 98 99 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 100 $family->shouldReceive('facts')->with('MARR')->andReturn([$fact]); 101 102 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 103 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 104 105 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 106 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 107 108 $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 109 110 $this->assertSame('', $column->generate($individual, $individual)); 111 } 112 113 /** 114 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 115 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 116 * 117 * @return void 118 */ 119 public function testNoMarriage() 120 { 121 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 122 $family->shouldReceive('facts')->with('MARR')->andReturn([]); 123 124 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 125 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 126 127 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 128 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 129 130 $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 131 132 $this->assertSame('', $column->generate($individual, $individual)); 133 } 134 135 /** 136 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 137 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 138 * 139 * @return void 140 */ 141 public function testNoSpouseFamily() 142 { 143 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 144 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 145 146 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 147 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 148 149 $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 150 151 $this->assertSame('', $column->generate($individual, $individual)); 152 } 153} 154