xref: /webtrees/tests/app/Census/CensusColumnConditionDanishTest.php (revision 13abd6f3a37322f885d85df150e105d27ad81f8d)
1101af0b4SGreg Roach<?php
2101af0b4SGreg Roach
3101af0b4SGreg Roach/**
4101af0b4SGreg Roach * webtrees: online genealogy
5369c0ce6SGreg Roach * Copyright (C) 2016 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;
20101af0b4SGreg Roachuse Mockery;
21101af0b4SGreg Roach
22101af0b4SGreg Roach/**
2373d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish
24101af0b4SGreg Roach */
25101af0b4SGreg Roachclass CensusColumnConditionDanishTest extends \PHPUnit_Framework_TestCase {
26101af0b4SGreg Roach	/**
27101af0b4SGreg Roach	 * Delete mock objects
28101af0b4SGreg Roach	 */
29101af0b4SGreg Roach	public function tearDown() {
30101af0b4SGreg Roach		Mockery::close();
31101af0b4SGreg Roach	}
32101af0b4SGreg Roach
33101af0b4SGreg Roach	/**
3473d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
3500225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
36101af0b4SGreg Roach	 */
3700225b98SGreg Roach	public function testNoSpouseFamiliesMale() {
38c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
3900225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
40*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([]);
4100225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
42101af0b4SGreg Roach
43c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
4400225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
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
5300225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
5473d4df56SGreg Roach	 */
5500225b98SGreg Roach	public function testNoSpouseFamiliesFemale() {
5600225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
5700225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
58*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([]);
5900225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
6000225b98SGreg Roach
6100225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
6200225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
6300225b98SGreg Roach
6400225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
6500225b98SGreg Roach
6600225b98SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
6700225b98SGreg Roach	}
6800225b98SGreg Roach
6900225b98SGreg Roach	/**
7000225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
7100225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
7200225b98SGreg Roach	 */
73e76c0cf0SGreg Roach	public function testNoFamilyFactsMale() {
74e76c0cf0SGreg Roach		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
75e76c0cf0SGreg Roach		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1850'));
76e76c0cf0SGreg Roach
77c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
7873d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
79*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->andReturn([]);
80e76c0cf0SGreg Roach		$family->shouldReceive('getSpouse')->andReturn($spouse);
8173d4df56SGreg Roach
82c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
8300225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
84*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
8573d4df56SGreg Roach
86c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
8773d4df56SGreg Roach
8873d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
8973d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
9073d4df56SGreg Roach
9173d4df56SGreg Roach		$this->assertSame('Gift', $column->generate($individual));
9273d4df56SGreg Roach	}
9373d4df56SGreg Roach
9473d4df56SGreg Roach	/**
9573d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
9600225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
9773d4df56SGreg Roach	 */
98e76c0cf0SGreg Roach	public function testNoFamilyFactsFemale() {
99e76c0cf0SGreg Roach		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
100e76c0cf0SGreg Roach		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1850'));
101e76c0cf0SGreg Roach
102c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
10373d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
104*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->andReturn([]);
105e76c0cf0SGreg Roach		$family->shouldReceive('getSpouse')->andReturn($spouse);
106e76c0cf0SGreg Roach
107e76c0cf0SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
108e76c0cf0SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
109*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
110e76c0cf0SGreg Roach
111e76c0cf0SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
112e76c0cf0SGreg Roach
113e76c0cf0SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
114e76c0cf0SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
115e76c0cf0SGreg Roach
116e76c0cf0SGreg Roach		$this->assertSame('Gift', $column->generate($individual));
117e76c0cf0SGreg Roach	}
118e76c0cf0SGreg Roach
119e76c0cf0SGreg Roach	/**
120e76c0cf0SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
121e76c0cf0SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
122e76c0cf0SGreg Roach	 */
123e76c0cf0SGreg Roach	public function testSpouseDeadMale() {
124e76c0cf0SGreg Roach		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
125e76c0cf0SGreg Roach		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
126e76c0cf0SGreg Roach
127e76c0cf0SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
128e76c0cf0SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
129*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->andReturn([]);
130e76c0cf0SGreg Roach		$family->shouldReceive('getSpouse')->andReturn($spouse);
131e76c0cf0SGreg Roach
132e76c0cf0SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
133e76c0cf0SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
134*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
135e76c0cf0SGreg Roach
136e76c0cf0SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
137e76c0cf0SGreg Roach
138e76c0cf0SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
139e76c0cf0SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
140e76c0cf0SGreg Roach
141e76c0cf0SGreg Roach		$this->assertSame('Gift', $column->generate($individual));
142e76c0cf0SGreg Roach	}
143e76c0cf0SGreg Roach
144e76c0cf0SGreg Roach	/**
145e76c0cf0SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
146e76c0cf0SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
147e76c0cf0SGreg Roach	 */
148e76c0cf0SGreg Roach	public function testSpouseDeadFemale() {
149e76c0cf0SGreg Roach		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
150e76c0cf0SGreg Roach		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
151e76c0cf0SGreg Roach
152e76c0cf0SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
153e76c0cf0SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
154*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->andReturn([]);
155e76c0cf0SGreg Roach		$family->shouldReceive('getSpouse')->andReturn($spouse);
15673d4df56SGreg Roach
157c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
15800225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
159*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
16073d4df56SGreg Roach
161c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
16273d4df56SGreg Roach
16373d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
16473d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
16573d4df56SGreg Roach
16600225b98SGreg Roach		$this->assertSame('Gift', $column->generate($individual));
16700225b98SGreg Roach	}
16800225b98SGreg Roach
16900225b98SGreg Roach	/**
17000225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
17100225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
17200225b98SGreg Roach	 */
17300225b98SGreg Roach	public function testNoFamilyUnmarriedMale() {
17400225b98SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
17500225b98SGreg Roach
17600225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
17700225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
178*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]);
17900225b98SGreg Roach
18000225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
18100225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
182*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
18300225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
18400225b98SGreg Roach
18500225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
18600225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
18700225b98SGreg Roach
18800225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
18900225b98SGreg Roach
19073d4df56SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
19173d4df56SGreg Roach	}
19273d4df56SGreg Roach
19373d4df56SGreg Roach	/**
19473d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
19500225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
19673d4df56SGreg Roach	 */
19700225b98SGreg Roach	public function testNoFamilyUnmarriedFemale() {
19800225b98SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
19900225b98SGreg Roach
20000225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
20100225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
202*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]);
20300225b98SGreg Roach
20400225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
20500225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
206*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
20700225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
20800225b98SGreg Roach
20900225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
21000225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
21100225b98SGreg Roach
21200225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
21300225b98SGreg Roach
21400225b98SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
21500225b98SGreg Roach	}
21600225b98SGreg Roach
21700225b98SGreg Roach	/**
21800225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
21900225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
22000225b98SGreg Roach	 */
22100225b98SGreg Roach	public function testChildMale() {
22200225b98SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
22300225b98SGreg Roach
22400225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
22500225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
226*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]);
22700225b98SGreg Roach
22800225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
22900225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
230*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
23100225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
23200225b98SGreg Roach
23300225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
23400225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
23500225b98SGreg Roach
23600225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
23700225b98SGreg Roach
23800225b98SGreg Roach		$this->assertSame('', $column->generate($individual));
23900225b98SGreg Roach	}
24000225b98SGreg Roach
24100225b98SGreg Roach	/**
24200225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
24300225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
24400225b98SGreg Roach	 */
24500225b98SGreg Roach	public function testChildFemale() {
24600225b98SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
24700225b98SGreg Roach
24800225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
24900225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
250*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]);
25100225b98SGreg Roach
25200225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
25300225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
254*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
25500225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
25600225b98SGreg Roach
25700225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
25800225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
25900225b98SGreg Roach
26000225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
26100225b98SGreg Roach
26200225b98SGreg Roach		$this->assertSame('', $column->generate($individual));
26300225b98SGreg Roach	}
26400225b98SGreg Roach
26500225b98SGreg Roach	/**
26600225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
26700225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
26800225b98SGreg Roach	 */
26900225b98SGreg Roach	public function testDivorcedMale() {
270c314ecc9SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
27173d4df56SGreg Roach
272c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
27373d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
274*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn([]);
275*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
27673d4df56SGreg Roach
277c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
27800225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
279*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
28000225b98SGreg Roach
28100225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
28200225b98SGreg Roach
28300225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
28400225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
28500225b98SGreg Roach
28600225b98SGreg Roach		$this->assertSame('Skilt', $column->generate($individual));
28700225b98SGreg Roach	}
28800225b98SGreg Roach
28900225b98SGreg Roach	/**
29000225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish
29100225b98SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
29200225b98SGreg Roach	 */
29300225b98SGreg Roach	public function testDivorcedFemale() {
29400225b98SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
29500225b98SGreg Roach
29600225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
29700225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
298*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn([]);
299*13abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
30000225b98SGreg Roach
30100225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
30200225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
303*13abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
30473d4df56SGreg Roach
305c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
30673d4df56SGreg Roach
30773d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
30873d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
30973d4df56SGreg Roach
31073d4df56SGreg Roach		$this->assertSame('Skilt', $column->generate($individual));
311101af0b4SGreg Roach	}
312101af0b4SGreg Roach}
313