18e2171feSGreg Roach<?php 28e2171feSGreg Roach 38e2171feSGreg Roach/** 48e2171feSGreg Roach * webtrees: online genealogy 56bdf7674SGreg Roach * Copyright (C) 2017 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 Mockery; 218e2171feSGreg Roach 228e2171feSGreg Roach/** 238e2171feSGreg Roach * Test harness for the class CensusColumnMonthIfMarriedWithinYear 248e2171feSGreg Roach */ 25*3e983931SGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \PHPUnit\Framework\TestCase { 268e2171feSGreg Roach /** 278e2171feSGreg Roach * Delete mock objects 288e2171feSGreg Roach */ 298e2171feSGreg Roach public function tearDown() { 308e2171feSGreg Roach Mockery::close(); 318e2171feSGreg Roach } 328e2171feSGreg Roach 338e2171feSGreg Roach /** 3415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 368e2171feSGreg Roach */ 378e2171feSGreg Roach public function testMarriedWithinYear() { 38c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 398e2171feSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); 408e2171feSGreg Roach 41c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 4213abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 438e2171feSGreg Roach 44c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 4513abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 468e2171feSGreg Roach 47c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 488e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 498e2171feSGreg Roach 508e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 518e2171feSGreg Roach 528e2171feSGreg Roach $this->assertSame('Dec', $column->generate($individual)); 538e2171feSGreg Roach } 548e2171feSGreg Roach 558e2171feSGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 5715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 588e2171feSGreg Roach */ 594fc9500eSGreg Roach public function testMarriedOverYearBeforeTheCensus() { 60c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 618e2171feSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859')); 628e2171feSGreg Roach 63c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 6413abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 658e2171feSGreg Roach 66c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 6713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 688e2171feSGreg Roach 69c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 708e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 718e2171feSGreg Roach 728e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 738e2171feSGreg Roach 748e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 758e2171feSGreg Roach } 768e2171feSGreg Roach 778e2171feSGreg Roach /** 7815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 7915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 808e2171feSGreg Roach */ 814fc9500eSGreg Roach public function testMarriedAfterTheCensus() { 824fc9500eSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 834fc9500eSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860')); 844fc9500eSGreg Roach 854fc9500eSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 8613abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 874fc9500eSGreg Roach 884fc9500eSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 8913abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 904fc9500eSGreg Roach 914fc9500eSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 924fc9500eSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 934fc9500eSGreg Roach 944fc9500eSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 954fc9500eSGreg Roach 964fc9500eSGreg Roach $this->assertSame('', $column->generate($individual)); 974fc9500eSGreg Roach } 984fc9500eSGreg Roach 994fc9500eSGreg Roach /** 10015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 10115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 1024fc9500eSGreg Roach */ 1038e2171feSGreg Roach public function testNoMarriage() { 104c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 10513abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 1068e2171feSGreg Roach 107c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 10813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1098e2171feSGreg Roach 110c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 1118e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1128e2171feSGreg Roach 1138e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 1148e2171feSGreg Roach 1158e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 1168e2171feSGreg Roach } 1178e2171feSGreg Roach 1188e2171feSGreg Roach /** 11915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 12015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 1218e2171feSGreg Roach */ 1228e2171feSGreg Roach public function testNoSpouseFamily() { 123c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 12413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 1258e2171feSGreg Roach 126c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 1278e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1288e2171feSGreg Roach 1298e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 1308e2171feSGreg Roach 1318e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 1328e2171feSGreg Roach } 1338e2171feSGreg Roach} 134