xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision 3cfcc809af53e831fa6cafac7b274a2cb407db6e)
18e2171feSGreg Roach<?php
23976b470SGreg Roach
38e2171feSGreg Roach/**
48e2171feSGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 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 */
17e7f56f2aSGreg Roachdeclare(strict_types=1);
18e7f56f2aSGreg Roach
198e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census;
208e2171feSGreg Roach
218e2171feSGreg Roachuse Fisharebest\Webtrees\Date;
22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
25*3cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
2639ca88baSGreg Roachuse Illuminate\Support\Collection;
278e2171feSGreg Roach
288e2171feSGreg Roach/**
298e2171feSGreg Roach * Test harness for the class CensusColumnMonthIfMarriedWithinYear
308e2171feSGreg Roach */
31*3cfcc809SGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends TestCase
32c1010edaSGreg Roach{
338e2171feSGreg Roach    /**
3415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
3515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
3652348eb8SGreg Roach     *
3752348eb8SGreg Roach     * @return void
388e2171feSGreg Roach     */
399b802b22SGreg Roach    public function testMarriedWithinYear(): void
40c1010edaSGreg Roach    {
410ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
420ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('01 DEC 1859'));
438e2171feSGreg Roach
440ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
450ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
468e2171feSGreg Roach
470ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
480ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
498e2171feSGreg Roach
500ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
510ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
528e2171feSGreg Roach
538e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
548e2171feSGreg Roach
55342dcecdSGreg Roach        $this->assertSame('Dec', $column->generate($individual, $individual));
568e2171feSGreg Roach    }
578e2171feSGreg Roach
588e2171feSGreg Roach    /**
5915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
6015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6152348eb8SGreg Roach     *
6252348eb8SGreg Roach     * @return void
638e2171feSGreg Roach     */
649b802b22SGreg Roach    public function testMarriedOverYearBeforeTheCensus(): void
65c1010edaSGreg Roach    {
660ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
670ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('01 JAN 1859'));
688e2171feSGreg Roach
690ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
700ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
718e2171feSGreg Roach
720ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
730ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
748e2171feSGreg Roach
750ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
760ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
778e2171feSGreg Roach
788e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
798e2171feSGreg Roach
80342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
818e2171feSGreg Roach    }
828e2171feSGreg Roach
838e2171feSGreg Roach    /**
8415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
8515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
8652348eb8SGreg Roach     *
8752348eb8SGreg Roach     * @return void
888e2171feSGreg Roach     */
899b802b22SGreg Roach    public function testMarriedAfterTheCensus(): void
90c1010edaSGreg Roach    {
910ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
920ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('02 JUN 1860'));
934fc9500eSGreg Roach
940ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
950ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
964fc9500eSGreg Roach
970ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
980ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
994fc9500eSGreg Roach
1000ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
1010ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1024fc9500eSGreg Roach
1034fc9500eSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1044fc9500eSGreg Roach
105342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1064fc9500eSGreg Roach    }
1074fc9500eSGreg Roach
1084fc9500eSGreg Roach    /**
10915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
11015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
11152348eb8SGreg Roach     *
11252348eb8SGreg Roach     * @return void
1134fc9500eSGreg Roach     */
1149b802b22SGreg Roach    public function testNoMarriage(): void
115c1010edaSGreg Roach    {
1160ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
1170ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
1188e2171feSGreg Roach
1190ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1200ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1218e2171feSGreg Roach
1220ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
1230ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1248e2171feSGreg Roach
1258e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1268e2171feSGreg Roach
127342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1288e2171feSGreg Roach    }
1298e2171feSGreg Roach
1308e2171feSGreg Roach    /**
13115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
13215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
13352348eb8SGreg Roach     *
13452348eb8SGreg Roach     * @return void
1358e2171feSGreg Roach     */
1369b802b22SGreg Roach    public function testNoSpouseFamily(): void
137c1010edaSGreg Roach    {
1380ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1390ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
1408e2171feSGreg Roach
1410ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
1420ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1438e2171feSGreg Roach
1448e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1458e2171feSGreg Roach
146342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1478e2171feSGreg Roach    }
1488e2171feSGreg Roach}
149