. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Place; /** * Test harness for the class CensusColumnMotherForeign */ class CensusColumnMotherForeignTest extends \Fisharebest\Webtrees\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\CensusColumnMotherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testSameCountry(): void { $mother = $this->createMock(Individual::class); $mother->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England')); $family = $this->createMock(Family::class); $family->method('wife')->willReturn($mother); $individual = $this->createMock(Individual::class); $individual->method('primaryChildFamily')->willReturn($family); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnMotherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testDifferentCountry(): void { $mother = $this->createMock(Individual::class); $mother->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England')); $family = $this->createMock(Family::class); $family->method('wife')->willReturn($mother); $individual = $this->createMock(Individual::class); $individual->method('primaryChildFamily')->willReturn($family); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('Ireland'); $column = new CensusColumnMotherForeign($census, '', ''); $this->assertSame('Y', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceNoParent(): void { $family = $this->createMock(Family::class); $family->method('wife')->willReturn(null); $individual = $this->createMock(Individual::class); $individual->method('primaryChildFamily')->willReturn($family); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnMotherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceNoParentFamily(): void { $individual = $this->createMock(Individual::class); $individual->method('primaryChildFamily')->willReturn(null); $census = $this->createMock(CensusInterface::class); $census->method('censusPlace')->willReturn('England'); $column = new CensusColumnMotherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }