. */ 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(CensusColumnBirthPlaceSimple::class)] #[CoversClass(AbstractCensusColumn::class)] class CensusColumnBirthPlaceSimpleTest extends TestCase { private function getPlaceMock(string $place): Place { $placeMock = $this->createMock(Place::class); $placeMock->method('gedcomName')->willReturn($place); return $placeMock; } public function testForeignCountry(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Westminster, London, England')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('United States'); $column = new CensusColumnBirthPlaceSimple($census, '', ''); self::assertSame('England', $column->generate($individual, $individual)); } public function testJustCountry(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('United States')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('United States'); $column = new CensusColumnBirthPlaceSimple($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } public function testKnownState(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Maryland, United States')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('United States'); $column = new CensusColumnBirthPlaceSimple($census, '', ''); self::assertSame('Maryland', $column->generate($individual, $individual)); } public function testKnownStateAndTown(): void { $individual = $this->createMock(Individual::class); $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Miami, Florida, United States')); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('United States'); $column = new CensusColumnBirthPlaceSimple($census, '', ''); self::assertSame('Florida', $column->generate($individual, $individual)); } }