1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2015 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 */ 17 18namespace Fisharebest\Webtrees\Census; 19 20use Fisharebest\Webtrees\Date; 21use Fisharebest\Webtrees\Fact; 22use Fisharebest\Webtrees\Family; 23use Fisharebest\Webtrees\Individual; 24use Mockery; 25 26/** 27 * Test harness for the class CensusColumnMarriedWithinYear 28 */ 29class CensusColumnMarriedWithinYearTest extends \PHPUnit_Framework_TestCase { 30 /** 31 * Delete mock objects 32 */ 33 public function tearDown() { 34 Mockery::close(); 35 } 36 37 /** 38 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 39 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 40 */ 41 public function testMarriedWithinYear() { 42 $fact = Mockery::mock(Fact::class); 43 $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 44 45 $family = Mockery::mock(Family::class); 46 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 47 48 $individual = Mockery::mock(Individual::class); 49 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 50 51 $census = Mockery::mock(CensusInterface::class); 52 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 53 54 $column = new CensusColumnMarriedWithinYear($census, '', ''); 55 56 $this->assertSame('Y', $column->generate($individual)); 57 } 58 59 /** 60 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 61 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 62 */ 63 public function testNotMarriedWithinYear() { 64 $fact = Mockery::mock(Fact::class); 65 $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859')); 66 67 $family = Mockery::mock(Family::class); 68 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 69 70 $individual = Mockery::mock(Individual::class); 71 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 72 73 $census = Mockery::mock(CensusInterface::class); 74 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 75 76 $column = new CensusColumnMarriedWithinYear($census, '', ''); 77 78 $this->assertSame('', $column->generate($individual)); 79 } 80 81 /** 82 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 83 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 84 */ 85 public function testNoMarriage() { 86 $family = Mockery::mock(Family::class); 87 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 88 89 $individual = Mockery::mock(Individual::class); 90 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 91 92 $census = Mockery::mock(CensusInterface::class); 93 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 94 95 $column = new CensusColumnMarriedWithinYear($census, '', ''); 96 97 $this->assertSame('', $column->generate($individual)); 98 } 99 100 /** 101 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 102 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 103 */ 104 public function testNoSpouseFamily() { 105 $individual = Mockery::mock(Individual::class); 106 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 107 108 $census = Mockery::mock(CensusInterface::class); 109 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 110 111 $column = new CensusColumnMarriedWithinYear($census, '', ''); 112 113 $this->assertSame('', $column->generate($individual)); 114 } 115} 116