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 CensusColumnMonthIfBornWithinYear 23 */ 24class CensusColumnMonthIfBornWithinYearTest 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\CensusColumnMonthIfBornWithinYear 38 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 39 * 40 * @return void 41 */ 42 public function testBornWithinYear() 43 { 44 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 45 $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860')); 46 47 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 48 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 49 50 $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 51 52 $this->assertSame('Jan', $column->generate($individual, $individual)); 53 } 54 55 /** 56 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 57 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 58 * 59 * @return void 60 */ 61 public function testBornOverYearBeforeTheCensus() 62 { 63 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 64 $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859')); 65 66 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 67 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 68 69 $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 70 71 $this->assertSame('', $column->generate($individual, $individual)); 72 } 73 74 /** 75 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 76 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 77 * 78 * @return void 79 */ 80 public function testBornAfterTheCensus() 81 { 82 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 83 $individual->shouldReceive('getBirthDate')->andReturn(new Date('02 JUN 1860')); 84 85 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 86 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 87 88 89 $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 90 91 $this->assertSame('', $column->generate($individual, $individual)); 92 } 93 94 95 /** 96 * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 97 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 98 * 99 * @return void 100 */ 101 public function testNoBirth() 102 { 103 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 104 $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 105 106 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 107 $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 108 109 $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 110 111 $this->assertSame('', $column->generate($individual, $individual)); 112 } 113} 114