xref: /webtrees/tests/app/Census/CensusColumnConditionUsTest.php (revision 0b4be234dbaad0b8eb769cb2be9731f8dd710db3)
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 CensusColumnConditionUs
2481d1be7aSGreg Roach */
2581d1be7aSGreg Roachclass CensusColumnConditionUsTest 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	/**
3415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
3515d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
3681d1be7aSGreg Roach	 */
3700225b98SGreg Roach	public function testNoSpouseFamiliesMale() {
3881d1be7aSGreg 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'));
4281d1be7aSGreg Roach
4381d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
4400225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
4581d1be7aSGreg Roach
4681d1be7aSGreg Roach		$column = new CensusColumnConditionUs($census, '', '');
4781d1be7aSGreg Roach
4881d1be7aSGreg Roach		$this->assertSame('S', $column->generate($individual));
4981d1be7aSGreg Roach	}
5081d1be7aSGreg Roach
5181d1be7aSGreg Roach	/**
5215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
5315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
5481d1be7aSGreg 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 CensusColumnConditionUs($census, '', '');
6500225b98SGreg Roach
6600225b98SGreg Roach		$this->assertSame('S', $column->generate($individual));
6700225b98SGreg Roach	}
6800225b98SGreg Roach
6900225b98SGreg Roach	/**
7015d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
7115d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
7200225b98SGreg Roach	 */
73e76c0cf0SGreg Roach	public function testNoFamilyFactsMale() {
7481d1be7aSGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
7581d1be7aSGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
762a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
7781d1be7aSGreg Roach
7881d1be7aSGreg 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');
8281d1be7aSGreg Roach
8381d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
8481d1be7aSGreg Roach
8581d1be7aSGreg Roach		$column = new CensusColumnConditionUs($census, '', '');
8681d1be7aSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
8781d1be7aSGreg Roach
882a6fda60SGreg Roach		$this->assertSame('S', $column->generate($individual));
8981d1be7aSGreg Roach	}
9081d1be7aSGreg Roach
9181d1be7aSGreg Roach	/**
9215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
9315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
9481d1be7aSGreg Roach	 */
95e76c0cf0SGreg Roach	public function testNoFamilyFactsFemale() {
9681d1be7aSGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
9781d1be7aSGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
982a6fda60SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
9981d1be7aSGreg Roach
10081d1be7aSGreg 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');
10481d1be7aSGreg Roach
10581d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
10681d1be7aSGreg Roach
10781d1be7aSGreg Roach		$column = new CensusColumnConditionUs($census, '', '');
10881d1be7aSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
10981d1be7aSGreg Roach
1102a6fda60SGreg Roach		$this->assertSame('S', $column->generate($individual));
11100225b98SGreg Roach	}
11200225b98SGreg Roach
11300225b98SGreg Roach	/**
11415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
11515d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
11600225b98SGreg 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 CensusColumnConditionUs($census, '', '');
136e76c0cf0SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
137e76c0cf0SGreg Roach
138e76c0cf0SGreg Roach		$this->assertSame('W', $column->generate($individual));
139e76c0cf0SGreg Roach	}
140e76c0cf0SGreg Roach
141e76c0cf0SGreg Roach	/**
14215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
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);
156e76c0cf0SGreg Roach
157e76c0cf0SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
158e76c0cf0SGreg Roach		$individual->shouldReceive('getSex')->andReturn('F');
15913abd6f3SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
160e76c0cf0SGreg Roach
161e76c0cf0SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
162e76c0cf0SGreg Roach
163e76c0cf0SGreg Roach		$column = new CensusColumnConditionUs($census, '', '');
164e76c0cf0SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
165e76c0cf0SGreg Roach
166e76c0cf0SGreg Roach		$this->assertSame('W', $column->generate($individual));
167e76c0cf0SGreg Roach	}
168e76c0cf0SGreg Roach
169e76c0cf0SGreg Roach	/**
17015d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
17115d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
172e76c0cf0SGreg 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 CensusColumnConditionUs($census, '', '');
18700225b98SGreg Roach
18881d1be7aSGreg Roach		$this->assertSame('S', $column->generate($individual));
18981d1be7aSGreg Roach	}
19081d1be7aSGreg Roach
19181d1be7aSGreg Roach	/**
19215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
19315d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
19481d1be7aSGreg 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 CensusColumnConditionUs($census, '', '');
20900225b98SGreg Roach
21000225b98SGreg Roach		$this->assertSame('S', $column->generate($individual));
21100225b98SGreg Roach	}
21200225b98SGreg Roach
21300225b98SGreg Roach	/**
21415d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
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 CensusColumnConditionUs($census, '', '');
23100225b98SGreg Roach
23200225b98SGreg Roach		$this->assertSame('S', $column->generate($individual));
23300225b98SGreg Roach	}
23400225b98SGreg Roach
23500225b98SGreg Roach	/**
23615d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
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 CensusColumnConditionUs($census, '', '');
25300225b98SGreg Roach
25400225b98SGreg Roach		$this->assertSame('S', $column->generate($individual));
25500225b98SGreg Roach	}
25600225b98SGreg Roach
25700225b98SGreg Roach	/**
25815d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
25915d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
26000225b98SGreg Roach	 */
26100225b98SGreg Roach	public function testDivorcedMale() {
26281d1be7aSGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
26381d1be7aSGreg Roach
26481d1be7aSGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
26581d1be7aSGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
266*0b4be234SGreg Roach		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
26713abd6f3SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
26881d1be7aSGreg Roach
26981d1be7aSGreg 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 CensusColumnConditionUs($census, '', '');
27600225b98SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
27700225b98SGreg Roach
27800225b98SGreg Roach		$this->assertSame('D', $column->generate($individual));
27900225b98SGreg Roach	}
28000225b98SGreg Roach
28100225b98SGreg Roach	/**
28215d603e7SGreg Roach	 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
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(''));
290*0b4be234SGreg 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]);
29681d1be7aSGreg Roach
29781d1be7aSGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
29881d1be7aSGreg Roach
29981d1be7aSGreg Roach		$column = new CensusColumnConditionUs($census, '', '');
30081d1be7aSGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
30181d1be7aSGreg Roach
30281d1be7aSGreg Roach		$this->assertSame('D', $column->generate($individual));
30381d1be7aSGreg Roach	}
30481d1be7aSGreg Roach}
305