144f3c149SGreg Roach<?php 23976b470SGreg Roach 344f3c149SGreg Roach/** 444f3c149SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 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; 27*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 2844f3c149SGreg Roach 29*202c018bSGreg Roach 30*202c018bSGreg Roach#[CoversClass(CensusColumnChildrenBornAlive::class)] 31*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 323cfcc809SGreg Roachclass CensusColumnChildrenBornAliveTest extends TestCase 33c1010edaSGreg Roach{ 349b802b22SGreg Roach public function testMale(): void 35c1010edaSGreg Roach { 36cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 370ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 38ff7d8543SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([])); 3944f3c149SGreg Roach 40cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 4144f3c149SGreg Roach 4244f3c149SGreg Roach $column = new CensusColumnChildrenBornAlive($census, '', ''); 4344f3c149SGreg Roach 445e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 4544f3c149SGreg Roach } 4644f3c149SGreg Roach 479b802b22SGreg Roach public function testCountChildren(): void 48c1010edaSGreg Roach { 4944f3c149SGreg Roach // Stillborn 50cd94ca66SGreg Roach $child1 = $this->createMock(Individual::class); 510ecdbde6SGreg Roach $child1->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 520ecdbde6SGreg Roach $child1->method('getDeathDate')->willReturn(new Date('01 FEB 1904')); 5344f3c149SGreg Roach 5444f3c149SGreg Roach // Died after census 55cd94ca66SGreg Roach $child2 = $this->createMock(Individual::class); 560ecdbde6SGreg Roach $child2->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 570ecdbde6SGreg Roach $child2->method('getDeathDate')->willReturn(new Date('20 DEC 1912')); 5844f3c149SGreg Roach 5944f3c149SGreg Roach // Died before census 60cd94ca66SGreg Roach $child3 = $this->createMock(Individual::class); 610ecdbde6SGreg Roach $child3->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 620ecdbde6SGreg Roach $child3->method('getDeathDate')->willReturn(new Date('20 DEC 1910')); 6344f3c149SGreg Roach 6444f3c149SGreg Roach // Still living 65cd94ca66SGreg Roach $child4 = $this->createMock(Individual::class); 660ecdbde6SGreg Roach $child4->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 670ecdbde6SGreg Roach $child4->method('getDeathDate')->willReturn(new Date('')); 6844f3c149SGreg Roach 69cd94ca66SGreg Roach $family = $this->createMock(Family::class); 700ecdbde6SGreg Roach $family->method('children')->willReturn(new Collection([ 71c1010edaSGreg Roach $child1, 72c1010edaSGreg Roach $child2, 73c1010edaSGreg Roach $child3, 74c1010edaSGreg Roach $child4, 75315b4874SGreg Roach ])); 7644f3c149SGreg Roach 77cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 780ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 790ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 8044f3c149SGreg Roach 81cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 820ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 MAR 1911'); 8344f3c149SGreg Roach 8444f3c149SGreg Roach $column = new CensusColumnChildrenBornAlive($census, '', ''); 8544f3c149SGreg Roach 865e933c21SGreg Roach self::assertSame('3', $column->generate($individual, $individual)); 8744f3c149SGreg Roach } 8844f3c149SGreg Roach} 89