. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\TestCase; /** * Test harness for the class CensusColumnAgeMale5Years5Years */ class CensusColumnAgeMale5YearsTest extends TestCase { /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testMale(): void { $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnAgeMale5Years($census, '', ''); self::assertSame('30', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testFemale(): void { $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('F'); $census = $this->createMock(CensusInterface::class); $column = new CensusColumnAgeMale5Years($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testUnknownSex(): void { $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('U'); $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnAgeMale5Years($census, '', ''); self::assertSame('30', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testLessThanOneYear(): void { $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1800'); $column = new CensusColumnAgeMale5Years($census, '', ''); self::assertSame('0', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testLessThanFifteenYears(): void { $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1814'); $column = new CensusColumnAgeMale5Years($census, '', ''); self::assertSame('14', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMale5Years * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testRoundedDownToFiveYears(): void { $individual = $this->createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('getEstimatedBirthDate')->willReturn(new Date('01 JAN 1800')); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1844'); $column = new CensusColumnAgeMale5Years($census, '', ''); self::assertSame('40', $column->generate($individual, $individual)); } }