18e2171feSGreg Roach<?php 28e2171feSGreg Roach 38e2171feSGreg Roach/** 48e2171feSGreg Roach * webtrees: online genealogy 51062a142SGreg Roach * Copyright (C) 2018 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 */ 25c1010edaSGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \PHPUnit\Framework\TestCase 26c1010edaSGreg Roach{ 278e2171feSGreg Roach /** 288e2171feSGreg Roach * Delete mock objects 298e2171feSGreg Roach */ 30c1010edaSGreg Roach public function tearDown() 31c1010edaSGreg Roach { 328e2171feSGreg Roach Mockery::close(); 338e2171feSGreg Roach } 348e2171feSGreg Roach 358e2171feSGreg Roach /** 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 3715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 388e2171feSGreg Roach */ 39c1010edaSGreg Roach public function testMarriedWithinYear() 40c1010edaSGreg Roach { 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'); 4513abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 468e2171feSGreg Roach 47c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 4813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$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 55*342dcecdSGreg Roach $this->assertSame('Dec', $column->generate($individual, $individual)); 568e2171feSGreg Roach } 578e2171feSGreg Roach 588e2171feSGreg Roach /** 5915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 6015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 618e2171feSGreg Roach */ 62c1010edaSGreg Roach public function testMarriedOverYearBeforeTheCensus() 63c1010edaSGreg Roach { 64c314ecc9SGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 658e2171feSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859')); 668e2171feSGreg Roach 67c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 6813abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 698e2171feSGreg Roach 70c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 7113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 728e2171feSGreg Roach 73c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 748e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 758e2171feSGreg Roach 768e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 778e2171feSGreg Roach 78*342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 798e2171feSGreg Roach } 808e2171feSGreg Roach 818e2171feSGreg Roach /** 8215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 8315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 848e2171feSGreg Roach */ 85c1010edaSGreg Roach public function testMarriedAfterTheCensus() 86c1010edaSGreg Roach { 874fc9500eSGreg Roach $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 884fc9500eSGreg Roach $fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860')); 894fc9500eSGreg Roach 904fc9500eSGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 9113abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 924fc9500eSGreg Roach 934fc9500eSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 9413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 954fc9500eSGreg Roach 964fc9500eSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 974fc9500eSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 984fc9500eSGreg Roach 994fc9500eSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 1004fc9500eSGreg Roach 101*342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 1024fc9500eSGreg Roach } 1034fc9500eSGreg Roach 1044fc9500eSGreg Roach /** 10515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 10615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 1074fc9500eSGreg Roach */ 108c1010edaSGreg Roach public function testNoMarriage() 109c1010edaSGreg Roach { 110c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 11113abd6f3SGreg Roach $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 1128e2171feSGreg Roach 113c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 11413abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1158e2171feSGreg Roach 116c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 1178e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1188e2171feSGreg Roach 1198e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 1208e2171feSGreg Roach 121*342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 1228e2171feSGreg Roach } 1238e2171feSGreg Roach 1248e2171feSGreg Roach /** 12515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear 12615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 1278e2171feSGreg Roach */ 128c1010edaSGreg Roach public function testNoSpouseFamily() 129c1010edaSGreg Roach { 130c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 13113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 1328e2171feSGreg Roach 133c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 1348e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1358e2171feSGreg Roach 1368e2171feSGreg Roach $column = new CensusColumnMonthIfMarriedWithinYear($census, '', ''); 1378e2171feSGreg Roach 138*342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 1398e2171feSGreg Roach } 1408e2171feSGreg Roach} 141