. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Individual; use Illuminate\Support\Collection; 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(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('sex')->andReturn('M'); $census = Mockery::mock(CensusInterface::class); $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(): void { // Stillborn $child1 = Mockery::mock(Individual::class); $child1->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); $child1->shouldReceive('getDeathDate')->andReturn(new Date('01 FEB 1904')); // Died after census $child2 = Mockery::mock(Individual::class); $child2->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); $child2->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1912')); // Died before census $child3 = Mockery::mock(Individual::class); $child3->shouldReceive('getBirthDate')->andReturn(new Date('02 FEB 1904')); $child3->shouldReceive('getDeathDate')->andReturn(new Date('20 DEC 1910')); // Still living $child4 = Mockery::mock(Individual::class); $child4->shouldReceive('getBirthDate')->andReturn(new Date('01 FEB 1904')); $child4->shouldReceive('getDeathDate')->andReturn(new Date('')); $family = Mockery::mock(Family::class); $family->shouldReceive('children')->andReturn([ $child1, $child2, $child3, $child4, ]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('sex')->andReturn('F'); $individual->shouldReceive('spouseFamilies')->andReturn(new Collection([$family])); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('30 MAR 1911'); $column = new CensusColumnChildrenLiving($census, '', ''); $this->assertSame('2', $column->generate($individual, $individual)); } }