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