18e2171feSGreg Roach<?php 28e2171feSGreg Roach 38e2171feSGreg Roach/** 48e2171feSGreg Roach * webtrees: online genealogy 56bdf7674SGreg Roach * Copyright (C) 2017 webtrees development team 68e2171feSGreg Roach * This program is free software: you can redistribute it and/or modify 78e2171feSGreg Roach * it under the terms of the GNU General Public License as published by 88e2171feSGreg Roach * the Free Software Foundation, either version 3 of the License, or 98e2171feSGreg Roach * (at your option) any later version. 108e2171feSGreg Roach * This program is distributed in the hope that it will be useful, 118e2171feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 128e2171feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 138e2171feSGreg Roach * GNU General Public License for more details. 148e2171feSGreg Roach * You should have received a copy of the GNU General Public License 158e2171feSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 168e2171feSGreg Roach */ 178e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census; 188e2171feSGreg Roach 198e2171feSGreg Roachuse Fisharebest\Webtrees\Date; 208e2171feSGreg Roachuse Mockery; 218e2171feSGreg Roach 228e2171feSGreg Roach/** 2371eba385SGreg Roach * Test harness for the class CensusColumnMonthIfBornWithinYear 248e2171feSGreg Roach */ 2571eba385SGreg Roachclass CensusColumnMonthIfBornWithinYearTest extends \PHPUnit_Framework_TestCase { 268e2171feSGreg Roach /** 278e2171feSGreg Roach * Delete mock objects 288e2171feSGreg Roach */ 298e2171feSGreg Roach public function tearDown() { 308e2171feSGreg Roach Mockery::close(); 318e2171feSGreg Roach } 328e2171feSGreg Roach 338e2171feSGreg Roach /** 34*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 35*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 368e2171feSGreg Roach */ 378e2171feSGreg Roach public function testBornWithinYear() { 38c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 398e2171feSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860')); 408e2171feSGreg Roach 41c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 428e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 438e2171feSGreg Roach 4471eba385SGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 458e2171feSGreg Roach 468e2171feSGreg Roach $this->assertSame('Jan', $column->generate($individual)); 478e2171feSGreg Roach } 488e2171feSGreg Roach 498e2171feSGreg Roach /** 50*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 51*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 528e2171feSGreg Roach */ 534fc9500eSGreg Roach public function testBornOverYearBeforeTheCensus() { 54c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 558e2171feSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859')); 568e2171feSGreg Roach 57c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 588e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 598e2171feSGreg Roach 6071eba385SGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 618e2171feSGreg Roach 628e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 638e2171feSGreg Roach } 648e2171feSGreg Roach 658e2171feSGreg Roach /** 66*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 67*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 688e2171feSGreg Roach */ 694fc9500eSGreg Roach public function testBornAfterTheCensus() { 704fc9500eSGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 714fc9500eSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('02 JUN 1860')); 724fc9500eSGreg Roach 734fc9500eSGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 744fc9500eSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 754fc9500eSGreg Roach 764fc9500eSGreg Roach 774fc9500eSGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 784fc9500eSGreg Roach 794fc9500eSGreg Roach $this->assertSame('', $column->generate($individual)); 804fc9500eSGreg Roach } 814fc9500eSGreg Roach 824fc9500eSGreg Roach 834fc9500eSGreg Roach /** 84*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear 85*15d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 864fc9500eSGreg Roach */ 878e2171feSGreg Roach public function testNoBirth() { 88c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 898e2171feSGreg Roach $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); 908e2171feSGreg Roach 91c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 928e2171feSGreg Roach $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); 938e2171feSGreg Roach 9471eba385SGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 958e2171feSGreg Roach 968e2171feSGreg Roach $this->assertSame('', $column->generate($individual)); 978e2171feSGreg Roach } 988e2171feSGreg Roach} 99