xref: /webtrees/tests/app/Census/CensusColumnConditionDanishTest.php (revision 3cfcc809af53e831fa6cafac7b274a2cb407db6e)
1101af0b4SGreg Roach<?php
23976b470SGreg Roach
3101af0b4SGreg Roach/**
4101af0b4SGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 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 */
17e7f56f2aSGreg Roachdeclare(strict_types=1);
18e7f56f2aSGreg Roach
19101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census;
20101af0b4SGreg Roach
21101af0b4SGreg Roachuse Fisharebest\Webtrees\Date;
22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
25*3cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
2639ca88baSGreg Roachuse Illuminate\Support\Collection;
27101af0b4SGreg Roach
28101af0b4SGreg Roach/**
2973d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish
30101af0b4SGreg Roach */
31*3cfcc809SGreg Roachclass CensusColumnConditionDanishTest extends TestCase
32c1010edaSGreg Roach{
33101af0b4SGreg Roach    /**
3415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
3515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
3652348eb8SGreg Roach     *
3752348eb8SGreg Roach     * @return void
38101af0b4SGreg Roach     */
399b802b22SGreg Roach    public function testNoSpouseFamiliesMale(): void
40c1010edaSGreg Roach    {
410ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
420ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
430ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
440ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
45101af0b4SGreg Roach
460ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
470ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
48101af0b4SGreg Roach
4973d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
50101af0b4SGreg Roach
51342dcecdSGreg 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
5752348eb8SGreg Roach     *
5852348eb8SGreg Roach     * @return void
5973d4df56SGreg Roach     */
609b802b22SGreg Roach    public function testNoSpouseFamiliesFemale(): void
61c1010edaSGreg Roach    {
620ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
630ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
640ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
650ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
6600225b98SGreg Roach
670ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
680ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
6900225b98SGreg Roach
7000225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
7100225b98SGreg Roach
72342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
7300225b98SGreg Roach    }
7400225b98SGreg Roach
7500225b98SGreg Roach    /**
7615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
7715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
7852348eb8SGreg Roach     *
7952348eb8SGreg Roach     * @return void
8000225b98SGreg Roach     */
819b802b22SGreg Roach    public function testNoFamilyFactsMale(): void
82c1010edaSGreg Roach    {
830ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
840ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
850ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
8673d4df56SGreg Roach
870ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
880ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
890ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
900ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
9173d4df56SGreg Roach
920ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
9373d4df56SGreg Roach
9473d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
950ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
9673d4df56SGreg Roach
97342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
9873d4df56SGreg Roach    }
9973d4df56SGreg Roach
10073d4df56SGreg Roach    /**
10115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
10215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
10352348eb8SGreg Roach     *
10452348eb8SGreg Roach     * @return void
10573d4df56SGreg Roach     */
1069b802b22SGreg Roach    public function testNoFamilyFactsFemale(): void
107c1010edaSGreg Roach    {
1080ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
1090ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
1100ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
111e76c0cf0SGreg Roach
1120ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1130ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
1140ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
1150ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
116e76c0cf0SGreg Roach
1170ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
118e76c0cf0SGreg Roach
119e76c0cf0SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
1200ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
121e76c0cf0SGreg Roach
122342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
123e76c0cf0SGreg Roach    }
124e76c0cf0SGreg Roach
125e76c0cf0SGreg Roach    /**
12615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
12715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
12852348eb8SGreg Roach     *
12952348eb8SGreg Roach     * @return void
130e76c0cf0SGreg Roach     */
1319b802b22SGreg Roach    public function testSpouseDeadMale(): void
132c1010edaSGreg Roach    {
1330ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
1342a6fda60SGreg Roach
1350ecdbde6SGreg Roach        $spouse = $this->createMock(Individual::class);
1360ecdbde6SGreg Roach        $spouse->method('getDeathDate')->willReturn(new Date('1820'));
137e76c0cf0SGreg Roach
1380ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
1390ecdbde6SGreg Roach        $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date(''));
1400ecdbde6SGreg Roach        $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
1410ecdbde6SGreg Roach        $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection());
1420ecdbde6SGreg Roach        $family->expects($this->at(3))->method('spouse')->willReturn($spouse);
143e76c0cf0SGreg Roach
1440ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1450ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
1460ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
147e76c0cf0SGreg Roach
1480ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
149e76c0cf0SGreg Roach
150e76c0cf0SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
1510ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
152e76c0cf0SGreg Roach
153342dcecdSGreg Roach        $this->assertSame('Gift', $column->generate($individual, $individual));
154e76c0cf0SGreg Roach    }
155e76c0cf0SGreg Roach
156e76c0cf0SGreg Roach    /**
15715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
15815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
15952348eb8SGreg Roach     *
16052348eb8SGreg Roach     * @return void
161e76c0cf0SGreg Roach     */
1629b802b22SGreg Roach    public function testSpouseDeadFemale(): void
163c1010edaSGreg Roach    {
1640ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
1652a6fda60SGreg Roach
1660ecdbde6SGreg Roach        $spouse = $this->createMock(Individual::class);
1670ecdbde6SGreg Roach        $spouse->method('getDeathDate')->willReturn(new Date('1820'));
168e76c0cf0SGreg Roach
1690ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
1700ecdbde6SGreg Roach        $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date(''));
1710ecdbde6SGreg Roach        $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
1720ecdbde6SGreg Roach        $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection());
1730ecdbde6SGreg Roach        $family->expects($this->at(3))->method('spouse')->willReturn($spouse);
17473d4df56SGreg Roach
1750ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1760ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
1770ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
17873d4df56SGreg Roach
1790ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
18073d4df56SGreg Roach
18173d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
1820ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
18373d4df56SGreg Roach
184342dcecdSGreg Roach        $this->assertSame('Gift', $column->generate($individual, $individual));
18500225b98SGreg Roach    }
18600225b98SGreg Roach
18700225b98SGreg Roach    /**
18815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
18915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
19052348eb8SGreg Roach     *
19152348eb8SGreg Roach     * @return void
19200225b98SGreg Roach     */
1939b802b22SGreg Roach    public function testNoFamilyUnmarriedMale(): void
194c1010edaSGreg Roach    {
1950ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
1960ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
1970ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
19800225b98SGreg Roach
1990ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
2000ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
2010ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
2020ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
20300225b98SGreg Roach
2040ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
2050ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
20600225b98SGreg Roach
20700225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
20800225b98SGreg Roach
209342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
21073d4df56SGreg Roach    }
21173d4df56SGreg Roach
21273d4df56SGreg Roach    /**
21315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
21415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
21552348eb8SGreg Roach     *
21652348eb8SGreg Roach     * @return void
21773d4df56SGreg Roach     */
2189b802b22SGreg Roach    public function testNoFamilyUnmarriedFemale(): void
219c1010edaSGreg Roach    {
2200ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
2210ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
2220ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
22300225b98SGreg Roach
2240ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
2250ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
2260ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
2270ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800'));
22800225b98SGreg Roach
2290ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
2300ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
23100225b98SGreg Roach
23200225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
23300225b98SGreg Roach
234342dcecdSGreg Roach        $this->assertSame('Ugift', $column->generate($individual, $individual));
23500225b98SGreg Roach    }
23600225b98SGreg Roach
23700225b98SGreg Roach    /**
23815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
23915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
24052348eb8SGreg Roach     *
24152348eb8SGreg Roach     * @return void
24200225b98SGreg Roach     */
2439b802b22SGreg Roach    public function testChildMale(): void
244c1010edaSGreg Roach    {
2450ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
2460ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
2470ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
24800225b98SGreg Roach
2490ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
2500ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
2510ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
2520ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
25300225b98SGreg Roach
2540ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
2550ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
25600225b98SGreg Roach
25700225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
25800225b98SGreg Roach
259342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
26000225b98SGreg Roach    }
26100225b98SGreg Roach
26200225b98SGreg Roach    /**
26315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
26415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
26552348eb8SGreg Roach     *
26652348eb8SGreg Roach     * @return void
26700225b98SGreg Roach     */
2689b802b22SGreg Roach    public function testChildFemale(): void
269c1010edaSGreg Roach    {
2700ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
2710ecdbde6SGreg Roach        $family->method('getMarriageDate')->willReturn(new Date(''));
2720ecdbde6SGreg Roach        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
27300225b98SGreg Roach
2740ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
2750ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
2760ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
2770ecdbde6SGreg Roach        $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820'));
27800225b98SGreg Roach
2790ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
2800ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
28100225b98SGreg Roach
28200225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
28300225b98SGreg Roach
284342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
28500225b98SGreg Roach    }
28600225b98SGreg Roach
28700225b98SGreg Roach    /**
28815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
28915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
29052348eb8SGreg Roach     *
29152348eb8SGreg Roach     * @return void
29200225b98SGreg Roach     */
2939b802b22SGreg Roach    public function testDivorcedMale(): void
294c1010edaSGreg Roach    {
2950ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
29673d4df56SGreg Roach
2970ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
2980ecdbde6SGreg Roach        $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date(''));
2990ecdbde6SGreg Roach        $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
3000ecdbde6SGreg Roach        $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact]));
30173d4df56SGreg Roach
3020ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
3030ecdbde6SGreg Roach        $individual->method('sex')->willReturn('M');
3040ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
30500225b98SGreg Roach
3060ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
30700225b98SGreg Roach
30800225b98SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
3090ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
31000225b98SGreg Roach
311342dcecdSGreg Roach        $this->assertSame('Skilt', $column->generate($individual, $individual));
31200225b98SGreg Roach    }
31300225b98SGreg Roach
31400225b98SGreg Roach    /**
31515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
31615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
31752348eb8SGreg Roach     *
31852348eb8SGreg Roach     * @return void
31900225b98SGreg Roach     */
3209b802b22SGreg Roach    public function testDivorcedFemale(): void
321c1010edaSGreg Roach    {
3220ecdbde6SGreg Roach        $fact = $this->createMock(Fact::class);
32300225b98SGreg Roach
3240ecdbde6SGreg Roach        $family = $this->createMock(Family::class);
3250ecdbde6SGreg Roach        $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date(''));
3260ecdbde6SGreg Roach        $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
3270ecdbde6SGreg Roach        $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact]));
32800225b98SGreg Roach
3290ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
3300ecdbde6SGreg Roach        $individual->method('sex')->willReturn('F');
3310ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
33273d4df56SGreg Roach
3330ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
33473d4df56SGreg Roach
33573d4df56SGreg Roach        $column = new CensusColumnConditionDanish($census, '', '');
3360ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('30 JUN 1830');
33773d4df56SGreg Roach
338342dcecdSGreg Roach        $this->assertSame('Skilt', $column->generate($individual, $individual));
339101af0b4SGreg Roach    }
340101af0b4SGreg Roach}
341