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 CensusColumnYearsMarried 28 */ 29class CensusColumnYearsMarriedTest extends \Fisharebest\Webtrees\TestCase 30{ 31 /** 32 * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried 33 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 34 * 35 * @return void 36 */ 37 public function testNoSpouseFamily(): void 38 { 39 $individual = $this->createMock(Individual::class); 40 $individual->method('spouseFamilies')->willReturn(new Collection()); 41 42 $census = $this->createMock(CensusInterface::class); 43 $census->method('censusDate')->willReturn('01 JUN 1860'); 44 45 $column = new CensusColumnYearsMarried($census, '', ''); 46 47 $this->assertSame('', $column->generate($individual, $individual)); 48 } 49 50 /** 51 * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried 52 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 53 * 54 * @return void 55 */ 56 public function testNoMarriage(): void 57 { 58 $family = $this->createMock(Family::class); 59 $family->method('facts')->with(['MARR'], true)->willReturn(new Collection()); 60 61 $individual = $this->createMock(Individual::class); 62 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 63 64 $census = $this->createMock(CensusInterface::class); 65 $census->method('censusDate')->willReturn('01 JUN 1860'); 66 67 $column = new CensusColumnYearsMarried($census, '', ''); 68 69 $this->assertSame('', $column->generate($individual, $individual)); 70 } 71 72 /** 73 * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried 74 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 75 * 76 * @return void 77 */ 78 public function testUndatedMarriage(): void 79 { 80 $fact = $this->createMock(Fact::class); 81 $fact->method('date')->willReturn(new Date('')); 82 83 $family = $this->createMock(Family::class); 84 $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); 85 86 $individual = $this->createMock(Individual::class); 87 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 88 89 $census = $this->createMock(CensusInterface::class); 90 $census->method('censusDate')->willReturn('01 JUN 1860'); 91 92 $column = new CensusColumnYearsMarried($census, '', ''); 93 94 $this->assertSame('', $column->generate($individual, $individual)); 95 } 96 97 /** 98 * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried 99 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 100 * 101 * @return void 102 */ 103 public function testMarriageAfterCensus(): void 104 { 105 $fact = $this->createMock(Fact::class); 106 $fact->method('date')->willReturn(new Date('1861')); 107 108 $family = $this->createMock(Family::class); 109 $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); 110 111 $individual = $this->createMock(Individual::class); 112 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 113 114 $census = $this->createMock(CensusInterface::class); 115 $census->method('censusDate')->willReturn('01 JUN 1860'); 116 117 $column = new CensusColumnYearsMarried($census, '', ''); 118 119 $this->assertSame('', $column->generate($individual, $individual)); 120 } 121 122 /** 123 * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried 124 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 125 * 126 * @return void 127 */ 128 public function testMarriageBeforeCensus(): void 129 { 130 $fact = $this->createMock(Fact::class); 131 $fact->method('date')->willReturn(new Date('OCT 1851')); 132 133 $family = $this->createMock(Family::class); 134 $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); 135 136 $individual = $this->createMock(Individual::class); 137 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 138 139 $census = $this->createMock(CensusInterface::class); 140 $census->method('censusDate')->willReturn('01 JUN 1860'); 141 142 $column = new CensusColumnYearsMarried($census, '', ''); 143 144 $this->assertSame('8', $column->generate($individual, $individual)); 145 } 146} 147