. */ 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 CensusColumnMarriedWithinYear */ class CensusColumnMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedWithinYear(): void { $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 CensusColumnMarriedWithinYear($census, '', ''); $this->assertSame('Y', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedOverYearBeforeTheCensus(): void { $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 CensusColumnMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedAfterTheCensus(): void { $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 CensusColumnMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoMarriage(): void { $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 CensusColumnMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoSpouseFamily(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnMarriedWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }