xref: /webtrees/tests/app/Census/CensusColumnAgeFemale5YearsTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1db7d25eeSGreg Roach<?php
23976b470SGreg Roach
3db7d25eeSGreg Roach/**
4db7d25eeSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify
7db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by
8db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9db7d25eeSGreg Roach * (at your option) any later version.
10db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful,
11db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13db7d25eeSGreg Roach * GNU General Public License for more details.
14db7d25eeSGreg 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/>.
16db7d25eeSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
20db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
21db7d25eeSGreg Roach
22db7d25eeSGreg Roachuse Fisharebest\Webtrees\Date;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
25*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
26db7d25eeSGreg Roach
27*202c018bSGreg Roach#[CoversClass(CensusColumnAgeFemale5Years::class)]
28*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
293cfcc809SGreg Roachclass CensusColumnAgeFemale5YearsTest extends TestCase
30c1010edaSGreg Roach{
319b802b22SGreg Roach    public function testMale(): void
32c1010edaSGreg Roach    {
33cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
340ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
35db7d25eeSGreg Roach
36cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
37db7d25eeSGreg Roach
38ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
39db7d25eeSGreg Roach
405e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
41db7d25eeSGreg Roach    }
42db7d25eeSGreg Roach
439b802b22SGreg Roach    public function testFemale(): void
44c1010edaSGreg Roach    {
45cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
460ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
470ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
48db7d25eeSGreg Roach
49cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
500ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
51db7d25eeSGreg Roach
52ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
53db7d25eeSGreg Roach
545e933c21SGreg Roach        self::assertSame('30', $column->generate($individual, $individual));
55db7d25eeSGreg Roach    }
56db7d25eeSGreg Roach
579b802b22SGreg Roach    public function testUnknownSex(): void
58c1010edaSGreg Roach    {
59cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
600ecdbde6SGreg Roach        $individual->method('sex')->willReturn('U');
610ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
62db7d25eeSGreg Roach
63cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
640ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
65db7d25eeSGreg Roach
66ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
67db7d25eeSGreg Roach
685e933c21SGreg Roach        self::assertSame('30', $column->generate($individual, $individual));
69db7d25eeSGreg Roach    }
70db7d25eeSGreg Roach
719b802b22SGreg Roach    public function testLessThanOneYear(): void
72c1010edaSGreg Roach    {
73cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
740ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
750ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
76db7d25eeSGreg Roach
77cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
780ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1800');
79db7d25eeSGreg Roach
80ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
81db7d25eeSGreg Roach
825e933c21SGreg Roach        self::assertSame('0', $column->generate($individual, $individual));
83db7d25eeSGreg Roach    }
84db7d25eeSGreg Roach
859b802b22SGreg Roach    public function testLessThanFifteenYears(): void
86c1010edaSGreg Roach    {
87cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
880ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
890ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
90db7d25eeSGreg Roach
91cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
920ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1814');
93db7d25eeSGreg Roach
94ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
95db7d25eeSGreg Roach
965e933c21SGreg Roach        self::assertSame('14', $column->generate($individual, $individual));
97db7d25eeSGreg Roach    }
98db7d25eeSGreg Roach
999b802b22SGreg Roach    public function testRoundedDownToFiveYears(): void
100c1010edaSGreg Roach    {
101cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
1020ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
1030ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
104db7d25eeSGreg Roach
105cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1060ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1844');
107db7d25eeSGreg Roach
108ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
109db7d25eeSGreg Roach
1105e933c21SGreg Roach        self::assertSame('40', $column->generate($individual, $individual));
111db7d25eeSGreg Roach    }
112db7d25eeSGreg Roach}
113