. */ 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; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(CensusColumnYearsMarried::class)] #[CoversClass(AbstractCensusColumn::class)] class CensusColumnYearsMarriedTest extends TestCase { public function testNoSpouseFamily(): void { $individual = $this->createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } public function testNoMarriage(): void { $family = $this->createMock(Family::class); $family->method('facts')->with(['MARR'], true)->willReturn(new Collection()); $individual = $this->createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } public function testUndatedMarriage(): void { $fact = $this->createMock(Fact::class); $fact->method('date')->willReturn(new Date('')); $family = $this->createMock(Family::class); $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); $individual = $this->createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } public function testMarriageAfterCensus(): void { $fact = $this->createMock(Fact::class); $fact->method('date')->willReturn(new Date('1861')); $family = $this->createMock(Family::class); $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); $individual = $this->createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } public function testMarriageBeforeCensus(): void { $fact = $this->createMock(Fact::class); $fact->method('date')->willReturn(new Date('OCT 1851')); $family = $this->createMock(Family::class); $family->method('facts')->with(['MARR'], true)->willReturn(new Collection([$fact])); $individual = $this->createMock(Individual::class); $individual->method('spouseFamilies')->willReturn(new Collection([$family])); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn('01 JUN 1860'); $column = new CensusColumnYearsMarried($census, '', ''); self::assertSame('8', $column->generate($individual, $individual)); } }