100225b98SGreg Roach<?php 23976b470SGreg Roach 300225b98SGreg Roach/** 400225b98SGreg Roach * webtrees: online genealogy 5*5e933c21SGreg Roach * Copyright (C) 2020 webtrees development team 600225b98SGreg Roach * This program is free software: you can redistribute it and/or modify 700225b98SGreg Roach * it under the terms of the GNU General Public License as published by 800225b98SGreg Roach * the Free Software Foundation, either version 3 of the License, or 900225b98SGreg Roach * (at your option) any later version. 1000225b98SGreg Roach * This program is distributed in the hope that it will be useful, 1100225b98SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1200225b98SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1300225b98SGreg Roach * GNU General Public License for more details. 1400225b98SGreg Roach * You should have received a copy of the GNU General Public License 1500225b98SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1600225b98SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2000225b98SGreg Roachnamespace Fisharebest\Webtrees\Census; 2100225b98SGreg Roach 2200225b98SGreg Roachuse Fisharebest\Webtrees\Date; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 25ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 263cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 2739ca88baSGreg Roachuse Illuminate\Support\Collection; 2800225b98SGreg Roach 2900225b98SGreg Roach/** 3000225b98SGreg Roach * Test harness for the class CensusColumnConditionFrenchGarcon 3100225b98SGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnConditionFrenchGarconTest extends TestCase 33c1010edaSGreg Roach{ 3400225b98SGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 3900225b98SGreg Roach */ 409b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 41c1010edaSGreg Roach { 42*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 430ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 440ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 450ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 4600225b98SGreg Roach 47*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 480ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4900225b98SGreg Roach 5000225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 5100225b98SGreg Roach 52*5e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 5300225b98SGreg Roach } 5400225b98SGreg Roach 5500225b98SGreg Roach /** 5615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 5715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5852348eb8SGreg Roach * 5952348eb8SGreg Roach * @return void 6000225b98SGreg Roach */ 619b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 62c1010edaSGreg Roach { 63*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 640ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 650ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 660ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 6700225b98SGreg Roach 68*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 690ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 7000225b98SGreg Roach 7100225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 7200225b98SGreg Roach 73*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 7400225b98SGreg Roach } 7500225b98SGreg Roach 7600225b98SGreg Roach /** 7715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 7815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7952348eb8SGreg Roach * 8052348eb8SGreg Roach * @return void 8100225b98SGreg Roach */ 829b802b22SGreg Roach public function testNoFamilyFactsMale(): void 83c1010edaSGreg Roach { 84*5e933c21SGreg Roach $family = self::createMock(Family::class); 850ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 860ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8700225b98SGreg Roach 88*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 890ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 900ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 910ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 9200225b98SGreg Roach 93*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 9400225b98SGreg Roach 9500225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 960ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9700225b98SGreg Roach 98*5e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 9900225b98SGreg Roach } 10000225b98SGreg Roach 10100225b98SGreg Roach /** 10215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 10315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10452348eb8SGreg Roach * 10552348eb8SGreg Roach * @return void 10600225b98SGreg Roach */ 1079b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 108c1010edaSGreg Roach { 109*5e933c21SGreg Roach $family = self::createMock(Family::class); 1100ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1110ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 112e76c0cf0SGreg Roach 113*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 1140ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 1150ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 1160ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 117e76c0cf0SGreg Roach 118*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 119e76c0cf0SGreg Roach 120e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 1210ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 122e76c0cf0SGreg Roach 123*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 124e76c0cf0SGreg Roach } 125e76c0cf0SGreg Roach 126e76c0cf0SGreg Roach /** 12715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 12815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12952348eb8SGreg Roach * 13052348eb8SGreg Roach * @return void 131e76c0cf0SGreg Roach */ 1329b802b22SGreg Roach public function testSpouseDeadMale(): void 133c1010edaSGreg Roach { 134*5e933c21SGreg Roach $fact = self::createMock(Fact::class); 1352a6fda60SGreg Roach 136*5e933c21SGreg Roach $spouse = self::createMock(Individual::class); 1370ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 138e76c0cf0SGreg Roach 139*5e933c21SGreg Roach $family = self::createMock(Family::class); 140*5e933c21SGreg Roach $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); 141*5e933c21SGreg Roach $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 142*5e933c21SGreg Roach $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 143*5e933c21SGreg Roach $family->expects(self::at(3))->method('spouse')->willReturn($spouse); 144e76c0cf0SGreg Roach 145*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 1460ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1470ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 148e76c0cf0SGreg Roach 149*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 150e76c0cf0SGreg Roach 151e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 1520ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 153e76c0cf0SGreg Roach 154*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 155e76c0cf0SGreg Roach } 156e76c0cf0SGreg Roach 157e76c0cf0SGreg Roach /** 15815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 15915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 16052348eb8SGreg Roach * 16152348eb8SGreg Roach * @return void 162e76c0cf0SGreg Roach */ 1639b802b22SGreg Roach public function testSpouseDeadFemale(): void 164c1010edaSGreg Roach { 165*5e933c21SGreg Roach $fact = self::createMock(Fact::class); 1662a6fda60SGreg Roach 167*5e933c21SGreg Roach $spouse = self::createMock(Individual::class); 1680ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 169e76c0cf0SGreg Roach 170*5e933c21SGreg Roach $family = self::createMock(Family::class); 171*5e933c21SGreg Roach $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); 172*5e933c21SGreg Roach $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 173*5e933c21SGreg Roach $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 174*5e933c21SGreg Roach $family->expects(self::at(3))->method('spouse')->willReturn($spouse); 17500225b98SGreg Roach 176*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 1770ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1780ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 17900225b98SGreg Roach 180*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 18100225b98SGreg Roach 18200225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 1830ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 18400225b98SGreg Roach 185*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 18600225b98SGreg Roach } 18700225b98SGreg Roach 18800225b98SGreg Roach /** 18915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 19015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 19152348eb8SGreg Roach * 19252348eb8SGreg Roach * @return void 19300225b98SGreg Roach */ 1949b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 195c1010edaSGreg Roach { 196*5e933c21SGreg Roach $family = self::createMock(Family::class); 1970ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 1980ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 19900225b98SGreg Roach 200*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 2010ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2020ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2030ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 20400225b98SGreg Roach 205*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2060ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 20700225b98SGreg Roach 20800225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 20900225b98SGreg Roach 210*5e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 21100225b98SGreg Roach } 21200225b98SGreg Roach 21300225b98SGreg Roach /** 21415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 21515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 21652348eb8SGreg Roach * 21752348eb8SGreg Roach * @return void 21800225b98SGreg Roach */ 2199b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 220c1010edaSGreg Roach { 221*5e933c21SGreg Roach $family = self::createMock(Family::class); 2220ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2230ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 22400225b98SGreg Roach 225*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 2260ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2270ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2280ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22900225b98SGreg Roach 230*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2310ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 23200225b98SGreg Roach 23300225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 23400225b98SGreg Roach 235*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 23600225b98SGreg Roach } 23700225b98SGreg Roach 23800225b98SGreg Roach /** 23915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 24015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 24152348eb8SGreg Roach * 24252348eb8SGreg Roach * @return void 24300225b98SGreg Roach */ 2449b802b22SGreg Roach public function testChildMale(): void 245c1010edaSGreg Roach { 246*5e933c21SGreg Roach $family = self::createMock(Family::class); 2470ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2480ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24900225b98SGreg Roach 250*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 2510ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 2520ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2530ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 25400225b98SGreg Roach 255*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2560ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 25700225b98SGreg Roach 25800225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 25900225b98SGreg Roach 260*5e933c21SGreg Roach self::assertSame('1', $column->generate($individual, $individual)); 26100225b98SGreg Roach } 26200225b98SGreg Roach 26300225b98SGreg Roach /** 26415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 26515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 26652348eb8SGreg Roach * 26752348eb8SGreg Roach * @return void 26800225b98SGreg Roach */ 2699b802b22SGreg Roach public function testChildFemale(): void 270c1010edaSGreg Roach { 271*5e933c21SGreg Roach $family = self::createMock(Family::class); 2720ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 2730ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 27400225b98SGreg Roach 275*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 2760ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 2770ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 2780ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27900225b98SGreg Roach 280*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 2810ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 28200225b98SGreg Roach 28300225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 28400225b98SGreg Roach 285*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 28600225b98SGreg Roach } 28700225b98SGreg Roach 28800225b98SGreg Roach /** 28915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 29015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 29152348eb8SGreg Roach * 29252348eb8SGreg Roach * @return void 29300225b98SGreg Roach */ 2949b802b22SGreg Roach public function testDivorcedMale(): void 295c1010edaSGreg Roach { 296*5e933c21SGreg Roach $fact = self::createMock(Fact::class); 29700225b98SGreg Roach 298*5e933c21SGreg Roach $family = self::createMock(Family::class); 299*5e933c21SGreg Roach $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); 300*5e933c21SGreg Roach $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 301*5e933c21SGreg Roach $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 30200225b98SGreg Roach 303*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 3040ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 3050ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 30600225b98SGreg Roach 307*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 30800225b98SGreg Roach 30900225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 3100ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 31100225b98SGreg Roach 312*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 31300225b98SGreg Roach } 31400225b98SGreg Roach 31500225b98SGreg Roach /** 31615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 31715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 31852348eb8SGreg Roach * 31952348eb8SGreg Roach * @return void 32000225b98SGreg Roach */ 3219b802b22SGreg Roach public function testDivorcedFemale(): void 322c1010edaSGreg Roach { 323*5e933c21SGreg Roach $fact = self::createMock(Fact::class); 32400225b98SGreg Roach 325*5e933c21SGreg Roach $family = self::createMock(Family::class); 326*5e933c21SGreg Roach $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); 327*5e933c21SGreg Roach $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 328*5e933c21SGreg Roach $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 32900225b98SGreg Roach 330*5e933c21SGreg Roach $individual = self::createMock(Individual::class); 3310ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 3320ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33300225b98SGreg Roach 334*5e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 33500225b98SGreg Roach 33600225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 3370ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33800225b98SGreg Roach 339*5e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 34000225b98SGreg Roach } 34100225b98SGreg Roach} 342