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