xref: /webtrees/tests/app/Census/CensusColumnAgeMarriedTest.php (revision 3976b4703df669696105ed6b024b96d433c8fbdb)
181d1be7aSGreg Roach<?php
2*3976b470SGreg Roach
381d1be7aSGreg Roach/**
481d1be7aSGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 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
1581d1be7aSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1681d1be7aSGreg Roach */
17e7f56f2aSGreg Roachdeclare(strict_types=1);
18e7f56f2aSGreg Roach
1981d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census;
2081d1be7aSGreg Roach
2181d1be7aSGreg Roachuse Fisharebest\Webtrees\Date;
22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
2539ca88baSGreg Roachuse Illuminate\Support\Collection;
2681d1be7aSGreg Roach
2781d1be7aSGreg Roach/**
2881d1be7aSGreg Roach * Test harness for the class CensusColumnAgeMarried
2981d1be7aSGreg Roach */
3084e2cf4eSGreg Roachclass CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase
31c1010edaSGreg Roach{
3281d1be7aSGreg Roach    /**
3315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
3415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
3552348eb8SGreg Roach     *
3652348eb8SGreg Roach     * @return void
3781d1be7aSGreg Roach     */
389b802b22SGreg Roach    public function testAgeMarried(): void
39c1010edaSGreg Roach    {
400ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
410ecdbde6SGreg Roach        $fact->method('date')->willReturn(new Date('01 DEC 1859'));
4281d1be7aSGreg Roach
430ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
440ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact]));
4581d1be7aSGreg Roach
460ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
470ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840'));
480ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
4981d1be7aSGreg Roach
500ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
510ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
5281d1be7aSGreg Roach
5381d1be7aSGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
5481d1be7aSGreg Roach
55220febf9SGreg Roach        $this->assertSame('19', $column->generate($individual, $individual));
5681d1be7aSGreg Roach    }
5781d1be7aSGreg Roach
5881d1be7aSGreg Roach    /**
5915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
6015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6152348eb8SGreg Roach     *
6252348eb8SGreg Roach     * @return void
6381d1be7aSGreg Roach     */
649b802b22SGreg Roach    public function testNoBirthDate(): void
65c1010edaSGreg Roach    {
660ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
670ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date(''));
680ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
693e983931SGreg Roach
700ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
710ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
723e983931SGreg Roach
733e983931SGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
743e983931SGreg Roach
75342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
7681d1be7aSGreg Roach    }
7781d1be7aSGreg Roach
7881d1be7aSGreg Roach    /**
7915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
8015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
8152348eb8SGreg Roach     *
8252348eb8SGreg Roach     * @return void
8381d1be7aSGreg Roach     */
849b802b22SGreg Roach    public function testNoMarriage(): void
85c1010edaSGreg Roach    {
860ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
870ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
8881d1be7aSGreg Roach
890ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
900ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date(''));
910ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
9281d1be7aSGreg Roach
930ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
940ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
9581d1be7aSGreg Roach
9681d1be7aSGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
9781d1be7aSGreg Roach
98342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
9981d1be7aSGreg Roach    }
10081d1be7aSGreg Roach
10181d1be7aSGreg Roach    /**
10215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
10315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
10452348eb8SGreg Roach     *
10552348eb8SGreg Roach     * @return void
10681d1be7aSGreg Roach     */
1079b802b22SGreg Roach    public function testNoSpouseFamily(): void
108c1010edaSGreg Roach    {
1090ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1100ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840'));
1110ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
11281d1be7aSGreg Roach
1130ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
1140ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
11581d1be7aSGreg Roach
11681d1be7aSGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
11781d1be7aSGreg Roach
118342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
11981d1be7aSGreg Roach    }
12081d1be7aSGreg Roach}
121