.
*/
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 = $this->createMock(Individual::class);
$individual->method('getAllNames')->willReturn([
[
'givn' => 'Joe',
'surname' => 'Sixpack',
'full' => 'Joe Sixpack',
],
]);
$individual->method('spouseFamilies')->willReturn(new Collection());
$census = $this->createMock(CensusInterface::class);
$census->method('censusDate')->willReturn('');
$column = new CensusColumnSurnameGivenNames($census, '', '');
$this->assertSame('Sixpack, Joe', $column->generate($individual, $individual));
}
/**
* @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNames
* @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
*
* @return void
*/
public function testMultipleGivenNames(): void
{
$individual = $this->createMock(Individual::class);
$individual->method('getAllNames')->willReturn([
[
'givn' => 'Joe Fred',
'surname' => 'Sixpack',
'full' => 'Joe Fred Sixpack',
],
]);
$individual->method('spouseFamilies')->willReturn(new Collection());
$census = $this->createMock(CensusInterface::class);
$census->method('censusDate')->willReturn('');
$column = new CensusColumnSurnameGivenNames($census, '', '');
$this->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 = $this->createMock(Individual::class);
$individual->method('getAllNames')->willReturn([
[
'givn' => '@P.N.',
'surname' => '@N.N.',
'full' => '… …',
]
]);
$individual->method('spouseFamilies')->willReturn(new Collection());
$census = $this->createMock(CensusInterface::class);
$census->method('censusDate')->willReturn('');
$column = new CensusColumnSurnameGivenNames($census, '', '');
$this->assertSame('…, …', $column->generate($individual, $individual));
}
}