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