1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2019 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16declare(strict_types=1); 17 18namespace Fisharebest\Webtrees\Census; 19 20use Fisharebest\Webtrees\Date; 21use Fisharebest\Webtrees\Individual; 22use Mockery; 23 24/** 25 * Test harness for the class CensusColumnChildrenDied 26 */ 27class CensusColumnChildrenDiedTest extends \Fisharebest\Webtrees\TestCase 28{ 29 /** 30 * Delete mock objects 31 * 32 * @return void 33 */ 34 public function tearDown() 35 { 36 Mockery::close(); 37 } 38 39 /** 40 * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenDied 41 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 42 * 43 * @return void 44 */ 45 public function testMale(): void 46 { 47 $individual = Mockery::mock(Individual::class); 48 $individual->shouldReceive('getSex')->andReturn('M'); 49 50 $census = Mockery::mock(CensusInterface::class); 51 52 $column = new CensusColumnChildrenDied($census, '', ''); 53 54 $this->assertSame('', $column->generate($individual, $individual)); 55 } 56 57 /** 58 * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenDied 59 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 60 * 61 * @return void 62 */ 63 public function testCountChildren(): void 64 { 65 // Stillborn 66 $child1 = Mockery::mock(Individual::class); 67 $child1->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); 68 $child1->shouldReceive('getDeathDate')->andReturn(new Date('01 FEB 1904')); 69 70 // Died after census 71 $child2 = Mockery::mock(Individual::class); 72 $child2->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); 73 $child2->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1912')); 74 75 // Died before census 76 $child3 = Mockery::mock(Individual::class); 77 $child3->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); 78 $child3->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1910')); 79 80 // Still living 81 $child4 = Mockery::mock(Individual::class); 82 $child4->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); 83 $child4->shouldReceive('getDeathDate')->andReturn(new Date('')); 84 85 $family = Mockery::mock(Family::class); 86 $family->shouldReceive('getChildren')->andReturn([ 87 $child1, 88 $child2, 89 $child3, 90 $child4, 91 ]); 92 93 $individual = Mockery::mock(Individual::class); 94 $individual->shouldReceive('getSex')->andReturn('F'); 95 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 96 97 $census = Mockery::mock(CensusInterface::class); 98 $census->shouldReceive('censusDate')->andReturn('30 MAR 1911'); 99 100 $column = new CensusColumnChildrenDied($census, '', ''); 101 102 $this->assertSame('1', $column->generate($individual, $individual)); 103 } 104} 105