xref: /webtrees/tests/app/Census/CensusColumnMonthIfBornWithinYearTest.php (revision c314ecc9a18e5e740a1c0fcb7379ef541f969dc5)
18e2171feSGreg Roach<?php
28e2171feSGreg Roach
38e2171feSGreg Roach/**
48e2171feSGreg Roach * webtrees: online genealogy
58e2171feSGreg Roach * Copyright (C) 2015 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 Fisharebest\Webtrees\Individual;
218e2171feSGreg Roachuse Mockery;
228e2171feSGreg Roach
238e2171feSGreg Roach/**
2471eba385SGreg Roach * Test harness for the class CensusColumnMonthIfBornWithinYear
258e2171feSGreg Roach */
2671eba385SGreg Roachclass CensusColumnMonthIfBornWithinYearTest extends \PHPUnit_Framework_TestCase {
278e2171feSGreg Roach	/**
288e2171feSGreg Roach	 * Delete mock objects
298e2171feSGreg Roach	 */
308e2171feSGreg Roach	public function tearDown() {
318e2171feSGreg Roach		Mockery::close();
328e2171feSGreg Roach	}
338e2171feSGreg Roach
348e2171feSGreg Roach	/**
3571eba385SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
368e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
378e2171feSGreg Roach	 */
388e2171feSGreg Roach	public function testBornWithinYear() {
39*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
408e2171feSGreg Roach		$individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860'));
418e2171feSGreg Roach
42*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
438e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
448e2171feSGreg Roach
4571eba385SGreg Roach		$column = new CensusColumnMonthIfBornWithinYear($census, '', '');
468e2171feSGreg Roach
478e2171feSGreg Roach		$this->assertSame('Jan', $column->generate($individual));
488e2171feSGreg Roach	}
498e2171feSGreg Roach
508e2171feSGreg Roach	/**
5171eba385SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
528e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
538e2171feSGreg Roach	 */
548e2171feSGreg Roach	public function testNotBornWithinYear() {
55*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
568e2171feSGreg Roach		$individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859'));
578e2171feSGreg Roach
58*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
598e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
608e2171feSGreg Roach
6171eba385SGreg Roach		$column = new CensusColumnMonthIfBornWithinYear($census, '', '');
628e2171feSGreg Roach
638e2171feSGreg Roach		$this->assertSame('', $column->generate($individual));
648e2171feSGreg Roach	}
658e2171feSGreg Roach
668e2171feSGreg Roach	/**
6771eba385SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
688e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
698e2171feSGreg Roach	 */
708e2171feSGreg Roach	public function testNoBirth() {
71*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
728e2171feSGreg Roach		$individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
738e2171feSGreg Roach
74*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
758e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
768e2171feSGreg Roach
7771eba385SGreg Roach		$column = new CensusColumnMonthIfBornWithinYear($census, '', '');
788e2171feSGreg Roach
798e2171feSGreg Roach		$this->assertSame('', $column->generate($individual));
808e2171feSGreg Roach	}
818e2171feSGreg Roach}
82