. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Place; use Fisharebest\Webtrees\TestCase; /** * Test harness for the class CensusColumnBirthPlace */ class CensusColumnBirthPlaceTest extends TestCase { /** * Get place mock. * * @param string $place Gedcom Place * * @return Place */ private function getPlaceMock($place): Place { $placeMock = $this->createMock(Place::class); $placeMock->method('gedcomName')->willReturn($place); return $placeMock; } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceCountry(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Westminster, London, England')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('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(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('England')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('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(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Paris, France')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); $this->assertSame('Paris, France', $column->generate($individual, $individual)); } }