. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Place; use Fisharebest\Webtrees\TestCase; use PHPUnit\Framework\Attributes\CoversClass; #[CoversClass(CensusColumnBirthPlace::class)] #[CoversClass(AbstractCensusColumn::class)] class CensusColumnBirthPlaceTest extends TestCase { private function getPlaceMock(string $place): Place { $placeMock = $this->createMock(Place::class); $placeMock->method('gedcomName')->willReturn($place); return $placeMock; } 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, '', ''); self::assertSame('Westminster, London', $column->generate($individual, $individual)); } 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, '', ''); self::assertSame('', $column->generate($individual, $individual)); } 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, '', ''); self::assertSame('Paris, France', $column->generate($individual, $individual)); } }