xref: /webtrees/tests/app/Census/CensusColumnAgeFemale5YearsTest.php (revision 342dcecd8628deacd49d86f3247fd77e64bf33c3)
1db7d25eeSGreg Roach<?php
2db7d25eeSGreg Roach
3db7d25eeSGreg Roach/**
4db7d25eeSGreg Roach * webtrees: online genealogy
51062a142SGreg Roach * Copyright (C) 2018 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
15db7d25eeSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16db7d25eeSGreg Roach */
17db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
18db7d25eeSGreg Roach
19db7d25eeSGreg Roachuse Fisharebest\Webtrees\Date;
20db7d25eeSGreg Roachuse Mockery;
21db7d25eeSGreg Roach
22db7d25eeSGreg Roach/**
23db7d25eeSGreg Roach * Test harness for the class CensusColumnAgeFemale5Years
24db7d25eeSGreg Roach */
25c1010edaSGreg Roachclass CensusColumnAgeFemale5YearsTest extends \PHPUnit\Framework\TestCase
26c1010edaSGreg Roach{
27db7d25eeSGreg Roach    /**
28db7d25eeSGreg Roach     * Delete mock objects
29db7d25eeSGreg Roach     */
30c1010edaSGreg Roach    public function tearDown()
31c1010edaSGreg Roach    {
32db7d25eeSGreg Roach        Mockery::close();
33db7d25eeSGreg Roach    }
34db7d25eeSGreg Roach
35db7d25eeSGreg Roach    /**
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
3715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
38db7d25eeSGreg Roach     */
39c1010edaSGreg Roach    public function testMale()
40c1010edaSGreg Roach    {
41c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
42db7d25eeSGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
43db7d25eeSGreg Roach
44c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
45db7d25eeSGreg Roach
46ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
47db7d25eeSGreg Roach
48*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
49db7d25eeSGreg Roach    }
50db7d25eeSGreg Roach
51db7d25eeSGreg Roach    /**
5215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
5315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
54db7d25eeSGreg Roach     */
55c1010edaSGreg Roach    public function testFemale()
56c1010edaSGreg Roach    {
57c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
58db7d25eeSGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
59db7d25eeSGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
60db7d25eeSGreg Roach
61c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
62db7d25eeSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
63db7d25eeSGreg Roach
64ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
65db7d25eeSGreg Roach
66*342dcecdSGreg Roach        $this->assertSame('30', $column->generate($individual, $individual));
67db7d25eeSGreg Roach    }
68db7d25eeSGreg Roach
69db7d25eeSGreg Roach    /**
7015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
7115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
72db7d25eeSGreg Roach     */
73c1010edaSGreg Roach    public function testUnknownSex()
74c1010edaSGreg Roach    {
75c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
76db7d25eeSGreg Roach        $individual->shouldReceive('getSex')->andReturn('U');
77db7d25eeSGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
78db7d25eeSGreg Roach
79c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
80db7d25eeSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
81db7d25eeSGreg Roach
82ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
83db7d25eeSGreg Roach
84*342dcecdSGreg Roach        $this->assertSame('30', $column->generate($individual, $individual));
85db7d25eeSGreg Roach    }
86db7d25eeSGreg Roach
87db7d25eeSGreg Roach    /**
8815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
8915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
90db7d25eeSGreg Roach     */
91c1010edaSGreg Roach    public function testLessThanOneYear()
92c1010edaSGreg Roach    {
93c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
94db7d25eeSGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
95db7d25eeSGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
96db7d25eeSGreg Roach
97c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
98db7d25eeSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1800');
99db7d25eeSGreg Roach
100ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
101db7d25eeSGreg Roach
102*342dcecdSGreg Roach        $this->assertSame('0', $column->generate($individual, $individual));
103db7d25eeSGreg Roach    }
104db7d25eeSGreg Roach
105db7d25eeSGreg Roach    /**
10615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
10715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
108db7d25eeSGreg Roach     */
109c1010edaSGreg Roach    public function testLessThanFifteenYears()
110c1010edaSGreg Roach    {
111c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
112db7d25eeSGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
113db7d25eeSGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
114db7d25eeSGreg Roach
115c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
116db7d25eeSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1814');
117db7d25eeSGreg Roach
118ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
119db7d25eeSGreg Roach
120*342dcecdSGreg Roach        $this->assertSame('14', $column->generate($individual, $individual));
121db7d25eeSGreg Roach    }
122db7d25eeSGreg Roach
123db7d25eeSGreg Roach    /**
12415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
12515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
126db7d25eeSGreg Roach     */
127c1010edaSGreg Roach    public function testRoundedDownToFiveYears()
128c1010edaSGreg Roach    {
129c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
130db7d25eeSGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
131db7d25eeSGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
132db7d25eeSGreg Roach
133c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
134db7d25eeSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1844');
135db7d25eeSGreg Roach
136ef21b467SGreg Roach        $column = new CensusColumnAgeFemale5Years($census, '', '');
137db7d25eeSGreg Roach
138*342dcecdSGreg Roach        $this->assertSame('40', $column->generate($individual, $individual));
139db7d25eeSGreg Roach    }
140db7d25eeSGreg Roach}
141