. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; use Illuminate\Support\Collection; use Mockery; /** * Test harness for the class CensusColumnSurnameGivenNameInitial */ class CensusColumnSurnameGivenNameInitialTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testOneGivenName(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getAllNames')->andReturn([ [ 'givn' => 'Joe', 'surname' => 'Sixpack', ], ]); $individual->shouldReceive('spouseFamilies')->andReturn(new Collection()); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn(''); $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); $this->assertSame('Sixpack, Joe', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testMultipleGivenNames(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getAllNames')->andReturn([ [ 'givn' => 'Joe Fred', 'surname' => 'Sixpack', ], ]); $individual->shouldReceive('spouseFamilies')->andReturn(new Collection()); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusDate')->andReturn(''); $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); $this->assertSame('Sixpack, Joe F', $column->generate($individual, $individual)); } }