1a53db70dSGreg Roach<?php 23976b470SGreg Roach 3a53db70dSGreg Roach/** 4a53db70dSGreg Roach * webtrees: online genealogy 58fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 6a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify 7a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by 8a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or 9a53db70dSGreg Roach * (at your option) any later version. 10a53db70dSGreg Roach * This program is distributed in the hope that it will be useful, 11a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13a53db70dSGreg Roach * GNU General Public License for more details. 14a53db70dSGreg Roach * You should have received a copy of the GNU General Public License 15a53db70dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16a53db70dSGreg Roach */ 17*fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 20a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census; 21a53db70dSGreg Roach 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2452348eb8SGreg Roachuse Fisharebest\Webtrees\Place; 253cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 26a53db70dSGreg Roach 27a53db70dSGreg Roach/** 28a53db70dSGreg Roach * Test harness for the class CensusColumnFatherForeign 29a53db70dSGreg Roach */ 303cfcc809SGreg Roachclass CensusColumnFatherForeignTest extends TestCase 31c1010edaSGreg Roach{ 32a53db70dSGreg Roach /** 3316d0b7f7SRico Sonntag * Get place mock. 3416d0b7f7SRico Sonntag * 3516d0b7f7SRico Sonntag * @param string $place Gedcom Place 3616d0b7f7SRico Sonntag * 3752348eb8SGreg Roach * @return Place 3816d0b7f7SRico Sonntag */ 3952348eb8SGreg Roach private function getPlaceMock($place): Place 40c1010edaSGreg Roach { 410ecdbde6SGreg Roach $placeMock = $this->createMock(Place::class); 420ecdbde6SGreg Roach $placeMock->method('gedcomName')->willReturn($place); 4316d0b7f7SRico Sonntag 4416d0b7f7SRico Sonntag return $placeMock; 4516d0b7f7SRico Sonntag } 4616d0b7f7SRico Sonntag 4716d0b7f7SRico Sonntag /** 4815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 4915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 5018d7a90dSGreg Roach * 5118d7a90dSGreg Roach * @return void 52a53db70dSGreg Roach */ 539b802b22SGreg Roach public function testSameCountry(): void 54c1010edaSGreg Roach { 550ecdbde6SGreg Roach $father = $this->createMock(Individual::class); 560ecdbde6SGreg Roach $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England')); 57a53db70dSGreg Roach 580ecdbde6SGreg Roach $family = $this->createMock(Family::class); 590ecdbde6SGreg Roach $family->method('husband')->willReturn($father); 60a53db70dSGreg Roach 610ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 620ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn($family); 63a53db70dSGreg Roach 640ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 650ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('England'); 66a53db70dSGreg Roach 67a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 68a53db70dSGreg Roach 69342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 70a53db70dSGreg Roach } 71a53db70dSGreg Roach 72a53db70dSGreg Roach /** 7315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 7415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 7518d7a90dSGreg Roach * 7618d7a90dSGreg Roach * @return void 77a53db70dSGreg Roach */ 789b802b22SGreg Roach public function testDifferentCountry(): void 79c1010edaSGreg Roach { 800ecdbde6SGreg Roach $father = $this->createMock(Individual::class); 810ecdbde6SGreg Roach $father->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England')); 82a53db70dSGreg Roach 830ecdbde6SGreg Roach $family = $this->createMock(Family::class); 840ecdbde6SGreg Roach $family->method('husband')->willReturn($father); 85a53db70dSGreg Roach 860ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 870ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn($family); 88a53db70dSGreg Roach 890ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 900ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('Ireland'); 91a53db70dSGreg Roach 92a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 93a53db70dSGreg Roach 94342dcecdSGreg Roach $this->assertSame('Y', $column->generate($individual, $individual)); 95a53db70dSGreg Roach } 96a53db70dSGreg Roach 97a53db70dSGreg Roach /** 9815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 9915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 10018d7a90dSGreg Roach * 10118d7a90dSGreg Roach * @return void 102a53db70dSGreg Roach */ 1039b802b22SGreg Roach public function testPlaceNoParent(): void 104c1010edaSGreg Roach { 1050ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1060ecdbde6SGreg Roach $family->method('husband')->willReturn(null); 107a53db70dSGreg Roach 1080ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1090ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn($family); 110a53db70dSGreg Roach 1110ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1120ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('England'); 113a53db70dSGreg Roach 114a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 115a53db70dSGreg Roach 116342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 117a53db70dSGreg Roach } 118a53db70dSGreg Roach 119a53db70dSGreg Roach /** 12015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 12115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 12218d7a90dSGreg Roach * 12318d7a90dSGreg Roach * @return void 124a53db70dSGreg Roach */ 1259b802b22SGreg Roach public function testPlaceNoParentFamily(): void 126c1010edaSGreg Roach { 1270ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1280ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn(null); 129a53db70dSGreg Roach 1300ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1310ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('England'); 132a53db70dSGreg Roach 133a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 134a53db70dSGreg Roach 135342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 136a53db70dSGreg Roach } 137a53db70dSGreg Roach} 138