1a53db70dSGreg Roach<?php 2a53db70dSGreg Roach/** 3a53db70dSGreg Roach * webtrees: online genealogy 41062a142SGreg Roach * Copyright (C) 2018 webtrees development team 5a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify 6a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by 7a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or 8a53db70dSGreg Roach * (at your option) any later version. 9a53db70dSGreg Roach * This program is distributed in the hope that it will be useful, 10a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a53db70dSGreg Roach * GNU General Public License for more details. 13a53db70dSGreg Roach * You should have received a copy of the GNU General Public License 14a53db70dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15a53db70dSGreg Roach */ 16*e7f56f2aSGreg Roachdeclare(strict_types=1); 17*e7f56f2aSGreg Roach 18a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census; 19a53db70dSGreg Roach 2052348eb8SGreg Roachuse Fisharebest\Webtrees\Place; 21a53db70dSGreg Roachuse Mockery; 22a53db70dSGreg Roach 23a53db70dSGreg Roach/** 24a53db70dSGreg Roach * Test harness for the class CensusColumnFatherForeign 25a53db70dSGreg Roach */ 2684e2cf4eSGreg Roachclass CensusColumnFatherForeignTest extends \Fisharebest\Webtrees\TestCase 27c1010edaSGreg Roach{ 28a53db70dSGreg Roach /** 29a53db70dSGreg Roach * Delete mock objects 3052348eb8SGreg Roach * 3152348eb8SGreg Roach * @return void 32a53db70dSGreg Roach */ 33c1010edaSGreg Roach public function tearDown() 34c1010edaSGreg Roach { 35a53db70dSGreg Roach Mockery::close(); 36a53db70dSGreg Roach } 37a53db70dSGreg Roach 38a53db70dSGreg Roach /** 3916d0b7f7SRico Sonntag * Get place mock. 4016d0b7f7SRico Sonntag * 4116d0b7f7SRico Sonntag * @param string $place Gedcom Place 4216d0b7f7SRico Sonntag * 4352348eb8SGreg Roach * @return Place 4416d0b7f7SRico Sonntag */ 4552348eb8SGreg Roach private function getPlaceMock($place): Place 46c1010edaSGreg Roach { 4716d0b7f7SRico Sonntag $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place'); 4816d0b7f7SRico Sonntag $placeMock->shouldReceive('getGedcomName')->andReturn($place); 4916d0b7f7SRico Sonntag 5016d0b7f7SRico Sonntag return $placeMock; 5116d0b7f7SRico Sonntag } 5216d0b7f7SRico Sonntag 5316d0b7f7SRico Sonntag /** 5415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 5515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 5618d7a90dSGreg Roach * 5718d7a90dSGreg Roach * @return void 58a53db70dSGreg Roach */ 59c1010edaSGreg Roach public function testSameCountry() 60c1010edaSGreg Roach { 61c314ecc9SGreg Roach $father = Mockery::mock('Fisharebest\Webtrees\Individual'); 6216d0b7f7SRico Sonntag $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 63a53db70dSGreg Roach 64c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 65a53db70dSGreg Roach $family->shouldReceive('getHusband')->andReturn($father); 66a53db70dSGreg Roach 67c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 68a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 69a53db70dSGreg Roach 70c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 71a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 72a53db70dSGreg Roach 73a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 74a53db70dSGreg Roach 75342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 76a53db70dSGreg Roach } 77a53db70dSGreg Roach 78a53db70dSGreg Roach /** 7915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 8015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 8118d7a90dSGreg Roach * 8218d7a90dSGreg Roach * @return void 83a53db70dSGreg Roach */ 84c1010edaSGreg Roach public function testDifferentCountry() 85c1010edaSGreg Roach { 86c314ecc9SGreg Roach $father = Mockery::mock('Fisharebest\Webtrees\Individual'); 8716d0b7f7SRico Sonntag $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 88a53db70dSGreg Roach 89c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 90a53db70dSGreg Roach $family->shouldReceive('getHusband')->andReturn($father); 91a53db70dSGreg Roach 92c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 93a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 94a53db70dSGreg Roach 95c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 96a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('Ireland'); 97a53db70dSGreg Roach 98a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 99a53db70dSGreg Roach 100342dcecdSGreg Roach $this->assertSame('Y', $column->generate($individual, $individual)); 101a53db70dSGreg Roach } 102a53db70dSGreg Roach 103a53db70dSGreg Roach /** 10415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 10515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 10618d7a90dSGreg Roach * 10718d7a90dSGreg Roach * @return void 108a53db70dSGreg Roach */ 109c1010edaSGreg Roach public function testPlaceNoParent() 110c1010edaSGreg Roach { 111c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 112a53db70dSGreg Roach $family->shouldReceive('getHusband')->andReturn(null); 113a53db70dSGreg Roach 114c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 115a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 116a53db70dSGreg Roach 117c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 118a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 119a53db70dSGreg Roach 120a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 121a53db70dSGreg Roach 122342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 123a53db70dSGreg Roach } 124a53db70dSGreg Roach 125a53db70dSGreg Roach /** 12615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 12715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 12818d7a90dSGreg Roach * 12918d7a90dSGreg Roach * @return void 130a53db70dSGreg Roach */ 131c1010edaSGreg Roach public function testPlaceNoParentFamily() 132c1010edaSGreg Roach { 133c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 134a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null); 135a53db70dSGreg Roach 136c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 137a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 138a53db70dSGreg Roach 139a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 140a53db70dSGreg Roach 141342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 142a53db70dSGreg Roach } 143a53db70dSGreg Roach} 144