. */ declare(strict_types=1); 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 CensusColumnMonthIfMarriedWithinYear */ class CensusColumnMonthIfMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedWithinYear() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859')); $family = Mockery::mock(Family::class); $family->shouldReceive('facts')->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, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedOverYearBeforeTheCensus() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('date')->andReturn(new Date('01 JAN 1859')); $family = Mockery::mock(Family::class); $family->shouldReceive('facts')->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, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedAfterTheCensus() { $fact = Mockery::mock(Fact::class); $fact->shouldReceive('date')->andReturn(new Date('02 JUN 1860')); $family = Mockery::mock(Family::class); $family->shouldReceive('facts')->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, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoMarriage() { $family = Mockery::mock(Family::class); $family->shouldReceive('facts')->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, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ 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, $individual)); } }