xref: /webtrees/tests/app/Census/CensusColumnAgeMaleTest.php (revision db7d25eeb5ba43cdc3662cbee9ceabb8d61c7ab5)
1*db7d25eeSGreg Roach<?php
2*db7d25eeSGreg Roach
3*db7d25eeSGreg Roach/**
4*db7d25eeSGreg Roach * webtrees: online genealogy
5*db7d25eeSGreg Roach * Copyright (C) 2015 webtrees development team
6*db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify
7*db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by
8*db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9*db7d25eeSGreg Roach * (at your option) any later version.
10*db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful,
11*db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12*db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*db7d25eeSGreg Roach * GNU General Public License for more details.
14*db7d25eeSGreg Roach * You should have received a copy of the GNU General Public License
15*db7d25eeSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16*db7d25eeSGreg Roach */
17*db7d25eeSGreg Roach
18*db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
19*db7d25eeSGreg Roach
20*db7d25eeSGreg Roachuse Fisharebest\Webtrees\Date;
21*db7d25eeSGreg Roachuse Fisharebest\Webtrees\Individual;
22*db7d25eeSGreg Roachuse Mockery;
23*db7d25eeSGreg Roach
24*db7d25eeSGreg Roach/**
25*db7d25eeSGreg Roach * Test harness for the class CensusColumnAgeMale
26*db7d25eeSGreg Roach */
27*db7d25eeSGreg Roachclass CensusColumnAgeMaleTest extends \PHPUnit_Framework_TestCase {
28*db7d25eeSGreg Roach	/**
29*db7d25eeSGreg Roach	 * Delete mock objects
30*db7d25eeSGreg Roach	 */
31*db7d25eeSGreg Roach	public function tearDown() {
32*db7d25eeSGreg Roach		Mockery::close();
33*db7d25eeSGreg Roach	}
34*db7d25eeSGreg Roach
35*db7d25eeSGreg Roach	/**
36*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale
37*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
38*db7d25eeSGreg Roach	 */
39*db7d25eeSGreg Roach	public function testMale() {
40*db7d25eeSGreg Roach		$individual = Mockery::mock(Individual::class);
41*db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
42*db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
43*db7d25eeSGreg Roach
44*db7d25eeSGreg Roach		$census = Mockery::mock(CensusInterface::class);
45*db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1832');
46*db7d25eeSGreg Roach
47*db7d25eeSGreg Roach		$column = new CensusColumnAgeMale($census);
48*db7d25eeSGreg Roach
49*db7d25eeSGreg Roach		$this->assertSame('32', $column->generate($individual));
50*db7d25eeSGreg Roach	}
51*db7d25eeSGreg Roach
52*db7d25eeSGreg Roach	/**
53*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale
54*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
55*db7d25eeSGreg Roach	 */
56*db7d25eeSGreg Roach	public function testFemale() {
57*db7d25eeSGreg Roach		$individual = Mockery::mock(Individual::class);
58*db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
59*db7d25eeSGreg Roach
60*db7d25eeSGreg Roach		$census = Mockery::mock(CensusInterface::class);
61*db7d25eeSGreg Roach
62*db7d25eeSGreg Roach		$column = new CensusColumnAgeMale($census);
63*db7d25eeSGreg Roach
64*db7d25eeSGreg Roach		$this->assertSame('', $column->generate($individual));
65*db7d25eeSGreg Roach	}
66*db7d25eeSGreg Roach
67*db7d25eeSGreg Roach	/**
68*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale
69*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
70*db7d25eeSGreg Roach	 */
71*db7d25eeSGreg Roach	public function testUnknownSex() {
72*db7d25eeSGreg Roach		$individual = Mockery::mock(Individual::class);
73*db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('U');
74*db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
75*db7d25eeSGreg Roach
76*db7d25eeSGreg Roach		$census = Mockery::mock(CensusInterface::class);
77*db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1832');
78*db7d25eeSGreg Roach
79*db7d25eeSGreg Roach		$column = new CensusColumnAgeMale($census);
80*db7d25eeSGreg Roach
81*db7d25eeSGreg Roach		$this->assertSame('32', $column->generate($individual));
82*db7d25eeSGreg Roach	}
83*db7d25eeSGreg Roach
84*db7d25eeSGreg Roach	/**
85*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale
86*db7d25eeSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
87*db7d25eeSGreg Roach	 */
88*db7d25eeSGreg Roach	public function testLessThanOneYear() {
89*db7d25eeSGreg Roach		$individual = Mockery::mock(Individual::class);
90*db7d25eeSGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
91*db7d25eeSGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800'));
92*db7d25eeSGreg Roach
93*db7d25eeSGreg Roach		$census = Mockery::mock(CensusInterface::class);
94*db7d25eeSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1800');
95*db7d25eeSGreg Roach
96*db7d25eeSGreg Roach		$column = new CensusColumnAgeMale($census);
97*db7d25eeSGreg Roach
98*db7d25eeSGreg Roach		$this->assertSame('0', $column->generate($individual));
99*db7d25eeSGreg Roach	}
100*db7d25eeSGreg Roach}
101