xref: /webtrees/tests/app/Census/CensusColumnMarriedWithinYearTest.php (revision 5e933c21f8006e675d1df8bcedc634ee61f4aec2)
18e2171feSGreg Roach<?php
23976b470SGreg Roach
38e2171feSGreg Roach/**
48e2171feSGreg Roach * webtrees: online genealogy
5*5e933c21SGreg Roach * Copyright (C) 2020 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
158e2171feSGreg Roach * along with this program. If not, see <http://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;
288e2171feSGreg Roach
298e2171feSGreg Roach/**
308e2171feSGreg Roach * Test harness for the class CensusColumnMarriedWithinYear
318e2171feSGreg Roach */
323cfcc809SGreg Roachclass CensusColumnMarriedWithinYearTest extends TestCase
33c1010edaSGreg Roach{
348e2171feSGreg Roach    /**
3515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
3752348eb8SGreg Roach     *
3852348eb8SGreg Roach     * @return void
398e2171feSGreg Roach     */
409b802b22SGreg Roach    public function testMarriedWithinYear(): void
41c1010edaSGreg Roach    {
42*5e933c21SGreg Roach        $fact = self::createMock(Fact::class);
430ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('01 DEC 1859'));
448e2171feSGreg Roach
45*5e933c21SGreg Roach        $family = self::createMock(Family::class);
460ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
478e2171feSGreg Roach
48*5e933c21SGreg Roach        $individual = self::createMock(Individual::class);
490ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
508e2171feSGreg Roach
51*5e933c21SGreg Roach        $census = self::createMock(CensusInterface::class);
520ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
538e2171feSGreg Roach
548e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
558e2171feSGreg Roach
56*5e933c21SGreg Roach        self::assertSame('Y', $column->generate($individual, $individual));
578e2171feSGreg Roach    }
588e2171feSGreg Roach
598e2171feSGreg Roach    /**
6015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
6115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6252348eb8SGreg Roach     *
6352348eb8SGreg Roach     * @return void
648e2171feSGreg Roach     */
659b802b22SGreg Roach    public function testMarriedOverYearBeforeTheCensus(): void
66c1010edaSGreg Roach    {
67*5e933c21SGreg Roach        $fact = self::createMock(Fact::class);
680ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('01 JAN 1859'));
698e2171feSGreg Roach
70*5e933c21SGreg Roach        $family = self::createMock(Family::class);
710ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
728e2171feSGreg Roach
73*5e933c21SGreg Roach        $individual = self::createMock(Individual::class);
740ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
758e2171feSGreg Roach
76*5e933c21SGreg Roach        $census = self::createMock(CensusInterface::class);
770ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
788e2171feSGreg Roach
798e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
808e2171feSGreg Roach
81*5e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
828e2171feSGreg Roach    }
838e2171feSGreg Roach
848e2171feSGreg Roach    /**
8515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
8615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
8752348eb8SGreg Roach     *
8852348eb8SGreg Roach     * @return void
898e2171feSGreg Roach     */
909b802b22SGreg Roach    public function testMarriedAfterTheCensus(): void
91c1010edaSGreg Roach    {
92*5e933c21SGreg Roach        $fact = self::createMock(Fact::class);
930ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('02 JUN 1860'));
944fc9500eSGreg Roach
95*5e933c21SGreg Roach        $family = self::createMock(Family::class);
960ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
974fc9500eSGreg Roach
98*5e933c21SGreg Roach        $individual = self::createMock(Individual::class);
990ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1004fc9500eSGreg Roach
101*5e933c21SGreg Roach        $census = self::createMock(CensusInterface::class);
1020ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1034fc9500eSGreg Roach
1044fc9500eSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
1054fc9500eSGreg Roach
106*5e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
1074fc9500eSGreg Roach    }
1084fc9500eSGreg Roach
1094fc9500eSGreg Roach    /**
11015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
11115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
11252348eb8SGreg Roach     *
11352348eb8SGreg Roach     * @return void
1144fc9500eSGreg Roach     */
1159b802b22SGreg Roach    public function testNoMarriage(): void
116c1010edaSGreg Roach    {
117*5e933c21SGreg Roach        $family = self::createMock(Family::class);
1180ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
1198e2171feSGreg Roach
120*5e933c21SGreg Roach        $individual = self::createMock(Individual::class);
1210ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1228e2171feSGreg Roach
123*5e933c21SGreg Roach        $census = self::createMock(CensusInterface::class);
1240ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1258e2171feSGreg Roach
1268e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
1278e2171feSGreg Roach
128*5e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
1298e2171feSGreg Roach    }
1308e2171feSGreg Roach
1318e2171feSGreg Roach    /**
13215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
13315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
13452348eb8SGreg Roach     *
13552348eb8SGreg Roach     * @return void
1368e2171feSGreg Roach     */
1379b802b22SGreg Roach    public function testNoSpouseFamily(): void
138c1010edaSGreg Roach    {
139*5e933c21SGreg Roach        $individual = self::createMock(Individual::class);
1400ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
1418e2171feSGreg Roach
142*5e933c21SGreg Roach        $census = self::createMock(CensusInterface::class);
1430ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1448e2171feSGreg Roach
1458e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
1468e2171feSGreg Roach
147*5e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
1488e2171feSGreg Roach    }
1498e2171feSGreg Roach}
150