xref: /webtrees/tests/app/Census/CensusColumnYearsMarriedTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
17338314fSGreg Roach<?php
23976b470SGreg Roach
37338314fSGreg Roach/**
47338314fSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
67338314fSGreg Roach * This program is free software: you can redistribute it and/or modify
77338314fSGreg Roach * it under the terms of the GNU General Public License as published by
87338314fSGreg Roach * the Free Software Foundation, either version 3 of the License, or
97338314fSGreg Roach * (at your option) any later version.
107338314fSGreg Roach * This program is distributed in the hope that it will be useful,
117338314fSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
127338314fSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
137338314fSGreg Roach * GNU General Public License for more details.
147338314fSGreg 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/>.
167338314fSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
207338314fSGreg Roachnamespace Fisharebest\Webtrees\Census;
217338314fSGreg Roach
227338314fSGreg 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;
297338314fSGreg Roach
30*202c018bSGreg Roach#[CoversClass(CensusColumnYearsMarried::class)]
31*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
323cfcc809SGreg Roachclass CensusColumnYearsMarriedTest extends TestCase
33c1010edaSGreg Roach{
349b802b22SGreg Roach    public function testNoSpouseFamily(): void
35c1010edaSGreg Roach    {
36cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
370ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
387338314fSGreg Roach
39cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
400ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
417338314fSGreg Roach
427338314fSGreg Roach        $column = new CensusColumnYearsMarried($census, '', '');
437338314fSGreg Roach
445e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
457338314fSGreg Roach    }
467338314fSGreg Roach
479b802b22SGreg Roach    public function testNoMarriage(): void
48c1010edaSGreg Roach    {
49cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
500ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'], true)->willReturn(new Collection());
517338314fSGreg Roach
52cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
530ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
547338314fSGreg Roach
55cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
560ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
577338314fSGreg Roach
587338314fSGreg Roach        $column = new CensusColumnYearsMarried($census, '', '');
597338314fSGreg Roach
605e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
617338314fSGreg Roach    }
627338314fSGreg Roach
639b802b22SGreg Roach    public function testUndatedMarriage(): void
64c1010edaSGreg Roach    {
65cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
660ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date(''));
677338314fSGreg Roach
68cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
690ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact]));
707338314fSGreg Roach
71cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
720ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
737338314fSGreg Roach
74cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
750ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
767338314fSGreg Roach
777338314fSGreg Roach        $column = new CensusColumnYearsMarried($census, '', '');
787338314fSGreg Roach
795e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
807338314fSGreg Roach    }
817338314fSGreg Roach
829b802b22SGreg Roach    public function testMarriageAfterCensus(): void
83c1010edaSGreg Roach    {
84cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
850ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('1861'));
867338314fSGreg Roach
87cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
880ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact]));
897338314fSGreg Roach
90cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
910ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
927338314fSGreg Roach
93cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
940ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
957338314fSGreg Roach
967338314fSGreg Roach        $column = new CensusColumnYearsMarried($census, '', '');
977338314fSGreg Roach
985e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
997338314fSGreg Roach    }
1007338314fSGreg Roach
1019b802b22SGreg Roach    public function testMarriageBeforeCensus(): void
102c1010edaSGreg Roach    {
103cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
1040ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('OCT 1851'));
1057338314fSGreg Roach
106cd94ca66SGreg Roach        $family = $this->createMock(Family::class);
1070ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact]));
1087338314fSGreg Roach
109cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1100ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1117338314fSGreg Roach
112cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1130ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1147338314fSGreg Roach
1157338314fSGreg Roach        $column = new CensusColumnYearsMarried($census, '', '');
1167338314fSGreg Roach
1175e933c21SGreg Roach        self::assertSame('8', $column->generate($individual, $individual));
1187338314fSGreg Roach    }
1197338314fSGreg Roach}
120