18e2171feSGreg Roach<?php 28e2171feSGreg Roach 38e2171feSGreg Roach/** 48e2171feSGreg Roach * webtrees: online genealogy 5*369c0ce6SGreg Roach * Copyright (C) 2016 webtrees development team 68e2171feSGreg Roach * This program is free software: you can redistribute it and/or modify 78e2171feSGreg Roach * it under the terms of the GNU General Public License as published by 88e2171feSGreg Roach * the Free Software Foundation, either version 3 of the License, or 98e2171feSGreg Roach * (at your option) any later version. 108e2171feSGreg Roach * This program is distributed in the hope that it will be useful, 118e2171feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128e2171feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138e2171feSGreg Roach * GNU General Public License for more details. 148e2171feSGreg Roach * You should have received a copy of the GNU General Public License 158e2171feSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 168e2171feSGreg Roach */ 178e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census; 188e2171feSGreg Roach 198e2171feSGreg Roachuse Fisharebest\Webtrees\Date; 208e2171feSGreg Roachuse Fisharebest\Webtrees\Fact; 218e2171feSGreg Roachuse Fisharebest\Webtrees\Family; 228e2171feSGreg Roachuse Fisharebest\Webtrees\Individual; 238e2171feSGreg Roachuse Mockery; 248e2171feSGreg Roach 258e2171feSGreg Roach/** 268e2171feSGreg Roach * Test harness for the class CensusColumnMonthIfMarriedWithinYear 278e2171feSGreg Roach */ 288e2171feSGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \PHPUnit_Framework_TestCase { 298e2171feSGreg Roach /** 308e2171feSGreg Roach * Delete mock objects 318e2171feSGreg Roach */ 328e2171feSGreg Roach public function tearDown() { 338e2171feSGreg Roach Mockery::close(); 348e2171feSGreg Roach } 358e2171feSGreg Roach 368e2171feSGreg Roach /** 378e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 388e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 398e2171feSGreg Roach */ 408e2171feSGreg Roach public function testMarriedWithinYear() { 41c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 428e2171feSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 438e2171feSGreg Roach 44c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 45e2052359SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn(array($fact)); 468e2171feSGreg Roach 47c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 48e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 498e2171feSGreg Roach 50c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 518e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 528e2171feSGreg Roach 538e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 548e2171feSGreg Roach 558e2171feSGreg Roach $this->assertSame('Dec', $column->generate($individual)); 568e2171feSGreg Roach } 578e2171feSGreg Roach 588e2171feSGreg Roach /** 598e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 608e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 618e2171feSGreg Roach */ 628e2171feSGreg Roach public function testNotMarriedWithinYear() { 63c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 648e2171feSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859')); 658e2171feSGreg Roach 66c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 67e2052359SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn(array($fact)); 688e2171feSGreg Roach 69c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 70e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 718e2171feSGreg Roach 72c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 738e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 748e2171feSGreg Roach 758e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 768e2171feSGreg Roach 778e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 788e2171feSGreg Roach } 798e2171feSGreg Roach 808e2171feSGreg Roach /** 818e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 828e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 838e2171feSGreg Roach */ 848e2171feSGreg Roach public function testNoMarriage() { 85c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 86e2052359SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn(array()); 878e2171feSGreg Roach 88c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 89e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 908e2171feSGreg Roach 91c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 928e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 938e2171feSGreg Roach 948e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 958e2171feSGreg Roach 968e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 978e2171feSGreg Roach } 988e2171feSGreg Roach 998e2171feSGreg Roach /** 1008e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 1018e2171feSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 1028e2171feSGreg Roach */ 1038e2171feSGreg Roach public function testNoSpouseFamily() { 104c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 105e2052359SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); 1068e2171feSGreg Roach 107c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 1088e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1098e2171feSGreg Roach 1108e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 1118e2171feSGreg Roach 1128e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 1138e2171feSGreg Roach } 1148e2171feSGreg Roach} 115