xref: /webtrees/tests/app/Census/CensusColumnConditionDanishTest.php (revision 1062a1429914c995339f502856821457aa975a5a)
1101af0b4SGreg Roach<?php
2101af0b4SGreg Roach
3101af0b4SGreg Roach/**
4101af0b4SGreg Roach * webtrees: online genealogy
5*1062a142SGreg Roach * Copyright (C) 2018 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 */
253e983931SGreg 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	/**
3415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
3515d603e7SGreg 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');
4013abd6f3SGreg 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	/**
5215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
5315d603e7SGreg 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');
5813abd6f3SGreg 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	/**
7015d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
7115d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
7200225b98SGreg Roach	 */
73e76c0cf0SGreg Roach	public function testNoFamilyFactsMale() {
74c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
7573d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
762a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
7773d4df56SGreg Roach
78c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
7913abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
802a6fda60SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
812a6fda60SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
8273d4df56SGreg Roach
83c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
8473d4df56SGreg Roach
8573d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
8673d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
8773d4df56SGreg Roach
882a6fda60SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
8973d4df56SGreg Roach	}
9073d4df56SGreg Roach
9173d4df56SGreg Roach	/**
9215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
9315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
9473d4df56SGreg Roach	 */
95e76c0cf0SGreg Roach	public function testNoFamilyFactsFemale() {
96c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
9773d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
982a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
99e76c0cf0SGreg Roach
100e76c0cf0SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10113abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1022a6fda60SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
1032a6fda60SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
104e76c0cf0SGreg Roach
105e76c0cf0SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
106e76c0cf0SGreg Roach
107e76c0cf0SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
108e76c0cf0SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
109e76c0cf0SGreg Roach
1102a6fda60SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
111e76c0cf0SGreg Roach	}
112e76c0cf0SGreg Roach
113e76c0cf0SGreg Roach	/**
11415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
11515d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
116e76c0cf0SGreg Roach	 */
117e76c0cf0SGreg Roach	public function testSpouseDeadMale() {
1182a6fda60SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
1192a6fda60SGreg Roach
120e76c0cf0SGreg Roach		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
121e76c0cf0SGreg Roach		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
122e76c0cf0SGreg Roach
123e76c0cf0SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
124e76c0cf0SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1252a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1262a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn([]);
127e76c0cf0SGreg Roach		$family->shouldReceive('getSpouse')->andReturn($spouse);
128e76c0cf0SGreg Roach
129e76c0cf0SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
130e76c0cf0SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
13113abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
132e76c0cf0SGreg Roach
133e76c0cf0SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
134e76c0cf0SGreg Roach
135e76c0cf0SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
136e76c0cf0SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
137e76c0cf0SGreg Roach
138e76c0cf0SGreg Roach		$this->assertSame('Gift', $column->generate($individual));
139e76c0cf0SGreg Roach	}
140e76c0cf0SGreg Roach
141e76c0cf0SGreg Roach	/**
14215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
14315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
144e76c0cf0SGreg Roach	 */
145e76c0cf0SGreg Roach	public function testSpouseDeadFemale() {
1462a6fda60SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
1472a6fda60SGreg Roach
148e76c0cf0SGreg Roach		$spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
149e76c0cf0SGreg Roach		$spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
150e76c0cf0SGreg Roach
151e76c0cf0SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
152e76c0cf0SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1532a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1542a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->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');
15913abd6f3SGreg 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	/**
17015d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
17115d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
17200225b98SGreg Roach	 */
17300225b98SGreg Roach	public function testNoFamilyUnmarriedMale() {
17400225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
17500225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1762a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
17700225b98SGreg Roach
17800225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
17900225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
18013abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
18100225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
18200225b98SGreg Roach
18300225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
18400225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
18500225b98SGreg Roach
18600225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
18700225b98SGreg Roach
18873d4df56SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
18973d4df56SGreg Roach	}
19073d4df56SGreg Roach
19173d4df56SGreg Roach	/**
19215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
19315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
19473d4df56SGreg Roach	 */
19500225b98SGreg Roach	public function testNoFamilyUnmarriedFemale() {
19600225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
19700225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1982a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
19900225b98SGreg Roach
20000225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
20100225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
20213abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
20300225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
20400225b98SGreg Roach
20500225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
20600225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
20700225b98SGreg Roach
20800225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
20900225b98SGreg Roach
21000225b98SGreg Roach		$this->assertSame('Ugift', $column->generate($individual));
21100225b98SGreg Roach	}
21200225b98SGreg Roach
21300225b98SGreg Roach	/**
21415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
21515d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
21600225b98SGreg Roach	 */
21700225b98SGreg Roach	public function testChildMale() {
21800225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
21900225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2202a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
22100225b98SGreg Roach
22200225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
22300225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
22413abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
22500225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
22600225b98SGreg Roach
22700225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
22800225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
22900225b98SGreg Roach
23000225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
23100225b98SGreg Roach
23200225b98SGreg Roach		$this->assertSame('', $column->generate($individual));
23300225b98SGreg Roach	}
23400225b98SGreg Roach
23500225b98SGreg Roach	/**
23615d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
23715d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
23800225b98SGreg Roach	 */
23900225b98SGreg Roach	public function testChildFemale() {
24000225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
24100225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2422a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
24300225b98SGreg Roach
24400225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
24500225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
24613abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
24700225b98SGreg Roach		$individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
24800225b98SGreg Roach
24900225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
25000225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
25100225b98SGreg Roach
25200225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
25300225b98SGreg Roach
25400225b98SGreg Roach		$this->assertSame('', $column->generate($individual));
25500225b98SGreg Roach	}
25600225b98SGreg Roach
25700225b98SGreg Roach	/**
25815d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
25915d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
26000225b98SGreg Roach	 */
26100225b98SGreg Roach	public function testDivorcedMale() {
262c314ecc9SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
26373d4df56SGreg Roach
264c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
26573d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2660b4be234SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
26713abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
26873d4df56SGreg Roach
269c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
27000225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('M');
27113abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
27200225b98SGreg Roach
27300225b98SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
27400225b98SGreg Roach
27500225b98SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
27600225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
27700225b98SGreg Roach
27800225b98SGreg Roach		$this->assertSame('Skilt', $column->generate($individual));
27900225b98SGreg Roach	}
28000225b98SGreg Roach
28100225b98SGreg Roach	/**
28215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
28315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
28400225b98SGreg Roach	 */
28500225b98SGreg Roach	public function testDivorcedFemale() {
28600225b98SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
28700225b98SGreg Roach
28800225b98SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
28900225b98SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2900b4be234SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
29113abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
29200225b98SGreg Roach
29300225b98SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
29400225b98SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
29513abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
29673d4df56SGreg Roach
297c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
29873d4df56SGreg Roach
29973d4df56SGreg Roach		$column = new CensusColumnConditionDanish($census, '', '');
30073d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
30173d4df56SGreg Roach
30273d4df56SGreg Roach		$this->assertSame('Skilt', $column->generate($individual));
303101af0b4SGreg Roach	}
304101af0b4SGreg Roach}
305