xref: /webtrees/tests/app/Census/CensusColumnConditionUsTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
181d1be7aSGreg Roach<?php
281d1be7aSGreg Roach/**
381d1be7aSGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
581d1be7aSGreg Roach * This program is free software: you can redistribute it and/or modify
681d1be7aSGreg Roach * it under the terms of the GNU General Public License as published by
781d1be7aSGreg Roach * the Free Software Foundation, either version 3 of the License, or
881d1be7aSGreg Roach * (at your option) any later version.
981d1be7aSGreg Roach * This program is distributed in the hope that it will be useful,
1081d1be7aSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1181d1be7aSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1281d1be7aSGreg Roach * GNU General Public License for more details.
1381d1be7aSGreg Roach * You should have received a copy of the GNU General Public License
1481d1be7aSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1581d1be7aSGreg Roach */
1681d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census;
1781d1be7aSGreg Roach
1881d1be7aSGreg Roachuse Fisharebest\Webtrees\Date;
1981d1be7aSGreg Roachuse Mockery;
2081d1be7aSGreg Roach
2181d1be7aSGreg Roach/**
2281d1be7aSGreg Roach * Test harness for the class CensusColumnConditionUs
2381d1be7aSGreg Roach */
24*84e2cf4eSGreg Roachclass CensusColumnConditionUsTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
2681d1be7aSGreg Roach    /**
2781d1be7aSGreg Roach     * Delete mock objects
2881d1be7aSGreg Roach     */
29c1010edaSGreg Roach    public function tearDown()
30c1010edaSGreg Roach    {
3181d1be7aSGreg Roach        Mockery::close();
3281d1be7aSGreg Roach    }
3381d1be7aSGreg Roach
3481d1be7aSGreg Roach    /**
3515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
3781d1be7aSGreg Roach     */
38c1010edaSGreg Roach    public function testNoSpouseFamiliesMale()
39c1010edaSGreg Roach    {
4081d1be7aSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
4100225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
4213abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
4300225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
4481d1be7aSGreg Roach
4581d1be7aSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
4600225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
4781d1be7aSGreg Roach
4881d1be7aSGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
4981d1be7aSGreg Roach
50342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
5181d1be7aSGreg Roach    }
5281d1be7aSGreg Roach
5381d1be7aSGreg Roach    /**
5415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
5515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
5681d1be7aSGreg Roach     */
57c1010edaSGreg Roach    public function testNoSpouseFamiliesFemale()
58c1010edaSGreg Roach    {
5900225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
6000225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
6113abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
6200225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
6300225b98SGreg Roach
6400225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
6500225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
6600225b98SGreg Roach
6700225b98SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
6800225b98SGreg Roach
69342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
7000225b98SGreg Roach    }
7100225b98SGreg Roach
7200225b98SGreg Roach    /**
7315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
7415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
7500225b98SGreg Roach     */
76c1010edaSGreg Roach    public function testNoFamilyFactsMale()
77c1010edaSGreg Roach    {
7881d1be7aSGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
7981d1be7aSGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
802a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
8181d1be7aSGreg Roach
8281d1be7aSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
8313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
842a6fda60SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
852a6fda60SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
8681d1be7aSGreg Roach
8781d1be7aSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
8881d1be7aSGreg Roach
8981d1be7aSGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
9081d1be7aSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
9181d1be7aSGreg Roach
92342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
9381d1be7aSGreg Roach    }
9481d1be7aSGreg Roach
9581d1be7aSGreg Roach    /**
9615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
9715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
9881d1be7aSGreg Roach     */
99c1010edaSGreg Roach    public function testNoFamilyFactsFemale()
100c1010edaSGreg Roach    {
10181d1be7aSGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
10281d1be7aSGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1032a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
10481d1be7aSGreg Roach
10581d1be7aSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10613abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1072a6fda60SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
1082a6fda60SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
10981d1be7aSGreg Roach
11081d1be7aSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
11181d1be7aSGreg Roach
11281d1be7aSGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
11381d1be7aSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
11481d1be7aSGreg Roach
115342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
11600225b98SGreg Roach    }
11700225b98SGreg Roach
11800225b98SGreg Roach    /**
11915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
12015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
12100225b98SGreg Roach     */
122c1010edaSGreg Roach    public function testSpouseDeadMale()
123c1010edaSGreg Roach    {
1242a6fda60SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
1252a6fda60SGreg Roach
126e76c0cf0SGreg Roach        $spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
127e76c0cf0SGreg Roach        $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
128e76c0cf0SGreg Roach
129e76c0cf0SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
130e76c0cf0SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1312a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1322a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([]);
133e76c0cf0SGreg Roach        $family->shouldReceive('getSpouse')->andReturn($spouse);
134e76c0cf0SGreg Roach
135e76c0cf0SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
136e76c0cf0SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
13713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
138e76c0cf0SGreg Roach
139e76c0cf0SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
140e76c0cf0SGreg Roach
141e76c0cf0SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
142e76c0cf0SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
143e76c0cf0SGreg Roach
144342dcecdSGreg Roach        $this->assertSame('W', $column->generate($individual, $individual));
145e76c0cf0SGreg Roach    }
146e76c0cf0SGreg Roach
147e76c0cf0SGreg Roach    /**
14815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
14915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
150e76c0cf0SGreg Roach     */
151c1010edaSGreg Roach    public function testSpouseDeadFemale()
152c1010edaSGreg Roach    {
1532a6fda60SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
1542a6fda60SGreg Roach
155e76c0cf0SGreg Roach        $spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
156e76c0cf0SGreg Roach        $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
157e76c0cf0SGreg Roach
158e76c0cf0SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
159e76c0cf0SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1602a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1612a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([]);
162e76c0cf0SGreg Roach        $family->shouldReceive('getSpouse')->andReturn($spouse);
163e76c0cf0SGreg Roach
164e76c0cf0SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
165e76c0cf0SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
16613abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
167e76c0cf0SGreg Roach
168e76c0cf0SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
169e76c0cf0SGreg Roach
170e76c0cf0SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
171e76c0cf0SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
172e76c0cf0SGreg Roach
173342dcecdSGreg Roach        $this->assertSame('W', $column->generate($individual, $individual));
174e76c0cf0SGreg Roach    }
175e76c0cf0SGreg Roach
176e76c0cf0SGreg Roach    /**
17715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
17815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
179e76c0cf0SGreg Roach     */
180c1010edaSGreg Roach    public function testNoFamilyUnmarriedMale()
181c1010edaSGreg Roach    {
18200225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
18300225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1842a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
18500225b98SGreg Roach
18600225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
18700225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
18813abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
18900225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
19000225b98SGreg Roach
19100225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
19200225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
19300225b98SGreg Roach
19400225b98SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
19500225b98SGreg Roach
196342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
19781d1be7aSGreg Roach    }
19881d1be7aSGreg Roach
19981d1be7aSGreg Roach    /**
20015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
20115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
20281d1be7aSGreg Roach     */
203c1010edaSGreg Roach    public function testNoFamilyUnmarriedFemale()
204c1010edaSGreg Roach    {
20500225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
20600225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2072a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
20800225b98SGreg Roach
20900225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
21000225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
21113abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
21200225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
21300225b98SGreg Roach
21400225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
21500225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
21600225b98SGreg Roach
21700225b98SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
21800225b98SGreg Roach
219342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
22000225b98SGreg Roach    }
22100225b98SGreg Roach
22200225b98SGreg Roach    /**
22315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
22415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
22500225b98SGreg Roach     */
226c1010edaSGreg Roach    public function testChildMale()
227c1010edaSGreg Roach    {
22800225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
22900225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2302a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
23100225b98SGreg Roach
23200225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
23300225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
23413abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
23500225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
23600225b98SGreg Roach
23700225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
23800225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
23900225b98SGreg Roach
24000225b98SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
24100225b98SGreg Roach
242342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
24300225b98SGreg Roach    }
24400225b98SGreg Roach
24500225b98SGreg Roach    /**
24615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
24715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
24800225b98SGreg Roach     */
249c1010edaSGreg Roach    public function testChildFemale()
250c1010edaSGreg Roach    {
25100225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
25200225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2532a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
25400225b98SGreg Roach
25500225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
25600225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
25713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
25800225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
25900225b98SGreg Roach
26000225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
26100225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
26200225b98SGreg Roach
26300225b98SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
26400225b98SGreg Roach
265342dcecdSGreg Roach        $this->assertSame('S', $column->generate($individual, $individual));
26600225b98SGreg Roach    }
26700225b98SGreg Roach
26800225b98SGreg Roach    /**
26915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
27015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
27100225b98SGreg Roach     */
272c1010edaSGreg Roach    public function testDivorcedMale()
273c1010edaSGreg Roach    {
27481d1be7aSGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
27581d1be7aSGreg Roach
27681d1be7aSGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
27781d1be7aSGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2780b4be234SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
27913abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
28081d1be7aSGreg Roach
28181d1be7aSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
28200225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
28313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
28400225b98SGreg Roach
28500225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
28600225b98SGreg Roach
28700225b98SGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
28800225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
28900225b98SGreg Roach
290342dcecdSGreg Roach        $this->assertSame('D', $column->generate($individual, $individual));
29100225b98SGreg Roach    }
29200225b98SGreg Roach
29300225b98SGreg Roach    /**
29415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs
29515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
29600225b98SGreg Roach     */
297c1010edaSGreg Roach    public function testDivorcedFemale()
298c1010edaSGreg Roach    {
29900225b98SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
30000225b98SGreg Roach
30100225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
30200225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
3030b4be234SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
30413abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
30500225b98SGreg Roach
30600225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
30700225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
30813abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
30981d1be7aSGreg Roach
31081d1be7aSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
31181d1be7aSGreg Roach
31281d1be7aSGreg Roach        $column = new CensusColumnConditionUs($census, '', '');
31381d1be7aSGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
31481d1be7aSGreg Roach
315342dcecdSGreg Roach        $this->assertSame('D', $column->generate($individual, $individual));
31681d1be7aSGreg Roach    }
31781d1be7aSGreg Roach}
318