xref: /webtrees/tests/app/Census/CensusColumnAgeMarriedTest.php (revision 15d603e7c7c15d20f055d3d9c38d6b133453c5be)
181d1be7aSGreg Roach<?php
281d1be7aSGreg Roach
381d1be7aSGreg Roach/**
481d1be7aSGreg Roach * webtrees: online genealogy
56bdf7674SGreg Roach * Copyright (C) 2017 webtrees development team
681d1be7aSGreg Roach * This program is free software: you can redistribute it and/or modify
781d1be7aSGreg Roach * it under the terms of the GNU General Public License as published by
881d1be7aSGreg Roach * the Free Software Foundation, either version 3 of the License, or
981d1be7aSGreg Roach * (at your option) any later version.
1081d1be7aSGreg Roach * This program is distributed in the hope that it will be useful,
1181d1be7aSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1281d1be7aSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1381d1be7aSGreg Roach * GNU General Public License for more details.
1481d1be7aSGreg Roach * You should have received a copy of the GNU General Public License
1581d1be7aSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1681d1be7aSGreg Roach */
1781d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census;
1881d1be7aSGreg Roach
1981d1be7aSGreg Roachuse Fisharebest\Webtrees\Date;
2081d1be7aSGreg Roachuse Mockery;
2181d1be7aSGreg Roach
2281d1be7aSGreg Roach/**
2381d1be7aSGreg Roach * Test harness for the class CensusColumnAgeMarried
2481d1be7aSGreg Roach */
2581d1be7aSGreg Roachclass CensusColumnAgeMarriedTest extends \PHPUnit_Framework_TestCase {
2681d1be7aSGreg Roach	/**
2781d1be7aSGreg Roach	 * Delete mock objects
2881d1be7aSGreg Roach	 */
2981d1be7aSGreg Roach	public function tearDown() {
3081d1be7aSGreg Roach		Mockery::close();
3181d1be7aSGreg Roach	}
3281d1be7aSGreg Roach
3381d1be7aSGreg Roach	/**
34*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
35*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
3681d1be7aSGreg Roach	 */
3781d1be7aSGreg Roach	public function testAgeMarried() {
3881d1be7aSGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
3981d1be7aSGreg Roach		$fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
4081d1be7aSGreg Roach
4181d1be7aSGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
4213abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]);
4381d1be7aSGreg Roach
4481d1be7aSGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
4581d1be7aSGreg Roach		$individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
4613abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
4781d1be7aSGreg Roach
4881d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
4981d1be7aSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
5081d1be7aSGreg Roach
5181d1be7aSGreg Roach		$column = new CensusColumnAgeMarried($census, '', '');
5281d1be7aSGreg Roach
5381d1be7aSGreg Roach		$this->assertSame(19, $column->generate($individual));
5481d1be7aSGreg Roach	}
5581d1be7aSGreg Roach
5681d1be7aSGreg Roach	/**
57*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
58*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
5981d1be7aSGreg Roach	 */
6081d1be7aSGreg Roach	public function testNoBirthDate() {
6181d1be7aSGreg Roach	}
6281d1be7aSGreg Roach
6381d1be7aSGreg Roach	/**
64*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
65*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6681d1be7aSGreg Roach	 */
6781d1be7aSGreg Roach	public function testNoMarriage() {
6881d1be7aSGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
6913abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
7081d1be7aSGreg Roach
7181d1be7aSGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
7281d1be7aSGreg Roach		$individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
7313abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
7481d1be7aSGreg Roach
7581d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
7681d1be7aSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
7781d1be7aSGreg Roach
7881d1be7aSGreg Roach		$column = new CensusColumnAgeMarried($census, '', '');
7981d1be7aSGreg Roach
8081d1be7aSGreg Roach		$this->assertSame('', $column->generate($individual));
8181d1be7aSGreg Roach	}
8281d1be7aSGreg Roach
8381d1be7aSGreg Roach	/**
84*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
85*15d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
8681d1be7aSGreg Roach	 */
8781d1be7aSGreg Roach	public function testNoSpouseFamily() {
8881d1be7aSGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
8981d1be7aSGreg Roach		$individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
9013abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([]);
9181d1be7aSGreg Roach
9281d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
9381d1be7aSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
9481d1be7aSGreg Roach
9581d1be7aSGreg Roach		$column = new CensusColumnAgeMarried($census, '', '');
9681d1be7aSGreg Roach
9781d1be7aSGreg Roach		$this->assertSame('', $column->generate($individual));
9881d1be7aSGreg Roach	}
9981d1be7aSGreg Roach}
100