. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Mockery; /** * Test harness for the class CensusColumnYearsMarried */ class CensusColumnYearsMarriedTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoSpouseFamily() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoMarriage() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testUndatedMarriage() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('date')->andReturn(new Date('')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriageAfterCensus() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('date')->andReturn(new Date('1861')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriageBeforeCensus() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('date')->andReturn(new Date('OCT 1851')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('8', $column->generate($individual, $individual)); } }