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