18e2171feSGreg Roach<?php 23976b470SGreg Roach 38e2171feSGreg Roach/** 48e2171feSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 68e2171feSGreg Roach * This program is free software: you can redistribute it and/or modify 78e2171feSGreg Roach * it under the terms of the GNU General Public License as published by 88e2171feSGreg Roach * the Free Software Foundation, either version 3 of the License, or 98e2171feSGreg Roach * (at your option) any later version. 108e2171feSGreg Roach * This program is distributed in the hope that it will be useful, 118e2171feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128e2171feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138e2171feSGreg Roach * GNU General Public License for more details. 148e2171feSGreg 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/>. 168e2171feSGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 208e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census; 218e2171feSGreg Roach 228e2171feSGreg 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; 298e2171feSGreg Roach 30*202c018bSGreg Roach#[CoversClass(CensusColumnMarriedWithinYear::class)] 31*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 323cfcc809SGreg Roachclass CensusColumnMarriedWithinYearTest extends TestCase 33c1010edaSGreg Roach{ 349b802b22SGreg Roach public function testMarriedWithinYear(): void 35c1010edaSGreg Roach { 36cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 370ecdbde6SGreg Roach $fact->method('date')->willReturn(new Date('01 DEC 1859')); 388e2171feSGreg Roach 39cd94ca66SGreg Roach $family = $this->createMock(Family::class); 400ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 418e2171feSGreg Roach 42cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 430ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 448e2171feSGreg Roach 45cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 460ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 478e2171feSGreg Roach 488e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 498e2171feSGreg Roach 505e933c21SGreg Roach self::assertSame('Y', $column->generate($individual, $individual)); 518e2171feSGreg Roach } 528e2171feSGreg Roach 539b802b22SGreg Roach public function testMarriedOverYearBeforeTheCensus(): void 54c1010edaSGreg Roach { 55cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 560ecdbde6SGreg Roach $fact->method('date')->willReturn(new Date('01 JAN 1859')); 578e2171feSGreg Roach 58cd94ca66SGreg Roach $family = $this->createMock(Family::class); 590ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 608e2171feSGreg Roach 61cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 620ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 638e2171feSGreg Roach 64cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 650ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 668e2171feSGreg Roach 678e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 688e2171feSGreg Roach 695e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 708e2171feSGreg Roach } 718e2171feSGreg Roach 729b802b22SGreg Roach public function testMarriedAfterTheCensus(): void 73c1010edaSGreg Roach { 74cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 750ecdbde6SGreg Roach $fact->method('date')->willReturn(new Date('02 JUN 1860')); 764fc9500eSGreg Roach 77cd94ca66SGreg Roach $family = $this->createMock(Family::class); 780ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 794fc9500eSGreg Roach 80cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 810ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 824fc9500eSGreg Roach 83cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 840ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 854fc9500eSGreg Roach 864fc9500eSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 874fc9500eSGreg Roach 885e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 894fc9500eSGreg Roach } 904fc9500eSGreg Roach 919b802b22SGreg Roach public function testNoMarriage(): void 92c1010edaSGreg Roach { 93cd94ca66SGreg Roach $family = $this->createMock(Family::class); 940ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 958e2171feSGreg Roach 96cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 970ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 988e2171feSGreg Roach 99cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 1000ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 1018e2171feSGreg Roach 1028e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 1038e2171feSGreg Roach 1045e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 1058e2171feSGreg Roach } 1068e2171feSGreg Roach 1079b802b22SGreg Roach public function testNoSpouseFamily(): void 108c1010edaSGreg Roach { 109cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 1100ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 1118e2171feSGreg Roach 112cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 1130ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 1148e2171feSGreg Roach 1158e2171feSGreg Roach $column = new CensusColumnMarriedWithinYear($census, '', ''); 1168e2171feSGreg Roach 1175e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 1188e2171feSGreg Roach } 1198e2171feSGreg Roach} 120