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#[CoversClass(CensusColumnChildrenBornAlive::class)] 30*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 313cfcc809SGreg Roachclass CensusColumnChildrenBornAliveTest extends TestCase 32c1010edaSGreg Roach{ 339b802b22SGreg Roach public function testMale(): void 34c1010edaSGreg Roach { 35cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 360ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 37ff7d8543SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([])); 3844f3c149SGreg Roach 39cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 4044f3c149SGreg Roach 4144f3c149SGreg Roach $column = new CensusColumnChildrenBornAlive($census, '', ''); 4244f3c149SGreg Roach 435e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 4444f3c149SGreg Roach } 4544f3c149SGreg Roach 469b802b22SGreg Roach public function testCountChildren(): void 47c1010edaSGreg Roach { 4844f3c149SGreg Roach // Stillborn 49cd94ca66SGreg Roach $child1 = $this->createMock(Individual::class); 500ecdbde6SGreg Roach $child1->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 510ecdbde6SGreg Roach $child1->method('getDeathDate')->willReturn(new Date('01 FEB 1904')); 5244f3c149SGreg Roach 5344f3c149SGreg Roach // Died after census 54cd94ca66SGreg Roach $child2 = $this->createMock(Individual::class); 550ecdbde6SGreg Roach $child2->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 560ecdbde6SGreg Roach $child2->method('getDeathDate')->willReturn(new Date('20 DEC 1912')); 5744f3c149SGreg Roach 5844f3c149SGreg Roach // Died before census 59cd94ca66SGreg Roach $child3 = $this->createMock(Individual::class); 600ecdbde6SGreg Roach $child3->method('getBirthDate')->willReturn(new Date('02 FEB 1904')); 610ecdbde6SGreg Roach $child3->method('getDeathDate')->willReturn(new Date('20 DEC 1910')); 6244f3c149SGreg Roach 6344f3c149SGreg Roach // Still living 64cd94ca66SGreg Roach $child4 = $this->createMock(Individual::class); 650ecdbde6SGreg Roach $child4->method('getBirthDate')->willReturn(new Date('01 FEB 1904')); 660ecdbde6SGreg Roach $child4->method('getDeathDate')->willReturn(new Date('')); 6744f3c149SGreg Roach 68cd94ca66SGreg Roach $family = $this->createMock(Family::class); 690ecdbde6SGreg Roach $family->method('children')->willReturn(new Collection([ 70c1010edaSGreg Roach $child1, 71c1010edaSGreg Roach $child2, 72c1010edaSGreg Roach $child3, 73c1010edaSGreg Roach $child4, 74315b4874SGreg Roach ])); 7544f3c149SGreg Roach 76cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 770ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 780ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 7944f3c149SGreg Roach 80cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 810ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 MAR 1911'); 8244f3c149SGreg Roach 8344f3c149SGreg Roach $column = new CensusColumnChildrenBornAlive($census, '', ''); 8444f3c149SGreg Roach 855e933c21SGreg Roach self::assertSame('3', $column->generate($individual, $individual)); 8644f3c149SGreg Roach } 8744f3c149SGreg Roach} 88