. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Mockery; /** * Test harness for the class CensusColumnSurnameGivenNames */ class CensusColumnSurnameGivenNamesTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNames * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testOneGivenName() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getAllNames')->andReturn([ [ 'givn' => 'Joe', 'surname' => 'Sixpack', ], ]); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn(''); $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() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getAllNames')->andReturn([ [ 'givn' => 'Joe Fred', 'surname' => 'Sixpack', ], ]); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn(''); $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() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getAllNames')->andReturn([]); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn(''); $column = new CensusColumnSurnameGivenNames($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }