. */ 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 */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ 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 */ 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 */ public function testUndatedMarriage() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('getDate')->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 */ public function testMarriageAfterCensus() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('getDate')->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 */ public function testMarriageBeforeCensus() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('getDate')->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)); } }