xref: /webtrees/tests/app/Census/CensusColumnConditionDanishTest.php (revision e20523594b1c9198044ea2549fd5fab80283ede4)
1101af0b4SGreg Roach<?php
2101af0b4SGreg Roach
3101af0b4SGreg Roach/**
4101af0b4SGreg Roach * webtrees: online genealogy
5101af0b4SGreg Roach * Copyright (C) 2015 webtrees development team
6101af0b4SGreg Roach * This program is free software: you can redistribute it and/or modify
7101af0b4SGreg Roach * it under the terms of the GNU General Public License as published by
8101af0b4SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9101af0b4SGreg Roach * (at your option) any later version.
10101af0b4SGreg Roach * This program is distributed in the hope that it will be useful,
11101af0b4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12101af0b4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13101af0b4SGreg Roach * GNU General Public License for more details.
14101af0b4SGreg Roach * You should have received a copy of the GNU General Public License
15101af0b4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16101af0b4SGreg Roach */
17101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census;
18101af0b4SGreg Roach
19101af0b4SGreg Roachuse Fisharebest\Webtrees\Date;
2073d4df56SGreg Roachuse Fisharebest\Webtrees\Fact;
2173d4df56SGreg Roachuse Fisharebest\Webtrees\Family;
22101af0b4SGreg Roachuse Fisharebest\Webtrees\Individual;
23101af0b4SGreg Roachuse Mockery;
24101af0b4SGreg Roach
25101af0b4SGreg Roach/**
2673d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish
27101af0b4SGreg Roach */
28101af0b4SGreg Roachclass CensusColumnConditionDanishTest extends \PHPUnit_Framework_TestCase {
29101af0b4SGreg Roach	/**
30101af0b4SGreg Roach	 * Delete mock objects
31101af0b4SGreg Roach	 */
32101af0b4SGreg Roach	public function tearDown() {
33101af0b4SGreg Roach		Mockery::close();
34101af0b4SGreg Roach	}
35101af0b4SGreg Roach
36101af0b4SGreg Roach	/**
3773d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
38101af0b4SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
39101af0b4SGreg Roach	 */
4073d4df56SGreg Roach	public function testNoSpouseFamilies() {
41101af0b4SGreg Roach		$individual = Mockery::mock(Individual::class);
42*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
43101af0b4SGreg Roach
44101af0b4SGreg Roach		$census = Mockery::mock(CensusInterface::class);
45101af0b4SGreg Roach
4673d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
47101af0b4SGreg Roach
4873d4df56SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
4973d4df56SGreg Roach	}
5073d4df56SGreg Roach
5173d4df56SGreg Roach	/**
5273d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
5373d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
5473d4df56SGreg Roach	 */
5573d4df56SGreg Roach	public function testNoFamilyNoFacts() {
5673d4df56SGreg Roach		$family = Mockery::mock(Family::class);
5773d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
58*e2052359SGreg Roach		$family->shouldReceive('getFacts')->andReturn(array());
5973d4df56SGreg Roach
6073d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
61*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
6273d4df56SGreg Roach
6373d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
6473d4df56SGreg Roach
6573d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
6673d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
6773d4df56SGreg Roach
6873d4df56SGreg Roach		$this->assertSame('Gift', $column->generate($individual));
6973d4df56SGreg Roach	}
7073d4df56SGreg Roach
7173d4df56SGreg Roach	/**
7273d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
7373d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
7473d4df56SGreg Roach	 */
7573d4df56SGreg Roach	public function testNoFamilyUnmarried() {
7673d4df56SGreg Roach		$fact = Mockery::mock(Fact::class);
7773d4df56SGreg Roach
7873d4df56SGreg Roach		$family = Mockery::mock(Family::class);
7973d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
80*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
8173d4df56SGreg Roach
8273d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
83*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
8473d4df56SGreg Roach
8573d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
8673d4df56SGreg Roach
8773d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
8873d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
8973d4df56SGreg Roach
9073d4df56SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
9173d4df56SGreg Roach	}
9273d4df56SGreg Roach
9373d4df56SGreg Roach	/**
9473d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
9573d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
9673d4df56SGreg Roach	 */
9773d4df56SGreg Roach	public function testNoFamilyDivorced() {
9873d4df56SGreg Roach		$fact = Mockery::mock(Fact::class);
9973d4df56SGreg Roach
10073d4df56SGreg Roach		$family = Mockery::mock(Family::class);
10173d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
102*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array());
103*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact));
10473d4df56SGreg Roach
10573d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
106*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
10773d4df56SGreg Roach
10873d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
10973d4df56SGreg Roach
11073d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
11173d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
11273d4df56SGreg Roach
11373d4df56SGreg Roach		$this->assertSame('Skilt', $column->generate($individual));
114101af0b4SGreg Roach	}
115101af0b4SGreg Roach}
116