. */ 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 CensusColumnMonthIfMarriedWithinYear */ class CensusColumnMonthIfMarriedWithinYearTest extends \PHPUnit_Framework_TestCase { /** * Delete mock objects */ public function tearDown() { Mockery::close(); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testMarriedWithinYear() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859')); $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR')->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 CensusColumnMonthIfMarriedWithinYear($census, '', ''); $this->assertSame('Dec', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNotMarriedWithinYear() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859')); $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR')->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 CensusColumnMonthIfMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoMarriage() { $family = Mockery::mock(Family::class); $family->shouldReceive('getFacts')->with('MARR')->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 CensusColumnMonthIfMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @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 CensusColumnMonthIfMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual)); } }