. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\TestCase; use Illuminate\Support\Collection; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(CensusColumnSurnameGivenNames::class)] #[CoversClass(AbstractCensusColumn::class)] class CensusColumnSurnameGivenNamesTest extends TestCase { public function testOneGivenName(): void { $individual = $this->createMock(Individual::class); $individual->method('getAllNames')->willReturn([ [ 'givn' => 'Joe', 'surname' => 'Sixpack', ], ]); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn(''); $column = new CensusColumnSurnameGivenNames($census, '', ''); self::assertSame('Sixpack, Joe', $column->generate($individual, $individual)); } public function testMultipleGivenNames(): void { $individual = $this->createMock(Individual::class); $individual->method('getAllNames')->willReturn([ [ 'givn' => 'Joe Fred', 'surname' => 'Sixpack', ], ]); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn(''); $column = new CensusColumnSurnameGivenNames($census, '', ''); self::assertSame('Sixpack, Joe Fred', $column->generate($individual, $individual)); } public function testNoName(): void { $individual = $this->createMock(Individual::class); $individual->method('getAllNames')->willReturn([ [ 'givn' => Individual::PRAENOMEN_NESCIO, 'surname' => Individual::NOMEN_NESCIO, ], ]); $individual->method('spouseFamilies')->willReturn(new Collection()); $census = $this->createMock(CensusInterface::class); $census->method('censusDate')->willReturn(''); $column = new CensusColumnSurnameGivenNames($census, '', ''); self::assertSame('…, …', $column->generate($individual, $individual)); } }