100225b98SGreg Roach<?php 200225b98SGreg Roach/** 300225b98SGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 500225b98SGreg Roach * This program is free software: you can redistribute it and/or modify 600225b98SGreg Roach * it under the terms of the GNU General Public License as published by 700225b98SGreg Roach * the Free Software Foundation, either version 3 of the License, or 800225b98SGreg Roach * (at your option) any later version. 900225b98SGreg Roach * This program is distributed in the hope that it will be useful, 1000225b98SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1100225b98SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1200225b98SGreg Roach * GNU General Public License for more details. 1300225b98SGreg Roach * You should have received a copy of the GNU General Public License 1400225b98SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1500225b98SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 1800225b98SGreg Roachnamespace Fisharebest\Webtrees\Census; 1900225b98SGreg Roach 2000225b98SGreg Roachuse Fisharebest\Webtrees\Date; 21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2439ca88baSGreg Roachuse Illuminate\Support\Collection; 2500225b98SGreg Roach 2600225b98SGreg Roach/** 2700225b98SGreg Roach * Test harness for the class CensusColumnConditionFrenchGarcon 2800225b98SGreg Roach */ 2984e2cf4eSGreg Roachclass CensusColumnConditionFrenchGarconTest extends \Fisharebest\Webtrees\TestCase 30c1010edaSGreg Roach{ 3100225b98SGreg Roach /** 3215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 3315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 3452348eb8SGreg Roach * 3552348eb8SGreg Roach * @return void 3600225b98SGreg Roach */ 379b802b22SGreg Roach public function testNoSpouseFamiliesMale(): void 38c1010edaSGreg Roach { 39*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 40*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 41*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 42*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 4300225b98SGreg Roach 44*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 45*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 4600225b98SGreg Roach 4700225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 4800225b98SGreg Roach 49342dcecdSGreg Roach $this->assertSame('1', $column->generate($individual, $individual)); 5000225b98SGreg Roach } 5100225b98SGreg Roach 5200225b98SGreg Roach /** 5315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 5415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 5552348eb8SGreg Roach * 5652348eb8SGreg Roach * @return void 5700225b98SGreg Roach */ 589b802b22SGreg Roach public function testNoSpouseFamiliesFemale(): void 59c1010edaSGreg Roach { 60*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 61*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 62*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 63*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 6400225b98SGreg Roach 65*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 66*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 6700225b98SGreg Roach 6800225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 6900225b98SGreg Roach 70342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 7100225b98SGreg Roach } 7200225b98SGreg Roach 7300225b98SGreg Roach /** 7415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 7515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 7652348eb8SGreg Roach * 7752348eb8SGreg Roach * @return void 7800225b98SGreg Roach */ 799b802b22SGreg Roach public function testNoFamilyFactsMale(): void 80c1010edaSGreg Roach { 81*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 82*0ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 83*0ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 8400225b98SGreg Roach 85*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 86*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 87*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 88*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 8900225b98SGreg Roach 90*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 9100225b98SGreg Roach 9200225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 93*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 9400225b98SGreg Roach 95342dcecdSGreg Roach $this->assertSame('1', $column->generate($individual, $individual)); 9600225b98SGreg Roach } 9700225b98SGreg Roach 9800225b98SGreg Roach /** 9915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 10015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 10152348eb8SGreg Roach * 10252348eb8SGreg Roach * @return void 10300225b98SGreg Roach */ 1049b802b22SGreg Roach public function testNoFamilyFactsFemale(): void 105c1010edaSGreg Roach { 106*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 107*0ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 108*0ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 109e76c0cf0SGreg Roach 110*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 111*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 112*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 113*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 114e76c0cf0SGreg Roach 115*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 116e76c0cf0SGreg Roach 117e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 118*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 119e76c0cf0SGreg Roach 120342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 121e76c0cf0SGreg Roach } 122e76c0cf0SGreg Roach 123e76c0cf0SGreg Roach /** 12415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 12515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 12652348eb8SGreg Roach * 12752348eb8SGreg Roach * @return void 128e76c0cf0SGreg Roach */ 1299b802b22SGreg Roach public function testSpouseDeadMale(): void 130c1010edaSGreg Roach { 131*0ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 1322a6fda60SGreg Roach 133*0ecdbde6SGreg Roach $spouse = $this->createMock(Individual::class); 134*0ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 135e76c0cf0SGreg Roach 136*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 137*0ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 138*0ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 139*0ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 140*0ecdbde6SGreg Roach $family->expects($this->at(3))->method('spouse')->willReturn($spouse); 141e76c0cf0SGreg Roach 142*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 143*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 144*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 145e76c0cf0SGreg Roach 146*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 147e76c0cf0SGreg Roach 148e76c0cf0SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 149*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 150e76c0cf0SGreg Roach 151342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 152e76c0cf0SGreg Roach } 153e76c0cf0SGreg Roach 154e76c0cf0SGreg Roach /** 15515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 15615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 15752348eb8SGreg Roach * 15852348eb8SGreg Roach * @return void 159e76c0cf0SGreg Roach */ 1609b802b22SGreg Roach public function testSpouseDeadFemale(): void 161c1010edaSGreg Roach { 162*0ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 1632a6fda60SGreg Roach 164*0ecdbde6SGreg Roach $spouse = $this->createMock(Individual::class); 165*0ecdbde6SGreg Roach $spouse->method('getDeathDate')->willReturn(new Date('1820')); 166e76c0cf0SGreg Roach 167*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 168*0ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 169*0ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 170*0ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); 171*0ecdbde6SGreg Roach $family->expects($this->at(3))->method('spouse')->willReturn($spouse); 17200225b98SGreg Roach 173*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 174*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 175*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 17600225b98SGreg Roach 177*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 17800225b98SGreg Roach 17900225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 180*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 18100225b98SGreg Roach 182342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 18300225b98SGreg Roach } 18400225b98SGreg Roach 18500225b98SGreg Roach /** 18615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 18715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 18852348eb8SGreg Roach * 18952348eb8SGreg Roach * @return void 19000225b98SGreg Roach */ 1919b802b22SGreg Roach public function testNoFamilyUnmarriedMale(): void 192c1010edaSGreg Roach { 193*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 194*0ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 195*0ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 19600225b98SGreg Roach 197*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 198*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 199*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 200*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 20100225b98SGreg Roach 202*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 203*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 20400225b98SGreg Roach 20500225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 20600225b98SGreg Roach 207342dcecdSGreg Roach $this->assertSame('1', $column->generate($individual, $individual)); 20800225b98SGreg Roach } 20900225b98SGreg Roach 21000225b98SGreg Roach /** 21115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 21215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 21352348eb8SGreg Roach * 21452348eb8SGreg Roach * @return void 21500225b98SGreg Roach */ 2169b802b22SGreg Roach public function testNoFamilyUnmarriedFemale(): void 217c1010edaSGreg Roach { 218*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 219*0ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 220*0ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 22100225b98SGreg Roach 222*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 223*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 224*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 225*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); 22600225b98SGreg Roach 227*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 228*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 22900225b98SGreg Roach 23000225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 23100225b98SGreg Roach 232342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 23300225b98SGreg Roach } 23400225b98SGreg Roach 23500225b98SGreg Roach /** 23615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 23715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 23852348eb8SGreg Roach * 23952348eb8SGreg Roach * @return void 24000225b98SGreg Roach */ 2419b802b22SGreg Roach public function testChildMale(): void 242c1010edaSGreg Roach { 243*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 244*0ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 245*0ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 24600225b98SGreg Roach 247*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 248*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 249*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 250*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 25100225b98SGreg Roach 252*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 253*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 25400225b98SGreg Roach 25500225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 25600225b98SGreg Roach 257342dcecdSGreg Roach $this->assertSame('1', $column->generate($individual, $individual)); 25800225b98SGreg Roach } 25900225b98SGreg Roach 26000225b98SGreg Roach /** 26115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 26215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 26352348eb8SGreg Roach * 26452348eb8SGreg Roach * @return void 26500225b98SGreg Roach */ 2669b802b22SGreg Roach public function testChildFemale(): void 267c1010edaSGreg Roach { 268*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 269*0ecdbde6SGreg Roach $family->method('getMarriageDate')->willReturn(new Date('')); 270*0ecdbde6SGreg Roach $family->method('facts')->with(['MARR'])->willReturn(new Collection()); 27100225b98SGreg Roach 272*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 273*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 274*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 275*0ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); 27600225b98SGreg Roach 277*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 278*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 27900225b98SGreg Roach 28000225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 28100225b98SGreg Roach 282342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 28300225b98SGreg Roach } 28400225b98SGreg Roach 28500225b98SGreg Roach /** 28615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 28715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 28852348eb8SGreg Roach * 28952348eb8SGreg Roach * @return void 29000225b98SGreg Roach */ 2919b802b22SGreg Roach public function testDivorcedMale(): void 292c1010edaSGreg Roach { 293*0ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 29400225b98SGreg Roach 295*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 296*0ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 297*0ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 298*0ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 29900225b98SGreg Roach 300*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 301*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 302*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 30300225b98SGreg Roach 304*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 30500225b98SGreg Roach 30600225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 307*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 30800225b98SGreg Roach 309342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 31000225b98SGreg Roach } 31100225b98SGreg Roach 31200225b98SGreg Roach /** 31315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchGarcon 31415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 31552348eb8SGreg Roach * 31652348eb8SGreg Roach * @return void 31700225b98SGreg Roach */ 3189b802b22SGreg Roach public function testDivorcedFemale(): void 319c1010edaSGreg Roach { 320*0ecdbde6SGreg Roach $fact = $this->createMock(Fact::class); 32100225b98SGreg Roach 322*0ecdbde6SGreg Roach $family = $this->createMock(Family::class); 323*0ecdbde6SGreg Roach $family->expects($this->at(0))->method('getMarriageDate')->willReturn(new Date('')); 324*0ecdbde6SGreg Roach $family->expects($this->at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); 325*0ecdbde6SGreg Roach $family->expects($this->at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); 32600225b98SGreg Roach 327*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 328*0ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 329*0ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 33000225b98SGreg Roach 331*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 33200225b98SGreg Roach 33300225b98SGreg Roach $column = new CensusColumnConditionFrenchGarcon($census, '', ''); 334*0ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 33500225b98SGreg Roach 336342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 33700225b98SGreg Roach } 33800225b98SGreg Roach} 339