. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Place; use Mockery; /** * Test harness for the class CensusColumnMotherForeign */ class CensusColumnMotherForeignTest 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('\Fisharebest\Webtrees\Place'); $placeMock->shouldReceive('getGedcomName')->andReturn($place); return $placeMock; } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * * @return void */ public function testSameCountry() { $mother = Mockery::mock('Fisharebest\Webtrees\Individual'); $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getWife')->andReturn($mother); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('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() { $mother = Mockery::mock('Fisharebest\Webtrees\Individual'); $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getWife')->andReturn($mother); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('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() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getWife')->andReturn(null); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('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() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusPlace')->andReturn('England'); $column = new CensusColumnMotherForeign($census, '', ''); $this->assertSame('', $column->generate($individual, $individual)); } }