144f3c149SGreg Roach<?php 2*3976b470SGreg Roach 344f3c149SGreg Roach/** 444f3c149SGreg Roach * webtrees: online genealogy 58fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 644f3c149SGreg Roach * This program is free software: you can redistribute it and/or modify 744f3c149SGreg Roach * it under the terms of the GNU General Public License as published by 844f3c149SGreg Roach * the Free Software Foundation, either version 3 of the License, or 944f3c149SGreg Roach * (at your option) any later version. 1044f3c149SGreg Roach * This program is distributed in the hope that it will be useful, 1144f3c149SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1244f3c149SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1344f3c149SGreg Roach * GNU General Public License for more details. 1444f3c149SGreg Roach * You should have received a copy of the GNU General Public License 1544f3c149SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1644f3c149SGreg Roach */ 17e7f56f2aSGreg Roachdeclare(strict_types=1); 18e7f56f2aSGreg Roach 1944f3c149SGreg Roachnamespace Fisharebest\Webtrees\Census; 2044f3c149SGreg Roach 2144f3c149SGreg Roachuse Fisharebest\Webtrees\Date; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2439ca88baSGreg Roachuse Illuminate\Support\Collection; 2544f3c149SGreg Roach 2644f3c149SGreg Roach/** 2744f3c149SGreg Roach * Test harness for the class CensusColumnChildrenLiving 2844f3c149SGreg Roach */ 2984e2cf4eSGreg Roachclass CensusColumnChildrenLivingTest extends \Fisharebest\Webtrees\TestCase 30c1010edaSGreg Roach{ 3144f3c149SGreg Roach /** 3215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenLiving 3315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3452348eb8SGreg Roach * 3552348eb8SGreg Roach * @return void 3644f3c149SGreg Roach */ 379b802b22SGreg Roach public function testMale(): void 38c1010edaSGreg Roach { 390ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 400ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 4144f3c149SGreg Roach 420ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 4344f3c149SGreg Roach 4444f3c149SGreg Roach $column = new CensusColumnChildrenLiving($census, '', ''); 4544f3c149SGreg Roach 46342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 4744f3c149SGreg Roach } 4844f3c149SGreg Roach 4944f3c149SGreg Roach /** 5015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenLiving 5115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 5252348eb8SGreg Roach * 5352348eb8SGreg Roach * @return void 5444f3c149SGreg Roach */ 559b802b22SGreg Roach public function testCountChildren(): void 56c1010edaSGreg Roach { 5744f3c149SGreg Roach // Stillborn 580ecdbde6SGreg Roach $child1 = $this->createMock(Individual::class); 590ecdbde6SGreg Roach $child1->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 600ecdbde6SGreg Roach $child1->method('getDeathDate')->willReturn(new Date('01 FEB 1904')); 6144f3c149SGreg Roach 6244f3c149SGreg Roach // Died after census 630ecdbde6SGreg Roach $child2 = $this->createMock(Individual::class); 640ecdbde6SGreg Roach $child2->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 650ecdbde6SGreg Roach $child2->method('getDeathDate')->willReturn(new Date('20 DEC 1912')); 6644f3c149SGreg Roach 6744f3c149SGreg Roach // Died before census 680ecdbde6SGreg Roach $child3 = $this->createMock(Individual::class); 690ecdbde6SGreg Roach $child3->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 700ecdbde6SGreg Roach $child3->method('getDeathDate')->willReturn(new Date('20 DEC 1910')); 7144f3c149SGreg Roach 7244f3c149SGreg Roach // Still living 730ecdbde6SGreg Roach $child4 = $this->createMock(Individual::class); 740ecdbde6SGreg Roach $child4->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 750ecdbde6SGreg Roach $child4->method('getDeathDate')->willReturn(new Date('')); 7644f3c149SGreg Roach 770ecdbde6SGreg Roach $family = $this->createMock(Family::class); 780ecdbde6SGreg Roach $family->method('children')->willReturn(new Collection([ 79c1010edaSGreg Roach $child1, 80c1010edaSGreg Roach $child2, 81c1010edaSGreg Roach $child3, 82c1010edaSGreg Roach $child4, 83315b4874SGreg Roach ])); 8444f3c149SGreg Roach 850ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 860ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 870ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 8844f3c149SGreg Roach 890ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 900ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 MAR 1911'); 9144f3c149SGreg Roach 9244f3c149SGreg Roach $column = new CensusColumnChildrenLiving($census, '', ''); 9344f3c149SGreg Roach 94342dcecdSGreg Roach $this->assertSame('2', $column->generate($individual, $individual)); 9544f3c149SGreg Roach } 9644f3c149SGreg Roach} 97