181d1be7aSGreg Roach<?php 23976b470SGreg Roach 381d1be7aSGreg Roach/** 481d1be7aSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 681d1be7aSGreg Roach * This program is free software: you can redistribute it and/or modify 781d1be7aSGreg Roach * it under the terms of the GNU General Public License as published by 881d1be7aSGreg Roach * the Free Software Foundation, either version 3 of the License, or 981d1be7aSGreg Roach * (at your option) any later version. 1081d1be7aSGreg Roach * This program is distributed in the hope that it will be useful, 1181d1be7aSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1281d1be7aSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1381d1be7aSGreg Roach * GNU General Public License for more details. 1481d1be7aSGreg Roach * You should have received a copy of the GNU General Public License 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1681d1be7aSGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2081d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census; 2181d1be7aSGreg Roach 2281d1be7aSGreg Roachuse Fisharebest\Webtrees\Date; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 25ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 263cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 2739ca88baSGreg Roachuse Illuminate\Support\Collection; 28*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 2981d1be7aSGreg Roach 30*202c018bSGreg Roach#[CoversClass(CensusColumnAgeMarried::class)] 31*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 323cfcc809SGreg Roachclass CensusColumnAgeMarriedTest extends TestCase 33c1010edaSGreg Roach{ 349b802b22SGreg Roach public function testAgeMarried(): void 35c1010edaSGreg Roach { 36cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 370ecdbde6SGreg Roach $fact->method('date')->willReturn(new Date('01 DEC 1859')); 3881d1be7aSGreg Roach 39cd94ca66SGreg Roach $family = $this->createMock(Family::class); 400ecdbde6SGreg Roach $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); 4181d1be7aSGreg Roach 42cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 430ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840')); 440ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 4581d1be7aSGreg Roach 46cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 470ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 4881d1be7aSGreg Roach 4981d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 5081d1be7aSGreg Roach 515e933c21SGreg Roach self::assertSame('19', $column->generate($individual, $individual)); 5281d1be7aSGreg Roach } 5381d1be7aSGreg Roach 549b802b22SGreg Roach public function testNoBirthDate(): void 55c1010edaSGreg Roach { 56cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 570ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('')); 580ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 593e983931SGreg Roach 60cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 610ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 623e983931SGreg Roach 633e983931SGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 643e983931SGreg Roach 655e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 6681d1be7aSGreg Roach } 6781d1be7aSGreg Roach 689b802b22SGreg Roach public function testNoMarriage(): void 69c1010edaSGreg Roach { 70cd94ca66SGreg Roach $family = $this->createMock(Family::class); 710ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 7281d1be7aSGreg Roach 73cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 740ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('')); 750ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 7681d1be7aSGreg Roach 77cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 780ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 7981d1be7aSGreg Roach 8081d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 8181d1be7aSGreg Roach 825e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 8381d1be7aSGreg Roach } 8481d1be7aSGreg Roach 859b802b22SGreg Roach public function testNoSpouseFamily(): void 86c1010edaSGreg Roach { 87cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 880ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840')); 890ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 9081d1be7aSGreg Roach 91cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 920ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 9381d1be7aSGreg Roach 9481d1be7aSGreg Roach $column = new CensusColumnAgeMarried($census, '', ''); 9581d1be7aSGreg Roach 965e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 9781d1be7aSGreg Roach } 9881d1be7aSGreg Roach} 99