1db7d25eeSGreg Roach<?php 23976b470SGreg Roach 3db7d25eeSGreg Roach/** 4db7d25eeSGreg Roach * webtrees: online genealogy 5*89f7189bSGreg Roach * Copyright (C) 2021 webtrees development team 6db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify 7db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by 8db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9db7d25eeSGreg Roach * (at your option) any later version. 10db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful, 11db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13db7d25eeSGreg Roach * GNU General Public License for more details. 14db7d25eeSGreg Roach * You should have received a copy of the GNU General Public License 15*89f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>. 16db7d25eeSGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 20db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census; 21db7d25eeSGreg Roach 22db7d25eeSGreg Roachuse Fisharebest\Webtrees\Date; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 25db7d25eeSGreg Roach 26db7d25eeSGreg Roach/** 27db7d25eeSGreg Roach * Test harness for the class CensusColumnAgeMale5Years5Years 28db7d25eeSGreg Roach */ 293cfcc809SGreg Roachclass CensusColumnAgeMale5YearsTest extends TestCase 30c1010edaSGreg Roach{ 31db7d25eeSGreg Roach /** 3215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years 3315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3452348eb8SGreg Roach * 3552348eb8SGreg Roach * @return void 36db7d25eeSGreg Roach */ 379b802b22SGreg Roach public function testMale(): void 38c1010edaSGreg Roach { 395e933c21SGreg Roach $individual = self::createMock(Individual::class); 400ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 410ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 42db7d25eeSGreg Roach 435e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 440ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 45db7d25eeSGreg Roach 46ef21b467SGreg Roach $column = new CensusColumnAgeMale5Years($census, '', ''); 47db7d25eeSGreg Roach 485e933c21SGreg Roach self::assertSame('30', $column->generate($individual, $individual)); 49db7d25eeSGreg Roach } 50db7d25eeSGreg Roach 51db7d25eeSGreg Roach /** 5215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years 5315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 5452348eb8SGreg Roach * 5552348eb8SGreg Roach * @return void 56db7d25eeSGreg Roach */ 579b802b22SGreg Roach public function testFemale(): void 58c1010edaSGreg Roach { 595e933c21SGreg Roach $individual = self::createMock(Individual::class); 600ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 61db7d25eeSGreg Roach 625e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 63db7d25eeSGreg Roach 64ef21b467SGreg Roach $column = new CensusColumnAgeMale5Years($census, '', ''); 65db7d25eeSGreg Roach 665e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 67db7d25eeSGreg Roach } 68db7d25eeSGreg Roach 69db7d25eeSGreg Roach /** 7015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years 7115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 7252348eb8SGreg Roach * 7352348eb8SGreg Roach * @return void 74db7d25eeSGreg Roach */ 759b802b22SGreg Roach public function testUnknownSex(): void 76c1010edaSGreg Roach { 775e933c21SGreg Roach $individual = self::createMock(Individual::class); 780ecdbde6SGreg Roach $individual->method('sex')->willReturn('U'); 790ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 80db7d25eeSGreg Roach 815e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 820ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 83db7d25eeSGreg Roach 84ef21b467SGreg Roach $column = new CensusColumnAgeMale5Years($census, '', ''); 85db7d25eeSGreg Roach 865e933c21SGreg Roach self::assertSame('30', $column->generate($individual, $individual)); 87db7d25eeSGreg Roach } 88db7d25eeSGreg Roach 89db7d25eeSGreg Roach /** 9015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years 9115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 9252348eb8SGreg Roach * 9352348eb8SGreg Roach * @return void 94db7d25eeSGreg Roach */ 959b802b22SGreg Roach public function testLessThanOneYear(): void 96c1010edaSGreg Roach { 975e933c21SGreg Roach $individual = self::createMock(Individual::class); 980ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 990ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 100db7d25eeSGreg Roach 1015e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 1020ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1800'); 103db7d25eeSGreg Roach 104ef21b467SGreg Roach $column = new CensusColumnAgeMale5Years($census, '', ''); 105db7d25eeSGreg Roach 1065e933c21SGreg Roach self::assertSame('0', $column->generate($individual, $individual)); 107db7d25eeSGreg Roach } 108db7d25eeSGreg Roach 109db7d25eeSGreg Roach /** 11015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years 11115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 11252348eb8SGreg Roach * 11352348eb8SGreg Roach * @return void 114db7d25eeSGreg Roach */ 1159b802b22SGreg Roach public function testLessThanFifteenYears(): void 116c1010edaSGreg Roach { 1175e933c21SGreg Roach $individual = self::createMock(Individual::class); 1180ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1190ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 120db7d25eeSGreg Roach 1215e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 1220ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1814'); 123db7d25eeSGreg Roach 124ef21b467SGreg Roach $column = new CensusColumnAgeMale5Years($census, '', ''); 125db7d25eeSGreg Roach 1265e933c21SGreg Roach self::assertSame('14', $column->generate($individual, $individual)); 127db7d25eeSGreg Roach } 128db7d25eeSGreg Roach 129db7d25eeSGreg Roach /** 13015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years 13115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 13252348eb8SGreg Roach * 13352348eb8SGreg Roach * @return void 134db7d25eeSGreg Roach */ 1359b802b22SGreg Roach public function testRoundedDownToFiveYears(): void 136c1010edaSGreg Roach { 1375e933c21SGreg Roach $individual = self::createMock(Individual::class); 1380ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 1390ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 140db7d25eeSGreg Roach 1415e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 1420ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1844'); 143db7d25eeSGreg Roach 144ef21b467SGreg Roach $column = new CensusColumnAgeMale5Years($census, '', ''); 145db7d25eeSGreg Roach 1465e933c21SGreg Roach self::assertSame('40', $column->generate($individual, $individual)); 147db7d25eeSGreg Roach } 148db7d25eeSGreg Roach} 149