. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Individual; use Mockery; /** * Test harness for the class CensusColumnMonthIfBornWithinYear */ class CensusColumnMonthIfBornWithinYearTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testBornWithinYear(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); $this->assertSame('Jan', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testBornOverYearBeforeTheCensus(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testBornAfterTheCensus(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('02 JUN 1860')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoBirth(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getBirthDate')->andReturn(new Date('')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('01 JUN 1860'); $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }