. */ 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 Fisharebest\Webtrees\TestCase; use Illuminate\Support\Collection; /** * Test harness for the class CensusColumnMarriedWithinYear */ class CensusColumnMarriedWithinYearTest extends TestCase { /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedWithinYear(): void { $fact = self::createMock(Fact::class); $fact->method('date')->willReturn(new Date('01 DEC 1859')); $family = self::createMock(Family::class); $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnMarriedWithinYear($census, '', ''); self::assertSame('Y', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedOverYearBeforeTheCensus(): void { $fact = self::createMock(Fact::class); $fact->method('date')->willReturn(new Date('01 JAN 1859')); $family = self::createMock(Family::class); $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnMarriedWithinYear($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMarriedAfterTheCensus(): void { $fact = self::createMock(Fact::class); $fact->method('date')->willReturn(new Date('02 JUN 1860')); $family = self::createMock(Family::class); $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnMarriedWithinYear($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoMarriage(): void { $family = self::createMock(Family::class); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnMarriedWithinYear($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testNoSpouseFamily(): void { $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnMarriedWithinYear($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } }