18e2171feSGreg Roach<?php 28e2171feSGreg Roach/** 38e2171feSGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 58e2171feSGreg Roach * This program is free software: you can redistribute it and/or modify 68e2171feSGreg Roach * it under the terms of the GNU General Public License as published by 78e2171feSGreg Roach * the Free Software Foundation, either version 3 of the License, or 88e2171feSGreg Roach * (at your option) any later version. 98e2171feSGreg Roach * This program is distributed in the hope that it will be useful, 108e2171feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 118e2171feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 128e2171feSGreg Roach * GNU General Public License for more details. 138e2171feSGreg Roach * You should have received a copy of the GNU General Public License 148e2171feSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 158e2171feSGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 188e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census; 198e2171feSGreg Roach 208e2171feSGreg Roachuse Fisharebest\Webtrees\Date; 21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 248e2171feSGreg Roachuse Mockery; 258e2171feSGreg Roach 268e2171feSGreg Roach/** 278e2171feSGreg Roach * Test harness for the class CensusColumnMarriedWithinYear 288e2171feSGreg Roach */ 2984e2cf4eSGreg Roachclass CensusColumnMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase 30c1010edaSGreg Roach{ 318e2171feSGreg Roach /** 328e2171feSGreg Roach * Delete mock objects 3352348eb8SGreg Roach * 3452348eb8SGreg Roach * @return void 358e2171feSGreg Roach */ 36c1010edaSGreg Roach public function tearDown() 37c1010edaSGreg Roach { 388e2171feSGreg Roach Mockery::close(); 398e2171feSGreg Roach } 408e2171feSGreg Roach 418e2171feSGreg Roach /** 4215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 4315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 4452348eb8SGreg Roach * 4552348eb8SGreg Roach * @return void 468e2171feSGreg Roach */ 47*9b802b22SGreg Roach public function testMarriedWithinYear(): void 48c1010edaSGreg Roach { 49ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 502decada7SGreg Roach $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859')); 518e2171feSGreg Roach 52ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 538d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 548e2171feSGreg Roach 55ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 5613abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 578e2171feSGreg Roach 58ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 598e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 608e2171feSGreg Roach 618e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 628e2171feSGreg Roach 63342dcecdSGreg Roach $this->assertSame('Y', $column->generate($individual, $individual)); 648e2171feSGreg Roach } 658e2171feSGreg Roach 668e2171feSGreg Roach /** 6715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 6815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 6952348eb8SGreg Roach * 7052348eb8SGreg Roach * @return void 718e2171feSGreg Roach */ 72*9b802b22SGreg Roach public function testMarriedOverYearBeforeTheCensus(): void 73c1010edaSGreg Roach { 74ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 752decada7SGreg Roach $fact->shouldReceive('date')->andReturn(new Date('01 JAN 1859')); 768e2171feSGreg Roach 77ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 788d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 798e2171feSGreg Roach 80ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 8113abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 828e2171feSGreg Roach 83ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 848e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 858e2171feSGreg Roach 868e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 878e2171feSGreg Roach 88342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 898e2171feSGreg Roach } 908e2171feSGreg Roach 918e2171feSGreg Roach /** 9215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 9315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 9452348eb8SGreg Roach * 9552348eb8SGreg Roach * @return void 968e2171feSGreg Roach */ 97*9b802b22SGreg Roach public function testMarriedAfterTheCensus(): void 98c1010edaSGreg Roach { 99ddf438a5SGreg Roach $fact = Mockery::mock(Fact::class); 1002decada7SGreg Roach $fact->shouldReceive('date')->andReturn(new Date('02 JUN 1860')); 1014fc9500eSGreg Roach 102ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 1038d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]); 1044fc9500eSGreg Roach 105ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 10613abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1074fc9500eSGreg Roach 108ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 1094fc9500eSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1104fc9500eSGreg Roach 1114fc9500eSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 1124fc9500eSGreg Roach 113342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 1144fc9500eSGreg Roach } 1154fc9500eSGreg Roach 1164fc9500eSGreg Roach /** 11715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 11815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 11952348eb8SGreg Roach * 12052348eb8SGreg Roach * @return void 1214fc9500eSGreg Roach */ 122*9b802b22SGreg Roach public function testNoMarriage(): void 123c1010edaSGreg Roach { 124ddf438a5SGreg Roach $family = Mockery::mock(Family::class); 1258d0ebef0SGreg Roach $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); 1268e2171feSGreg Roach 127ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 12813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 1298e2171feSGreg Roach 130ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 1318e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1328e2171feSGreg Roach 1338e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 1348e2171feSGreg Roach 135342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 1368e2171feSGreg Roach } 1378e2171feSGreg Roach 1388e2171feSGreg Roach /** 13915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 14015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 14152348eb8SGreg Roach * 14252348eb8SGreg Roach * @return void 1438e2171feSGreg Roach */ 144*9b802b22SGreg Roach public function testNoSpouseFamily(): void 145c1010edaSGreg Roach { 146ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 14713abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 1488e2171feSGreg Roach 149ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 1508e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 1518e2171feSGreg Roach 1528e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 1538e2171feSGreg Roach 154342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 1558e2171feSGreg Roach } 1568e2171feSGreg Roach} 157