xref: /webtrees/tests/app/Census/CensusColumnAgeMaleTest.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(CensusColumnAgeMale::class)]
28*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
293cfcc809SGreg Roachclass CensusColumnAgeMaleTest 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');
350ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
36db7d25eeSGreg Roach
37cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
380ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1832');
39db7d25eeSGreg Roach
40ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
41db7d25eeSGreg Roach
425e933c21SGreg Roach        self::assertSame('32', $column->generate($individual, $individual));
43db7d25eeSGreg Roach    }
44db7d25eeSGreg Roach
459b802b22SGreg Roach    public function testFemale(): void
46c1010edaSGreg Roach    {
47cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
480ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
49db7d25eeSGreg Roach
50cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
51db7d25eeSGreg Roach
52ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
53db7d25eeSGreg Roach
545e933c21SGreg Roach        self::assertSame('', $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 1832');
65db7d25eeSGreg Roach
66ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
67db7d25eeSGreg Roach
685e933c21SGreg Roach        self::assertSame('32', $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('M');
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 CensusColumnAgeMale($census, '', '');
81db7d25eeSGreg Roach
825e933c21SGreg Roach        self::assertSame('0', $column->generate($individual, $individual));
83db7d25eeSGreg Roach    }
84db7d25eeSGreg Roach}
85