. */ 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(string $place): Place { $placeMock = self::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 = self::createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Westminster, London, England')); $census = self::createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); self::assertSame('Westminster, London', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceAndCountry(): void { $individual = self::createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('England')); $census = self::createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testDifferentCountry(): void { $individual = self::createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Paris, France')); $census = self::createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnBirthPlace($census, '', ''); self::assertSame('Paris, France', $column->generate($individual, $individual)); } }