. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\Place; use Mockery; /** * Test harness for the class CensusColumnFatherForeign */ class CensusColumnFatherForeignTest extends \Fisharebest\Webtrees\TestCase { /** * Delete mock objects * * @return void */ public function tearDown() { Mockery::close(); } /** * Get place mock. * * @param string $place Gedcom Place * * @return Place */ private function getPlaceMock($place): Place { $placeMock = Mockery::mock(Place::class); $placeMock->shouldReceive('gedcomName')->andReturn($place); return $placeMock; } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testSameCountry(): void { $father = Mockery::mock(Individual::class); $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); $family = Mockery::mock(Family::class); $family->shouldReceive('husband')->andReturn($father); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('primaryChildFamily')->andReturn($family); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnFatherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testDifferentCountry(): void { $father = Mockery::mock(Individual::class); $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); $family = Mockery::mock(Family::class); $family->shouldReceive('husband')->andReturn($father); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('primaryChildFamily')->andReturn($family); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusPlace')->andReturn('Ireland'); $column = new CensusColumnFatherForeign($census, '', ''); $this->assertSame('Y', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceNoParent(): void { $family = Mockery::mock(Family::class); $family->shouldReceive('husband')->andReturn(null); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('primaryChildFamily')->andReturn($family); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnFatherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testPlaceNoParentFamily(): void { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('primaryChildFamily')->andReturn(null); $census = Mockery::mock(CensusInterface::class); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnFatherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }