xref: /webtrees/tests/app/Census/CensusColumnAgeMaleTest.php (revision 0ecdbde6aab590acff4665ec491a8427f5b7c90e)
1db7d25eeSGreg Roach<?php
2db7d25eeSGreg Roach/**
3db7d25eeSGreg Roach * webtrees: online genealogy
48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
5db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify
6db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by
7db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
8db7d25eeSGreg Roach * (at your option) any later version.
9db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful,
10db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12db7d25eeSGreg Roach * GNU General Public License for more details.
13db7d25eeSGreg Roach * You should have received a copy of the GNU General Public License
14db7d25eeSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15db7d25eeSGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
18db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
19db7d25eeSGreg Roach
20db7d25eeSGreg Roachuse Fisharebest\Webtrees\Date;
21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
22db7d25eeSGreg Roach
23db7d25eeSGreg Roach/**
24db7d25eeSGreg Roach * Test harness for the class CensusColumnAgeMale
25db7d25eeSGreg Roach */
2684e2cf4eSGreg Roachclass CensusColumnAgeMaleTest extends \Fisharebest\Webtrees\TestCase
27c1010edaSGreg Roach{
28db7d25eeSGreg Roach    /**
2915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale
3015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
3152348eb8SGreg Roach     *
3252348eb8SGreg Roach     * @return void
33db7d25eeSGreg Roach     */
349b802b22SGreg Roach    public function testMale(): void
35c1010edaSGreg Roach    {
36*0ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
37*0ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
38*0ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
39db7d25eeSGreg Roach
40*0ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
41*0ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1832');
42db7d25eeSGreg Roach
43ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
44db7d25eeSGreg Roach
45342dcecdSGreg Roach        $this->assertSame('32', $column->generate($individual, $individual));
46db7d25eeSGreg Roach    }
47db7d25eeSGreg Roach
48db7d25eeSGreg Roach    /**
4915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale
5015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
5152348eb8SGreg Roach     *
5252348eb8SGreg Roach     * @return void
53db7d25eeSGreg Roach     */
549b802b22SGreg Roach    public function testFemale(): void
55c1010edaSGreg Roach    {
56*0ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
57*0ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
58db7d25eeSGreg Roach
59*0ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
60db7d25eeSGreg Roach
61ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
62db7d25eeSGreg Roach
63342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
64db7d25eeSGreg Roach    }
65db7d25eeSGreg Roach
66db7d25eeSGreg Roach    /**
6715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale
6815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6952348eb8SGreg Roach     *
7052348eb8SGreg Roach     * @return void
71db7d25eeSGreg Roach     */
729b802b22SGreg Roach    public function testUnknownSex(): void
73c1010edaSGreg Roach    {
74*0ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
75*0ecdbde6SGreg Roach        $individual->method('sex')->willReturn('U');
76*0ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
77db7d25eeSGreg Roach
78*0ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
79*0ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1832');
80db7d25eeSGreg Roach
81ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
82db7d25eeSGreg Roach
83342dcecdSGreg Roach        $this->assertSame('32', $column->generate($individual, $individual));
84db7d25eeSGreg Roach    }
85db7d25eeSGreg Roach
86db7d25eeSGreg Roach    /**
8715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale
8815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
8952348eb8SGreg Roach     *
9052348eb8SGreg Roach     * @return void
91db7d25eeSGreg Roach     */
929b802b22SGreg Roach    public function testLessThanOneYear(): void
93c1010edaSGreg Roach    {
94*0ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
95*0ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
96*0ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800'));
97db7d25eeSGreg Roach
98*0ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
99*0ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1800');
100db7d25eeSGreg Roach
101ef21b467SGreg Roach        $column = new CensusColumnAgeMale($census, '', '');
102db7d25eeSGreg Roach
103342dcecdSGreg Roach        $this->assertSame('0', $column->generate($individual, $individual));
104db7d25eeSGreg Roach    }
105db7d25eeSGreg Roach}
106