xref: /webtrees/tests/app/Census/CensusColumnAgeFemaleTest.php (revision 202c018b592d5a516e4a465dc6dc515f3be37399)
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
28*202c018bSGreg Roach#[CoversClass(CensusColumnAgeFemale::class)]
29*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
303cfcc809SGreg Roachclass CensusColumnAgeFemaleTest extends TestCase
31c1010edaSGreg Roach{
329b802b22SGreg Roach    public function testMale(): void
33c1010edaSGreg Roach    {
34cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
350ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
36db7d25eeSGreg Roach
37cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
38db7d25eeSGreg Roach
39ef21b467SGreg Roach        $column = new CensusColumnAgeFemale($census, '', '');
40db7d25eeSGreg Roach
415e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
42db7d25eeSGreg Roach    }
43db7d25eeSGreg Roach
449b802b22SGreg Roach    public function testFemale(): void
45c1010edaSGreg Roach    {
46cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
470ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
480ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
49db7d25eeSGreg Roach
50cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
510ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1832');
52db7d25eeSGreg Roach
53ef21b467SGreg Roach        $column = new CensusColumnAgeFemale($census, '', '');
54db7d25eeSGreg Roach
555e933c21SGreg Roach        self::assertSame('32', $column->generate($individual, $individual));
56db7d25eeSGreg Roach    }
57db7d25eeSGreg Roach
589b802b22SGreg Roach    public function testUnknownSex(): void
59c1010edaSGreg Roach    {
60cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
610ecdbde6SGreg Roach        $individual->method('sex')->willReturn('U');
620ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
63db7d25eeSGreg Roach
64cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
650ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1832');
66db7d25eeSGreg Roach
67ef21b467SGreg Roach        $column = new CensusColumnAgeFemale($census, '', '');
68db7d25eeSGreg Roach
695e933c21SGreg Roach        self::assertSame('32', $column->generate($individual, $individual));
70db7d25eeSGreg Roach    }
71db7d25eeSGreg Roach
729b802b22SGreg Roach    public function testLessThanOneYear(): void
73c1010edaSGreg Roach    {
74cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
750ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
760ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
77db7d25eeSGreg Roach
78cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
790ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1800');
80db7d25eeSGreg Roach
81ef21b467SGreg Roach        $column = new CensusColumnAgeFemale($census, '', '');
82db7d25eeSGreg Roach
835e933c21SGreg Roach        self::assertSame('0', $column->generate($individual, $individual));
84db7d25eeSGreg Roach    }
85db7d25eeSGreg Roach}
86