. */ 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 \PHPUnit_Framework_TestCase { /** * Delete mock objects */ public function tearDown() { Mockery::close(); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testAgeMarried() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getFacts')->with('MARR', true)->andReturn(array($fact)); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame(19, $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoBirthDate() { } /** * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoMarriage() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getFacts')->with('MARR')->andReturn(array()); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoSpouseFamily() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840')); $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual)); } }