. */ 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 Illuminate\Support\Collection; /** * Test harness for the class CensusColumnAgeMarried */ class CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase { /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testAgeMarried(): void { $fact = $this->createMock(Fact::class); $fact->method('date')->willReturn(new Date('01 DEC 1859')); $family = $this->createMock(Family::class); $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); $individual = $this->createMock(Individual::class); $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840')); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('19', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoBirthDate(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthDate')->willReturn(new Date('')); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoMarriage(): void { $family = $this->createMock(Family::class); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = $this->createMock(Individual::class); $individual->method('getBirthDate')->willReturn(new Date('')); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoSpouseFamily(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthDate')->willReturn(new Date('15 MAR 1840')); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnAgeMarried($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }