1db7d25eeSGreg Roach<?php 2db7d25eeSGreg Roach 3db7d25eeSGreg Roach/** 4db7d25eeSGreg Roach * webtrees: online genealogy 5db7d25eeSGreg Roach * Copyright (C) 2015 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 Fisharebest\Webtrees\Individual; 21db7d25eeSGreg Roachuse Mockery; 22db7d25eeSGreg Roach 23db7d25eeSGreg Roach/** 24db7d25eeSGreg Roach * Test harness for the class CensusColumnAgeMale 25db7d25eeSGreg Roach */ 26db7d25eeSGreg Roachclass CensusColumnAgeMaleTest extends \PHPUnit_Framework_TestCase { 27db7d25eeSGreg Roach /** 28db7d25eeSGreg Roach * Delete mock objects 29db7d25eeSGreg Roach */ 30db7d25eeSGreg Roach public function tearDown() { 31db7d25eeSGreg Roach Mockery::close(); 32db7d25eeSGreg Roach } 33db7d25eeSGreg Roach 34db7d25eeSGreg Roach /** 35db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale 36db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 37db7d25eeSGreg Roach */ 38db7d25eeSGreg Roach public function testMale() { 39*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 40db7d25eeSGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 41db7d25eeSGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); 42db7d25eeSGreg Roach 43*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 44db7d25eeSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1832'); 45db7d25eeSGreg Roach 46ef21b467SGreg Roach $column = new CensusColumnAgeMale($census, '', ''); 47db7d25eeSGreg Roach 48db7d25eeSGreg Roach $this->assertSame('32', $column->generate($individual)); 49db7d25eeSGreg Roach } 50db7d25eeSGreg Roach 51db7d25eeSGreg Roach /** 52db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale 53db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 54db7d25eeSGreg Roach */ 55db7d25eeSGreg Roach public function testFemale() { 56*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 57db7d25eeSGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 58db7d25eeSGreg Roach 59*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 60db7d25eeSGreg Roach 61ef21b467SGreg Roach $column = new CensusColumnAgeMale($census, '', ''); 62db7d25eeSGreg Roach 63db7d25eeSGreg Roach $this->assertSame('', $column->generate($individual)); 64db7d25eeSGreg Roach } 65db7d25eeSGreg Roach 66db7d25eeSGreg Roach /** 67db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale 68db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 69db7d25eeSGreg Roach */ 70db7d25eeSGreg Roach public function testUnknownSex() { 71*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 72db7d25eeSGreg Roach $individual->shouldReceive('getSex')->andReturn('U'); 73db7d25eeSGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); 74db7d25eeSGreg Roach 75*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 76db7d25eeSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1832'); 77db7d25eeSGreg Roach 78ef21b467SGreg Roach $column = new CensusColumnAgeMale($census, '', ''); 79db7d25eeSGreg Roach 80db7d25eeSGreg Roach $this->assertSame('32', $column->generate($individual)); 81db7d25eeSGreg Roach } 82db7d25eeSGreg Roach 83db7d25eeSGreg Roach /** 84db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMale 85db7d25eeSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 86db7d25eeSGreg Roach */ 87db7d25eeSGreg Roach public function testLessThanOneYear() { 88*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 89db7d25eeSGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 90db7d25eeSGreg Roach $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); 91db7d25eeSGreg Roach 92*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 93db7d25eeSGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1800'); 94db7d25eeSGreg Roach 95ef21b467SGreg Roach $column = new CensusColumnAgeMale($census, '', ''); 96db7d25eeSGreg Roach 97db7d25eeSGreg Roach $this->assertSame('0', $column->generate($individual)); 98db7d25eeSGreg Roach } 99db7d25eeSGreg Roach} 100