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