. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Place; use Mockery; /** * Test harness for the class CensusColumnFatherBirthPlaceSimple */ class CensusColumnFatherBirthPlaceSimpleTest 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 { $placeParts = explode(', ', $place); $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place'); $placeMock->shouldReceive('getGedcomName')->andReturn($place); $placeMock->shouldReceive('lastPart')->andReturn(end($placeParts)); return $placeMock; } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherBirthPlaceSimple * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testKnownStateAndTown() { $father = Mockery::mock('Fisharebest\Webtrees\Individual'); $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Miami, Florida, United States')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getHusband')->andReturn($father); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('United States'); $column = new CensusColumnFatherBirthPlaceSimple($census, '', ''); $this->assertSame('Florida', $column->generate($individual, $individual)); } }