. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Localization\Translator; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\I18N; use Fisharebest\Webtrees\Individual; use Mockery; /** * Test harness for the class CensusColumnYearsMarried */ class CensusColumnYearsMarriedTest extends \PHPUnit_Framework_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(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoMarriage() { $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testUndatedMarriage() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('getDate')->andReturn(new Date('')); $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testMarriageAfterCensus() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('getDate')->andReturn(new Date('1861')); $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnYearsMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testMarriageBeforeCensus() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('getDate')->andReturn(new Date('OCT 1851')); $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); $this->assertSame('8', $column->generate($individual)); } }