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