. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Individual; use Mockery; /** * Test harness for the class CensusColumnAgeMarried */ class CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testAgeMarried() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859')); $family = Mockery::mock(Family::class); $family->shouldReceive('facts')->with(['MARR'], true)->andReturn([$fact]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('19', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoBirthDate() { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoMarriage() { $family = Mockery::mock(Family::class); $family->shouldReceive('facts')->with(['MARR'])->andReturn([]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoSpouseFamily() { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }