. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Mockery; /** * Test harness for the class CensusColumnAgeFemale5Years */ class CensusColumnAgeFemale5YearsTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMale() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnAgeFemale5Years($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testFemale() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnAgeFemale5Years($census, '', ''); $this->assertSame('30', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testUnknownSex() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('U'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnAgeFemale5Years($census, '', ''); $this->assertSame('30', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testLessThanOneYear() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1800'); $column = new CensusColumnAgeFemale5Years($census, '', ''); $this->assertSame('0', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testLessThanFifteenYears() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1814'); $column = new CensusColumnAgeFemale5Years($census, '', ''); $this->assertSame('14', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeFemale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testRoundedDownToFiveYears() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('01 JAN 1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1844'); $column = new CensusColumnAgeFemale5Years($census, '', ''); $this->assertSame('40', $column->generate($individual, $individual)); } }