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