xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision e20523594b1c9198044ea2549fd5fab80283ede4)
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\Fact;
218e2171feSGreg Roachuse Fisharebest\Webtrees\Family;
228e2171feSGreg Roachuse Fisharebest\Webtrees\Individual;
238e2171feSGreg Roachuse Mockery;
248e2171feSGreg Roach
258e2171feSGreg Roach/**
268e2171feSGreg Roach * Test harness for the class CensusColumnMonthIfMarriedWithinYear
278e2171feSGreg Roach */
288e2171feSGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \PHPUnit_Framework_TestCase {
298e2171feSGreg Roach	/**
308e2171feSGreg Roach	 * Delete mock objects
318e2171feSGreg Roach	 */
328e2171feSGreg Roach	public function tearDown() {
338e2171feSGreg Roach		Mockery::close();
348e2171feSGreg Roach	}
358e2171feSGreg Roach
368e2171feSGreg Roach	/**
378e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
388e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
398e2171feSGreg Roach	 */
408e2171feSGreg Roach	public function testMarriedWithinYear() {
418e2171feSGreg Roach		$fact = Mockery::mock(Fact::class);
428e2171feSGreg Roach		$fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
438e2171feSGreg Roach
448e2171feSGreg Roach		$family = Mockery::mock(Family::class);
45*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn(array($fact));
468e2171feSGreg Roach
478e2171feSGreg Roach		$individual = Mockery::mock(Individual::class);
48*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
498e2171feSGreg Roach
508e2171feSGreg Roach		$census = Mockery::mock(CensusInterface::class);
518e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
528e2171feSGreg Roach
538e2171feSGreg Roach		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
548e2171feSGreg Roach
558e2171feSGreg Roach		$this->assertSame('Dec', $column->generate($individual));
568e2171feSGreg Roach	}
578e2171feSGreg Roach
588e2171feSGreg Roach	/**
598e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
608e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
618e2171feSGreg Roach	 */
628e2171feSGreg Roach	public function testNotMarriedWithinYear() {
638e2171feSGreg Roach		$fact = Mockery::mock(Fact::class);
648e2171feSGreg Roach		$fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859'));
658e2171feSGreg Roach
668e2171feSGreg Roach		$family = Mockery::mock(Family::class);
67*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn(array($fact));
688e2171feSGreg Roach
698e2171feSGreg Roach		$individual = Mockery::mock(Individual::class);
70*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
718e2171feSGreg Roach
728e2171feSGreg Roach		$census = Mockery::mock(CensusInterface::class);
738e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
748e2171feSGreg Roach
758e2171feSGreg Roach		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
768e2171feSGreg Roach
778e2171feSGreg Roach		$this->assertSame('', $column->generate($individual));
788e2171feSGreg Roach	}
798e2171feSGreg Roach
808e2171feSGreg Roach	/**
818e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
828e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
838e2171feSGreg Roach	 */
848e2171feSGreg Roach	public function testNoMarriage() {
858e2171feSGreg Roach		$family = Mockery::mock(Family::class);
86*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn(array());
878e2171feSGreg Roach
888e2171feSGreg Roach		$individual = Mockery::mock(Individual::class);
89*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
908e2171feSGreg Roach
918e2171feSGreg Roach		$census = Mockery::mock(CensusInterface::class);
928e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
938e2171feSGreg Roach
948e2171feSGreg Roach		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
958e2171feSGreg Roach
968e2171feSGreg Roach		$this->assertSame('', $column->generate($individual));
978e2171feSGreg Roach	}
988e2171feSGreg Roach
998e2171feSGreg Roach	/**
1008e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
1018e2171feSGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
1028e2171feSGreg Roach	 */
1038e2171feSGreg Roach	public function testNoSpouseFamily() {
1048e2171feSGreg Roach		$individual = Mockery::mock(Individual::class);
105*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
1068e2171feSGreg Roach
1078e2171feSGreg Roach		$census = Mockery::mock(CensusInterface::class);
1088e2171feSGreg Roach		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1098e2171feSGreg Roach
1108e2171feSGreg Roach		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1118e2171feSGreg Roach
1128e2171feSGreg Roach		$this->assertSame('', $column->generate($individual));
1138e2171feSGreg Roach	}
1148e2171feSGreg Roach}
115