. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Individual; use Mockery; /** * Test harness for the class CensusColumnAgeFemale */ class CensusColumnAgeFemaleTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMale(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('sex')->andReturn('M'); $census = Mockery::mock(CensusInterface::class); $column = new CensusColumnAgeFemale($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testFemale(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('sex')->andReturn('F'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('30 JUN 1832'); $column = new CensusColumnAgeFemale($census, '', ''); $this->assertSame('32', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testUnknownSex(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('sex')->andReturn('U'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('30 JUN 1832'); $column = new CensusColumnAgeFemale($census, '', ''); $this->assertSame('32', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testLessThanOneYear(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('sex')->andReturn('F'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn('30 JUN 1800'); $column = new CensusColumnAgeFemale($census, '', ''); $this->assertSame('0', $column->generate($individual, $individual)); } }