. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Mockery; /** * Test harness for the class CensusColumnChildrenLiving */ class CensusColumnChildrenLivingTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenLiving * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMale() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnChildrenLiving($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnChildrenLiving * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testCountChildren() { // Stillborn $child1 = Mockery::mock('Fisharebest\Webtrees\Individual'); $child1->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); $child1->shouldReceive('getDeathDate')->andReturn(new Date('01 FEB 1904')); // Died after census $child2 = Mockery::mock('Fisharebest\Webtrees\Individual'); $child2->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); $child2->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1912')); // Died before census $child3 = Mockery::mock('Fisharebest\Webtrees\Individual'); $child3->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); $child3->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1910')); // Still living $child4 = Mockery::mock('Fisharebest\Webtrees\Individual'); $child4->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); $child4->shouldReceive('getDeathDate')->andReturn(new Date('')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getChildren')->andReturn([ $child1, $child2, $child3, $child4, ]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 MAR 1911'); $column = new CensusColumnChildrenLiving($census, '', ''); $this->assertSame('2', $column->generate($individual, $individual)); } }