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 CensusColumnAgeMarried 28 */ 29class CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase 30{ 31 /** 32 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 33 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 34 * 35 * @return void 36 */ 37 public function testAgeMarried(): 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'], true)->willReturn(new Collection([$fact])); 44 45 $individual = $this->createMock(Individual::class); 46 $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840')); 47 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 48 49 $census = $this->createMock(CensusInterface::class); 50 $census->method('censusDate')->willReturn('01 JUN 1860'); 51 52 $column = new CensusColumnAgeMarried($census, '', ''); 53 54 $this->assertSame('19', $column->generate($individual, $individual)); 55 } 56 57 /** 58 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 59 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 60 * 61 * @return void 62 */ 63 public function testNoBirthDate(): void 64 { 65 $individual = $this->createMock(Individual::class); 66 $individual->method('getBirthDate')->willReturn(new Date('')); 67 $individual->method('spouseFamilies')->willReturn(new Collection()); 68 69 $census = $this->createMock(CensusInterface::class); 70 $census->method('censusDate')->willReturn('01 JUN 1860'); 71 72 $column = new CensusColumnAgeMarried($census, '', ''); 73 74 $this->assertSame('', $column->generate($individual, $individual)); 75 } 76 77 /** 78 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 79 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 80 * 81 * @return void 82 */ 83 public function testNoMarriage(): void 84 { 85 $family = $this->createMock(Family::class); 86 $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 87 88 $individual = $this->createMock(Individual::class); 89 $individual->method('getBirthDate')->willReturn(new Date('')); 90 $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 91 92 $census = $this->createMock(CensusInterface::class); 93 $census->method('censusDate')->willReturn('01 JUN 1860'); 94 95 $column = new CensusColumnAgeMarried($census, '', ''); 96 97 $this->assertSame('', $column->generate($individual, $individual)); 98 } 99 100 /** 101 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried 102 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 103 * 104 * @return void 105 */ 106 public function testNoSpouseFamily(): void 107 { 108 $individual = $this->createMock(Individual::class); 109 $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840')); 110 $individual->method('spouseFamilies')->willReturn(new Collection()); 111 112 $census = $this->createMock(CensusInterface::class); 113 $census->method('censusDate')->willReturn('01 JUN 1860'); 114 115 $column = new CensusColumnAgeMarried($census, '', ''); 116 117 $this->assertSame('', $column->generate($individual, $individual)); 118 } 119} 120