1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Census; 19 20use Fisharebest\Webtrees\Date; 21use Fisharebest\Webtrees\Fact; 22use Fisharebest\Webtrees\Family; 23use Fisharebest\Webtrees\Individual; 24use Illuminate\Support\Collection; 25 26/** 27 * Test harness for the class CensusColumnMarriedWithinYear 28 */ 29class CensusColumnMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase 30{ 31 /** 32 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 33 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 34 * 35 * @return void 36 */ 37 public function testMarriedWithinYear(): void 38 { 39 $fact = $this->createMock(Fact::class); 40 $fact->method('date')->willReturn(new Date('01 DEC 1859')); 41 42 $family = $this->createMock(Family::class); 43 $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 44 45 $individual = $this->createMock(Individual::class); 46 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 47 48 $census = $this->createMock(CensusInterface::class); 49 $census->method('censusDate')->willReturn('01 JUN 1860'); 50 51 $column = new CensusColumnMarriedWithinYear($census, '', ''); 52 53 $this->assertSame('Y', $column->generate($individual, $individual)); 54 } 55 56 /** 57 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 58 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 59 * 60 * @return void 61 */ 62 public function testMarriedOverYearBeforeTheCensus(): void 63 { 64 $fact = $this->createMock(Fact::class); 65 $fact->method('date')->willReturn(new Date('01 JAN 1859')); 66 67 $family = $this->createMock(Family::class); 68 $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 69 70 $individual = $this->createMock(Individual::class); 71 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 72 73 $census = $this->createMock(CensusInterface::class); 74 $census->method('censusDate')->willReturn('01 JUN 1860'); 75 76 $column = new CensusColumnMarriedWithinYear($census, '', ''); 77 78 $this->assertSame('', $column->generate($individual, $individual)); 79 } 80 81 /** 82 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 83 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 84 * 85 * @return void 86 */ 87 public function testMarriedAfterTheCensus(): void 88 { 89 $fact = $this->createMock(Fact::class); 90 $fact->method('date')->willReturn(new Date('02 JUN 1860')); 91 92 $family = $this->createMock(Family::class); 93 $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 94 95 $individual = $this->createMock(Individual::class); 96 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 97 98 $census = $this->createMock(CensusInterface::class); 99 $census->method('censusDate')->willReturn('01 JUN 1860'); 100 101 $column = new CensusColumnMarriedWithinYear($census, '', ''); 102 103 $this->assertSame('', $column->generate($individual, $individual)); 104 } 105 106 /** 107 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 108 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 109 * 110 * @return void 111 */ 112 public function testNoMarriage(): void 113 { 114 $family = $this->createMock(Family::class); 115 $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 116 117 $individual = $this->createMock(Individual::class); 118 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 119 120 $census = $this->createMock(CensusInterface::class); 121 $census->method('censusDate')->willReturn('01 JUN 1860'); 122 123 $column = new CensusColumnMarriedWithinYear($census, '', ''); 124 125 $this->assertSame('', $column->generate($individual, $individual)); 126 } 127 128 /** 129 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear 130 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 131 * 132 * @return void 133 */ 134 public function testNoSpouseFamily(): void 135 { 136 $individual = $this->createMock(Individual::class); 137 $individual->method('spouseFamilies')->willReturn(new Collection()); 138 139 $census = $this->createMock(CensusInterface::class); 140 $census->method('censusDate')->willReturn('01 JUN 1860'); 141 142 $column = new CensusColumnMarriedWithinYear($census, '', ''); 143 144 $this->assertSame('', $column->generate($individual, $individual)); 145 } 146} 147