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