xref: /webtrees/tests/app/Census/CensusColumnAgeFemale5YearsTest.php (revision 15d603e7c7c15d20f055d3d9c38d6b133453c5be)
1db7d25eeSGreg Roach<?php
2db7d25eeSGreg Roach
3db7d25eeSGreg Roach/**
4db7d25eeSGreg Roach * webtrees: online genealogy
56bdf7674SGreg Roach * Copyright (C) 2017 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 */
25db7d25eeSGreg Roachclass CensusColumnAgeFemale5YearsTest extends \PHPUnit_Framework_TestCase {
26db7d25eeSGreg Roach	/**
27db7d25eeSGreg Roach	 * Delete mock objects
28db7d25eeSGreg Roach	 */
29db7d25eeSGreg Roach	public function tearDown() {
30db7d25eeSGreg Roach		Mockery::close();
31db7d25eeSGreg Roach	}
32db7d25eeSGreg Roach
33db7d25eeSGreg Roach	/**
34*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
35*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
36db7d25eeSGreg Roach	 */
37db7d25eeSGreg Roach	public function testMale() {
38c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
39db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
40db7d25eeSGreg Roach
41c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
42db7d25eeSGreg Roach
43ef21b467SGreg Roach		$column = new CensusColumnAgeFemale5Years($census, '', '');
44db7d25eeSGreg Roach
45db7d25eeSGreg Roach		$this->assertSame('', $column->generate($individual));
46db7d25eeSGreg Roach	}
47db7d25eeSGreg Roach
48db7d25eeSGreg Roach	/**
49*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
50*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
51db7d25eeSGreg Roach	 */
52db7d25eeSGreg Roach	public function testFemale() {
53c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
54db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
55db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
56db7d25eeSGreg Roach
57c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
58db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
59db7d25eeSGreg Roach
60ef21b467SGreg Roach		$column = new CensusColumnAgeFemale5Years($census, '', '');
61db7d25eeSGreg Roach
62db7d25eeSGreg Roach		$this->assertSame('30', $column->generate($individual));
63db7d25eeSGreg Roach	}
64db7d25eeSGreg Roach
65db7d25eeSGreg Roach	/**
66*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
67*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
68db7d25eeSGreg Roach	 */
69db7d25eeSGreg Roach	public function testUnknownSex() {
70c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
71db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('U');
72db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
73db7d25eeSGreg Roach
74c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
75db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
76db7d25eeSGreg Roach
77ef21b467SGreg Roach		$column = new CensusColumnAgeFemale5Years($census, '', '');
78db7d25eeSGreg Roach
79db7d25eeSGreg Roach		$this->assertSame('30', $column->generate($individual));
80db7d25eeSGreg Roach	}
81db7d25eeSGreg Roach
82db7d25eeSGreg Roach	/**
83*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
84*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
85db7d25eeSGreg Roach	 */
86db7d25eeSGreg Roach	public function testLessThanOneYear() {
87c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
88db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
89db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
90db7d25eeSGreg Roach
91c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
92db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1800');
93db7d25eeSGreg Roach
94ef21b467SGreg Roach		$column = new CensusColumnAgeFemale5Years($census, '', '');
95db7d25eeSGreg Roach
96db7d25eeSGreg Roach		$this->assertSame('0', $column->generate($individual));
97db7d25eeSGreg Roach	}
98db7d25eeSGreg Roach
99db7d25eeSGreg Roach	/**
100*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
101*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
102db7d25eeSGreg Roach	 */
103db7d25eeSGreg Roach	public function testLessThanFifteenYears() {
104c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
105db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
106db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
107db7d25eeSGreg Roach
108c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
109db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1814');
110db7d25eeSGreg Roach
111ef21b467SGreg Roach		$column = new CensusColumnAgeFemale5Years($census, '', '');
112db7d25eeSGreg Roach
113db7d25eeSGreg Roach		$this->assertSame('14', $column->generate($individual));
114db7d25eeSGreg Roach	}
115db7d25eeSGreg Roach
116db7d25eeSGreg Roach	/**
117*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years
118*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
119db7d25eeSGreg Roach	 */
120db7d25eeSGreg Roach	public function testRoundedDownToFiveYears() {
121c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
122db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
123db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
124db7d25eeSGreg Roach
125c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
126db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1844');
127db7d25eeSGreg Roach
128ef21b467SGreg Roach		$column = new CensusColumnAgeFemale5Years($census, '', '');
129db7d25eeSGreg Roach
130db7d25eeSGreg Roach		$this->assertSame('40', $column->generate($individual));
131db7d25eeSGreg Roach	}
132db7d25eeSGreg Roach}
133