1a53db70dSGreg Roach<?php 2*3976b470SGreg 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 */ 17e7f56f2aSGreg Roachdeclare(strict_types=1); 18e7f56f2aSGreg Roach 19a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census; 20a53db70dSGreg Roach 21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family; 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2352348eb8SGreg Roachuse Fisharebest\Webtrees\Place; 24a53db70dSGreg Roach 25a53db70dSGreg Roach/** 26a53db70dSGreg Roach * Test harness for the class CensusColumnMotherForeign 27a53db70dSGreg Roach */ 2884e2cf4eSGreg Roachclass CensusColumnMotherForeignTest extends \Fisharebest\Webtrees\TestCase 29c1010edaSGreg Roach{ 30a53db70dSGreg Roach /** 3116d0b7f7SRico Sonntag * Get place mock. 3216d0b7f7SRico Sonntag * 3316d0b7f7SRico Sonntag * @param string $place Gedcom Place 3416d0b7f7SRico Sonntag * 3552348eb8SGreg Roach * @return Place 3616d0b7f7SRico Sonntag */ 3752348eb8SGreg Roach private function getPlaceMock($place): Place 38c1010edaSGreg Roach { 390ecdbde6SGreg Roach $placeMock = $this->createMock(Place::class); 400ecdbde6SGreg Roach $placeMock->method('gedcomName')->willReturn($place); 4116d0b7f7SRico Sonntag 4216d0b7f7SRico Sonntag return $placeMock; 4316d0b7f7SRico Sonntag } 4416d0b7f7SRico Sonntag 4516d0b7f7SRico Sonntag /** 4615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign 4715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 4852348eb8SGreg Roach * 4952348eb8SGreg Roach * @return void 50a53db70dSGreg Roach */ 519b802b22SGreg Roach public function testSameCountry(): void 52c1010edaSGreg Roach { 530ecdbde6SGreg Roach $mother = $this->createMock(Individual::class); 540ecdbde6SGreg Roach $mother->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England')); 55a53db70dSGreg Roach 560ecdbde6SGreg Roach $family = $this->createMock(Family::class); 570ecdbde6SGreg Roach $family->method('wife')->willReturn($mother); 58a53db70dSGreg Roach 590ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 600ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn($family); 61a53db70dSGreg Roach 620ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 630ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('England'); 64a53db70dSGreg Roach 65a53db70dSGreg Roach $column = new CensusColumnMotherForeign($census, '', ''); 66a53db70dSGreg Roach 67342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 68a53db70dSGreg Roach } 69a53db70dSGreg Roach 70a53db70dSGreg Roach /** 7115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign 7215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 7352348eb8SGreg Roach * 7452348eb8SGreg Roach * @return void 75a53db70dSGreg Roach */ 769b802b22SGreg Roach public function testDifferentCountry(): void 77c1010edaSGreg Roach { 780ecdbde6SGreg Roach $mother = $this->createMock(Individual::class); 790ecdbde6SGreg Roach $mother->method('getBirthPlace')->willReturn($this->getPlaceMock('London, England')); 80a53db70dSGreg Roach 810ecdbde6SGreg Roach $family = $this->createMock(Family::class); 820ecdbde6SGreg Roach $family->method('wife')->willReturn($mother); 83a53db70dSGreg Roach 840ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 850ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn($family); 86a53db70dSGreg Roach 870ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 880ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('Ireland'); 89a53db70dSGreg Roach 90a53db70dSGreg Roach $column = new CensusColumnMotherForeign($census, '', ''); 91a53db70dSGreg Roach 92342dcecdSGreg Roach $this->assertSame('Y', $column->generate($individual, $individual)); 93a53db70dSGreg Roach } 94a53db70dSGreg Roach 95a53db70dSGreg Roach /** 9615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign 9715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 9852348eb8SGreg Roach * 9952348eb8SGreg Roach * @return void 100a53db70dSGreg Roach */ 1019b802b22SGreg Roach public function testPlaceNoParent(): void 102c1010edaSGreg Roach { 1030ecdbde6SGreg Roach $family = $this->createMock(Family::class); 1040ecdbde6SGreg Roach $family->method('wife')->willReturn(null); 105a53db70dSGreg Roach 1060ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1070ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn($family); 108a53db70dSGreg Roach 1090ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1100ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('England'); 111a53db70dSGreg Roach 112a53db70dSGreg Roach $column = new CensusColumnMotherForeign($census, '', ''); 113a53db70dSGreg Roach 114342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 115a53db70dSGreg Roach } 116a53db70dSGreg Roach 117a53db70dSGreg Roach /** 11815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign 11915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 12052348eb8SGreg Roach * 12152348eb8SGreg Roach * @return void 122a53db70dSGreg Roach */ 1239b802b22SGreg Roach public function testPlaceNoParentFamily(): void 124c1010edaSGreg Roach { 1250ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 1260ecdbde6SGreg Roach $individual->method('primaryChildFamily')->willReturn(null); 127a53db70dSGreg Roach 1280ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 1290ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('England'); 130a53db70dSGreg Roach 131a53db70dSGreg Roach $column = new CensusColumnMotherForeign($census, '', ''); 132a53db70dSGreg Roach 133342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 134a53db70dSGreg Roach } 135a53db70dSGreg Roach} 136