1db7d25eeSGreg Roach<?php 2*3976b470SGreg Roach 3db7d25eeSGreg Roach/** 4db7d25eeSGreg Roach * webtrees: online genealogy 58fcd0d32SGreg Roach * Copyright (C) 2019 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 15db7d25eeSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16db7d25eeSGreg Roach */ 17e7f56f2aSGreg Roachdeclare(strict_types=1); 18e7f56f2aSGreg Roach 19db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census; 20db7d25eeSGreg Roach 21db7d25eeSGreg Roachuse Fisharebest\Webtrees\Date; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 23db7d25eeSGreg Roach 24db7d25eeSGreg Roach/** 25db7d25eeSGreg Roach * Test harness for the class CensusColumnAgeFemale5Years 26db7d25eeSGreg Roach */ 2784e2cf4eSGreg Roachclass CensusColumnAgeFemale5YearsTest extends \Fisharebest\Webtrees\TestCase 28c1010edaSGreg Roach{ 29db7d25eeSGreg Roach /** 3015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years 3115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3252348eb8SGreg Roach * 3352348eb8SGreg Roach * @return void 34db7d25eeSGreg Roach */ 359b802b22SGreg Roach public function testMale(): void 36c1010edaSGreg Roach { 370ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 380ecdbde6SGreg Roach $individual->method('sex')->willReturn('M'); 39db7d25eeSGreg Roach 400ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 41db7d25eeSGreg Roach 42ef21b467SGreg Roach $column = new CensusColumnAgeFemale5Years($census, '', ''); 43db7d25eeSGreg Roach 44342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 45db7d25eeSGreg Roach } 46db7d25eeSGreg Roach 47db7d25eeSGreg Roach /** 4815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years 4915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 5052348eb8SGreg Roach * 5152348eb8SGreg Roach * @return void 52db7d25eeSGreg Roach */ 539b802b22SGreg Roach public function testFemale(): void 54c1010edaSGreg Roach { 550ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 560ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 570ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 58db7d25eeSGreg Roach 590ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 600ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 61db7d25eeSGreg Roach 62ef21b467SGreg Roach $column = new CensusColumnAgeFemale5Years($census, '', ''); 63db7d25eeSGreg Roach 64342dcecdSGreg Roach $this->assertSame('30', $column->generate($individual, $individual)); 65db7d25eeSGreg Roach } 66db7d25eeSGreg Roach 67db7d25eeSGreg Roach /** 6815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years 6915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 7052348eb8SGreg Roach * 7152348eb8SGreg Roach * @return void 72db7d25eeSGreg Roach */ 739b802b22SGreg Roach public function testUnknownSex(): void 74c1010edaSGreg Roach { 750ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 760ecdbde6SGreg Roach $individual->method('sex')->willReturn('U'); 770ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 78db7d25eeSGreg Roach 790ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 800ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1830'); 81db7d25eeSGreg Roach 82ef21b467SGreg Roach $column = new CensusColumnAgeFemale5Years($census, '', ''); 83db7d25eeSGreg Roach 84342dcecdSGreg Roach $this->assertSame('30', $column->generate($individual, $individual)); 85db7d25eeSGreg Roach } 86db7d25eeSGreg Roach 87db7d25eeSGreg Roach /** 8815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years 8915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 9052348eb8SGreg Roach * 9152348eb8SGreg Roach * @return void 92db7d25eeSGreg Roach */ 939b802b22SGreg Roach public function testLessThanOneYear(): void 94c1010edaSGreg Roach { 950ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 960ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 970ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 98db7d25eeSGreg Roach 990ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1000ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1800'); 101db7d25eeSGreg Roach 102ef21b467SGreg Roach $column = new CensusColumnAgeFemale5Years($census, '', ''); 103db7d25eeSGreg Roach 104342dcecdSGreg Roach $this->assertSame('0', $column->generate($individual, $individual)); 105db7d25eeSGreg Roach } 106db7d25eeSGreg Roach 107db7d25eeSGreg Roach /** 10815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years 10915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 11052348eb8SGreg Roach * 11152348eb8SGreg Roach * @return void 112db7d25eeSGreg Roach */ 1139b802b22SGreg Roach public function testLessThanFifteenYears(): void 114c1010edaSGreg Roach { 1150ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1160ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1170ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 118db7d25eeSGreg Roach 1190ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1200ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1814'); 121db7d25eeSGreg Roach 122ef21b467SGreg Roach $column = new CensusColumnAgeFemale5Years($census, '', ''); 123db7d25eeSGreg Roach 124342dcecdSGreg Roach $this->assertSame('14', $column->generate($individual, $individual)); 125db7d25eeSGreg Roach } 126db7d25eeSGreg Roach 127db7d25eeSGreg Roach /** 12815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years 12915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 13052348eb8SGreg Roach * 13152348eb8SGreg Roach * @return void 132db7d25eeSGreg Roach */ 1339b802b22SGreg Roach public function testRoundedDownToFiveYears(): void 134c1010edaSGreg Roach { 1350ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1360ecdbde6SGreg Roach $individual->method('sex')->willReturn('F'); 1370ecdbde6SGreg Roach $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); 138db7d25eeSGreg Roach 1390ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1400ecdbde6SGreg Roach $census->method('censusDate')->willReturn('30 JUN 1844'); 141db7d25eeSGreg Roach 142ef21b467SGreg Roach $column = new CensusColumnAgeFemale5Years($census, '', ''); 143db7d25eeSGreg Roach 144342dcecdSGreg Roach $this->assertSame('40', $column->generate($individual, $individual)); 145db7d25eeSGreg Roach } 146db7d25eeSGreg Roach} 147