. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Place; use Mockery; /** * Test harness for the class CensusColumnBirthPlace */ class CensusColumnBirthPlaceTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * Get place mock. * * @param string $place Gedcom Place * * @return Place */ private function getPlaceMock($place): Place { $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place'); $placeMock->shouldReceive('getGedcomName')->andReturn($place); return $placeMock; } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceCountry() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Westminster, London, England')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); $this->assertSame('Westminster, London', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceAndCountry() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('England')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testDifferentCountry() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Paris, France')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); $this->assertSame('Paris, France', $column->generate($individual, $individual)); } }