. */ 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 CensusColumnConditionDanish */ class CensusColumnConditionDanishTest extends TestCase { /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testNoSpouseFamiliesMale(): void { $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('spouseFamilies')->willReturn(new Collection()); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnConditionDanish($census, '', ''); self::assertSame('Ugift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testNoSpouseFamiliesFemale(): void { $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('F'); $individual->method('spouseFamilies')->willReturn(new Collection()); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnConditionDanish($census, '', ''); self::assertSame('Ugift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testNoFamilyFactsMale(): void { $family = self::createMock(Family::class); $family->method('getMarriageDate')->willReturn(new Date('')); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); $individual->method('sex')->willReturn('M'); $census = self::createMock(CensusInterface::class); $column = new CensusColumnConditionDanish($census, '', ''); $census->method('censusDate')->willReturn('30 JUN 1830'); self::assertSame('Ugift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testNoFamilyFactsFemale(): void { $family = self::createMock(Family::class); $family->method('getMarriageDate')->willReturn(new Date('')); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); $individual->method('sex')->willReturn('F'); $census = self::createMock(CensusInterface::class); $column = new CensusColumnConditionDanish($census, '', ''); $census->method('censusDate')->willReturn('30 JUN 1830'); self::assertSame('Ugift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testSpouseDeadMale(): void { $fact = self::createMock(Fact::class); $spouse = self::createMock(Individual::class); $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = self::createMock(Family::class); $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); $family->expects(self::at(3))->method('spouse')->willReturn($spouse); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $column = new CensusColumnConditionDanish($census, '', ''); $census->method('censusDate')->willReturn('30 JUN 1830'); self::assertSame('Gift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testSpouseDeadFemale(): void { $fact = self::createMock(Fact::class); $spouse = self::createMock(Individual::class); $spouse->method('getDeathDate')->willReturn(new Date('1820')); $family = self::createMock(Family::class); $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection()); $family->expects(self::at(3))->method('spouse')->willReturn($spouse); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('F'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $column = new CensusColumnConditionDanish($census, '', ''); $census->method('censusDate')->willReturn('30 JUN 1830'); self::assertSame('Gift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testNoFamilyUnmarriedMale(): void { $family = self::createMock(Family::class); $family->method('getMarriageDate')->willReturn(new Date('')); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnConditionDanish($census, '', ''); self::assertSame('Ugift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testNoFamilyUnmarriedFemale(): void { $family = self::createMock(Family::class); $family->method('getMarriageDate')->willReturn(new Date('')); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('F'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1800')); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnConditionDanish($census, '', ''); self::assertSame('Ugift', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testChildMale(): void { $family = self::createMock(Family::class); $family->method('getMarriageDate')->willReturn(new Date('')); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnConditionDanish($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testChildFemale(): void { $family = self::createMock(Family::class); $family->method('getMarriageDate')->willReturn(new Date('')); $family->method('facts')->with(['MARR'])->willReturn(new Collection()); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('F'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $individual->method('getEstimatedBirthDate')->willReturn(new Date('1820')); $census = self::createMock(CensusInterface::class); $census->method('censusDate')->willReturn('30 JUN 1830'); $column = new CensusColumnConditionDanish($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testDivorcedMale(): void { $fact = self::createMock(Fact::class); $family = self::createMock(Family::class); $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('M'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $column = new CensusColumnConditionDanish($census, '', ''); $census->method('censusDate')->willReturn('30 JUN 1830'); self::assertSame('Skilt', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition * * @return void */ public function testDivorcedFemale(): void { $fact = self::createMock(Fact::class); $family = self::createMock(Family::class); $family->expects(self::at(0))->method('getMarriageDate')->willReturn(new Date('')); $family->expects(self::at(1))->method('facts')->with(['MARR'])->willReturn(new Collection([$fact])); $family->expects(self::at(2))->method('facts')->with(['DIV'])->willReturn(new Collection([$fact])); $individual = self::createMock(Individual::class); $individual->method('sex')->willReturn('F'); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = self::createMock(CensusInterface::class); $column = new CensusColumnConditionDanish($census, '', ''); $census->method('censusDate')->willReturn('30 JUN 1830'); self::assertSame('Skilt', $column->generate($individual, $individual)); } }