144f3c149SGreg Roach<?php 244f3c149SGreg Roach 344f3c149SGreg Roach/** 444f3c149SGreg Roach * webtrees: online genealogy 544f3c149SGreg Roach * Copyright (C) 2015 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 1544f3c149SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 1644f3c149SGreg Roach */ 1744f3c149SGreg Roach 1844f3c149SGreg Roachnamespace Fisharebest\Webtrees\Census; 1944f3c149SGreg Roach 2044f3c149SGreg Roachuse Fisharebest\Webtrees\Date; 21*88cd6753SGreg Roachuse Fisharebest\Webtrees\Family; 2244f3c149SGreg Roachuse Fisharebest\Webtrees\Individual; 2344f3c149SGreg Roachuse Mockery; 2444f3c149SGreg Roach 2544f3c149SGreg Roach/** 2644f3c149SGreg Roach * Test harness for the class CensusColumnChildrenLiving 2744f3c149SGreg Roach */ 2844f3c149SGreg Roachclass CensusColumnChildrenLivingTest extends \PHPUnit_Framework_TestCase { 2944f3c149SGreg Roach /** 3044f3c149SGreg Roach * Delete mock objects 3144f3c149SGreg Roach */ 3244f3c149SGreg Roach public function tearDown() { 3344f3c149SGreg Roach Mockery::close(); 3444f3c149SGreg Roach } 3544f3c149SGreg Roach 3644f3c149SGreg Roach /** 3744f3c149SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnChildrenLiving 3844f3c149SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 3944f3c149SGreg Roach */ 4044f3c149SGreg Roach public function testMale() { 4144f3c149SGreg Roach $individual = Mockery::mock(Individual::class); 4244f3c149SGreg Roach $individual->shouldReceive('getSex')->andReturn('M'); 4344f3c149SGreg Roach 4444f3c149SGreg Roach $census = Mockery::mock(CensusInterface::class); 4544f3c149SGreg Roach 4644f3c149SGreg Roach $column = new CensusColumnChildrenLiving($census, '', ''); 4744f3c149SGreg Roach 4844f3c149SGreg Roach $this->assertSame('', $column->generate($individual)); 4944f3c149SGreg Roach } 5044f3c149SGreg Roach 5144f3c149SGreg Roach /** 5244f3c149SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnChildrenLiving 5344f3c149SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 5444f3c149SGreg Roach */ 5544f3c149SGreg Roach public function testCountChildren() { 5644f3c149SGreg Roach // Stillborn 5744f3c149SGreg Roach $child1 = Mockery::mock(Individual::class); 5844f3c149SGreg Roach $child1->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); 5944f3c149SGreg Roach $child1->shouldReceive('getDeathDate')->andReturn(new Date('01 FEB 1904')); 6044f3c149SGreg Roach 6144f3c149SGreg Roach // Died after census 6244f3c149SGreg Roach $child2 = Mockery::mock(Individual::class); 6344f3c149SGreg Roach $child2->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); 6444f3c149SGreg Roach $child2->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1912')); 6544f3c149SGreg Roach 6644f3c149SGreg Roach // Died before census 6744f3c149SGreg Roach $child3 = Mockery::mock(Individual::class); 6844f3c149SGreg Roach $child3->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); 6944f3c149SGreg Roach $child3->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1910')); 7044f3c149SGreg Roach 7144f3c149SGreg Roach // Still living 7244f3c149SGreg Roach $child4 = Mockery::mock(Individual::class); 7344f3c149SGreg Roach $child4->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); 7444f3c149SGreg Roach $child4->shouldReceive('getDeathDate')->andReturn(new Date('')); 7544f3c149SGreg Roach 7644f3c149SGreg Roach $family = Mockery::mock(Family::class); 7744f3c149SGreg Roach $family->shouldReceive('getChildren')->andReturn([$child1, $child2, $child3, $child4]); 7844f3c149SGreg Roach 7944f3c149SGreg Roach $individual = Mockery::mock(Individual::class); 8044f3c149SGreg Roach $individual->shouldReceive('getSex')->andReturn('F'); 8144f3c149SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 8244f3c149SGreg Roach 8344f3c149SGreg Roach $census = Mockery::mock(CensusInterface::class); 8444f3c149SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 MAR 1911'); 8544f3c149SGreg Roach 8644f3c149SGreg Roach $column = new CensusColumnChildrenLiving($census, '', ''); 8744f3c149SGreg Roach 8844f3c149SGreg Roach $this->assertSame('2', $column->generate($individual)); 8944f3c149SGreg Roach } 9044f3c149SGreg Roach} 91