144f3c149SGreg Roach<?php 23976b470SGreg Roach 344f3c149SGreg Roach/** 444f3c149SGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 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 1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 1644f3c149SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2044f3c149SGreg Roachnamespace Fisharebest\Webtrees\Census; 2144f3c149SGreg Roach 2244f3c149SGreg Roachuse Fisharebest\Webtrees\Date; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 24ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 253cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 2639ca88baSGreg Roachuse Illuminate\Support\Collection; 2744f3c149SGreg Roach 2844f3c149SGreg Roach/** 2944f3c149SGreg Roach * Test harness for the class CensusColumnChildrenBornAlive 3044f3c149SGreg Roach */ 313cfcc809SGreg Roachclass CensusColumnChildrenBornAliveTest extends TestCase 32c1010edaSGreg Roach{ 3344f3c149SGreg Roach /** 3415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenBornAlive 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3652348eb8SGreg Roach * 3752348eb8SGreg Roach * @return void 3844f3c149SGreg Roach */ 399b802b22SGreg Roach public function testMale(): void 40c1010edaSGreg Roach { 41*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 420ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 43ff7d8543SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([])); 4444f3c149SGreg Roach 45*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 4644f3c149SGreg Roach 4744f3c149SGreg Roach $column = new CensusColumnChildrenBornAlive($census, '', ''); 4844f3c149SGreg Roach 495e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 5044f3c149SGreg Roach } 5144f3c149SGreg Roach 5244f3c149SGreg Roach /** 5315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenBornAlive 5415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 5552348eb8SGreg Roach * 5652348eb8SGreg Roach * @return void 5744f3c149SGreg Roach */ 589b802b22SGreg Roach public function testCountChildren(): void 59c1010edaSGreg Roach { 6044f3c149SGreg Roach // Stillborn 61*cd94ca66SGreg Roach $child1 = $this->createMock(Individual::class); 620ecdbde6SGreg Roach $child1->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 630ecdbde6SGreg Roach $child1->method('getDeathDate')->willReturn(new Date('01 FEB 1904')); 6444f3c149SGreg Roach 6544f3c149SGreg Roach // Died after census 66*cd94ca66SGreg Roach $child2 = $this->createMock(Individual::class); 670ecdbde6SGreg Roach $child2->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 680ecdbde6SGreg Roach $child2->method('getDeathDate')->willReturn(new Date('20 DEC 1912')); 6944f3c149SGreg Roach 7044f3c149SGreg Roach // Died before census 71*cd94ca66SGreg Roach $child3 = $this->createMock(Individual::class); 720ecdbde6SGreg Roach $child3->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 730ecdbde6SGreg Roach $child3->method('getDeathDate')->willReturn(new Date('20 DEC 1910')); 7444f3c149SGreg Roach 7544f3c149SGreg Roach // Still living 76*cd94ca66SGreg Roach $child4 = $this->createMock(Individual::class); 770ecdbde6SGreg Roach $child4->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 780ecdbde6SGreg Roach $child4->method('getDeathDate')->willReturn(new Date('')); 7944f3c149SGreg Roach 80*cd94ca66SGreg Roach $family = $this->createMock(Family::class); 810ecdbde6SGreg Roach $family->method('children')->willReturn(new Collection([ 82c1010edaSGreg Roach $child1, 83c1010edaSGreg Roach $child2, 84c1010edaSGreg Roach $child3, 85c1010edaSGreg Roach $child4, 86315b4874SGreg Roach ])); 8744f3c149SGreg Roach 88*cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 890ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 900ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 9144f3c149SGreg Roach 92*cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 930ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 MAR 1911'); 9444f3c149SGreg Roach 9544f3c149SGreg Roach $column = new CensusColumnChildrenBornAlive($census, '', ''); 9644f3c149SGreg Roach 975e933c21SGreg Roach self::assertSame('3', $column->generate($individual, $individual)); 9844f3c149SGreg Roach } 9944f3c149SGreg Roach} 100