xref: /webtrees/tests/app/Census/CensusColumnConditionDanishTest.php (revision 342dcecd8628deacd49d86f3247fd77e64bf33c3)
1101af0b4SGreg Roach<?php
2101af0b4SGreg Roach
3101af0b4SGreg Roach/**
4101af0b4SGreg Roach * webtrees: online genealogy
51062a142SGreg 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 */
25c1010edaSGreg Roachclass CensusColumnConditionDanishTest extends \PHPUnit\Framework\TestCase
26c1010edaSGreg Roach{
27101af0b4SGreg Roach    /**
28101af0b4SGreg Roach     * Delete mock objects
29101af0b4SGreg Roach     */
30c1010edaSGreg Roach    public function tearDown()
31c1010edaSGreg Roach    {
32101af0b4SGreg Roach        Mockery::close();
33101af0b4SGreg Roach    }
34101af0b4SGreg Roach
35101af0b4SGreg Roach    /**
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
3715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
38101af0b4SGreg Roach     */
39c1010edaSGreg Roach    public function testNoSpouseFamiliesMale()
40c1010edaSGreg Roach    {
41c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
4200225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
4313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
4400225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
45101af0b4SGreg Roach
46c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
4700225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
48101af0b4SGreg Roach
4973d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
50101af0b4SGreg Roach
51*342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
5273d4df56SGreg Roach    }
5373d4df56SGreg Roach
5473d4df56SGreg Roach    /**
5515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
5615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
5773d4df56SGreg Roach     */
58c1010edaSGreg Roach    public function testNoSpouseFamiliesFemale()
59c1010edaSGreg Roach    {
6000225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
6100225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
6213abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
6300225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
6400225b98SGreg Roach
6500225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
6600225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
6700225b98SGreg Roach
6800225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
6900225b98SGreg Roach
70*342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
7100225b98SGreg Roach    }
7200225b98SGreg Roach
7300225b98SGreg Roach    /**
7415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
7515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
7600225b98SGreg Roach     */
77c1010edaSGreg Roach    public function testNoFamilyFactsMale()
78c1010edaSGreg Roach    {
79c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
8073d4df56SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
812a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
8273d4df56SGreg Roach
83c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
8413abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
852a6fda60SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
862a6fda60SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
8773d4df56SGreg Roach
88c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
8973d4df56SGreg Roach
9073d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
9173d4df56SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
9273d4df56SGreg Roach
93*342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
9473d4df56SGreg Roach    }
9573d4df56SGreg Roach
9673d4df56SGreg Roach    /**
9715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
9815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
9973d4df56SGreg Roach     */
100c1010edaSGreg Roach    public function testNoFamilyFactsFemale()
101c1010edaSGreg Roach    {
102c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
10373d4df56SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1042a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
105e76c0cf0SGreg Roach
106e76c0cf0SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1082a6fda60SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
1092a6fda60SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
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
116*342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
117e76c0cf0SGreg Roach    }
118e76c0cf0SGreg Roach
119e76c0cf0SGreg Roach    /**
12015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
12115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
122e76c0cf0SGreg Roach     */
123c1010edaSGreg Roach    public function testSpouseDeadMale()
124c1010edaSGreg Roach    {
1252a6fda60SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
1262a6fda60SGreg Roach
127e76c0cf0SGreg Roach        $spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
128e76c0cf0SGreg Roach        $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
129e76c0cf0SGreg Roach
130e76c0cf0SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
131e76c0cf0SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1322a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1332a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([]);
134e76c0cf0SGreg Roach        $family->shouldReceive('getSpouse')->andReturn($spouse);
135e76c0cf0SGreg Roach
136e76c0cf0SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
137e76c0cf0SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
13813abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
139e76c0cf0SGreg Roach
140e76c0cf0SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
141e76c0cf0SGreg Roach
142e76c0cf0SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
143e76c0cf0SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
144e76c0cf0SGreg Roach
145*342dcecdSGreg Roach        $this->assertSame('Gift', $column->generate($individual, $individual));
146e76c0cf0SGreg Roach    }
147e76c0cf0SGreg Roach
148e76c0cf0SGreg Roach    /**
14915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
15015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
151e76c0cf0SGreg Roach     */
152c1010edaSGreg Roach    public function testSpouseDeadFemale()
153c1010edaSGreg Roach    {
1542a6fda60SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
1552a6fda60SGreg Roach
156e76c0cf0SGreg Roach        $spouse = Mockery::mock('Fisharebest\Webtrees\Individual');
157e76c0cf0SGreg Roach        $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
158e76c0cf0SGreg Roach
159e76c0cf0SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
160e76c0cf0SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1612a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1622a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([]);
163e76c0cf0SGreg Roach        $family->shouldReceive('getSpouse')->andReturn($spouse);
16473d4df56SGreg Roach
165c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
16600225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
16713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
16873d4df56SGreg Roach
169c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
17073d4df56SGreg Roach
17173d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
17273d4df56SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
17373d4df56SGreg Roach
174*342dcecdSGreg Roach        $this->assertSame('Gift', $column->generate($individual, $individual));
17500225b98SGreg Roach    }
17600225b98SGreg Roach
17700225b98SGreg Roach    /**
17815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
17915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
18000225b98SGreg Roach     */
181c1010edaSGreg Roach    public function testNoFamilyUnmarriedMale()
182c1010edaSGreg Roach    {
18300225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
18400225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
1852a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
18600225b98SGreg Roach
18700225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
18800225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
18913abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
19000225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
19100225b98SGreg Roach
19200225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
19300225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
19400225b98SGreg Roach
19500225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
19600225b98SGreg Roach
197*342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
19873d4df56SGreg Roach    }
19973d4df56SGreg Roach
20073d4df56SGreg Roach    /**
20115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
20215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
20373d4df56SGreg Roach     */
204c1010edaSGreg Roach    public function testNoFamilyUnmarriedFemale()
205c1010edaSGreg Roach    {
20600225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
20700225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2082a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
20900225b98SGreg Roach
21000225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
21100225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
21213abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
21300225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
21400225b98SGreg Roach
21500225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
21600225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
21700225b98SGreg Roach
21800225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
21900225b98SGreg Roach
220*342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
22100225b98SGreg Roach    }
22200225b98SGreg Roach
22300225b98SGreg Roach    /**
22415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
22515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
22600225b98SGreg Roach     */
227c1010edaSGreg Roach    public function testChildMale()
228c1010edaSGreg Roach    {
22900225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
23000225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2312a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
23200225b98SGreg Roach
23300225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
23400225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
23513abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
23600225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
23700225b98SGreg Roach
23800225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
23900225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
24000225b98SGreg Roach
24100225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
24200225b98SGreg Roach
243*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
24400225b98SGreg Roach    }
24500225b98SGreg Roach
24600225b98SGreg Roach    /**
24715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
24815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
24900225b98SGreg Roach     */
250c1010edaSGreg Roach    public function testChildFemale()
251c1010edaSGreg Roach    {
25200225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
25300225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2542a6fda60SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
25500225b98SGreg Roach
25600225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
25700225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
25813abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
25900225b98SGreg Roach        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
26000225b98SGreg Roach
26100225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
26200225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
26300225b98SGreg Roach
26400225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
26500225b98SGreg Roach
266*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
26700225b98SGreg Roach    }
26800225b98SGreg Roach
26900225b98SGreg Roach    /**
27015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
27115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
27200225b98SGreg Roach     */
273c1010edaSGreg Roach    public function testDivorcedMale()
274c1010edaSGreg Roach    {
275c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
27673d4df56SGreg Roach
277c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
27873d4df56SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
2790b4be234SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
28013abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
28173d4df56SGreg Roach
282c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
28300225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('M');
28413abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
28500225b98SGreg Roach
28600225b98SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
28700225b98SGreg Roach
28800225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
28900225b98SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
29000225b98SGreg Roach
291*342dcecdSGreg Roach        $this->assertSame('Skilt', $column->generate($individual, $individual));
29200225b98SGreg Roach    }
29300225b98SGreg Roach
29400225b98SGreg Roach    /**
29515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
29615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
29700225b98SGreg Roach     */
298c1010edaSGreg Roach    public function testDivorcedFemale()
299c1010edaSGreg Roach    {
30000225b98SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
30100225b98SGreg Roach
30200225b98SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
30300225b98SGreg Roach        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
3040b4be234SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
30513abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]);
30600225b98SGreg Roach
30700225b98SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
30800225b98SGreg Roach        $individual->shouldReceive('getSex')->andReturn('F');
30913abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
31073d4df56SGreg Roach
311c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
31273d4df56SGreg Roach
31373d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
31473d4df56SGreg Roach        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
31573d4df56SGreg Roach
316*342dcecdSGreg Roach        $this->assertSame('Skilt', $column->generate($individual, $individual));
317101af0b4SGreg Roach    }
318101af0b4SGreg Roach}
319