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