1a4500ed5SGreg Roach<?php 2a4500ed5SGreg Roach/** 3a4500ed5SGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 5a4500ed5SGreg Roach * This program is free software: you can redistribute it and/or modify 6a4500ed5SGreg Roach * it under the terms of the GNU General Public License as published by 7a4500ed5SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8a4500ed5SGreg Roach * (at your option) any later version. 9a4500ed5SGreg Roach * This program is distributed in the hope that it will be useful, 10a4500ed5SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11a4500ed5SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12a4500ed5SGreg Roach * GNU General Public License for more details. 13a4500ed5SGreg Roach * You should have received a copy of the GNU General Public License 14a4500ed5SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15a4500ed5SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 18a4500ed5SGreg Roachnamespace Fisharebest\Webtrees\Census; 19a4500ed5SGreg Roach 20ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 2152348eb8SGreg Roachuse Fisharebest\Webtrees\Place; 22a4500ed5SGreg Roach 23a4500ed5SGreg Roach/** 24a4500ed5SGreg Roach * Test harness for the class CensusColumnBirthPlaceSimple 25a4500ed5SGreg Roach */ 2684e2cf4eSGreg Roachclass CensusColumnBirthPlaceSimpleTest extends \Fisharebest\Webtrees\TestCase 27c1010edaSGreg Roach{ 28a4500ed5SGreg Roach /** 2916d0b7f7SRico Sonntag * Get place mock. 3016d0b7f7SRico Sonntag * 3116d0b7f7SRico Sonntag * @param string $place Gedcom Place 3216d0b7f7SRico Sonntag * 3352348eb8SGreg Roach * @return Place 3416d0b7f7SRico Sonntag */ 3552348eb8SGreg Roach private function getPlaceMock($place): Place 36c1010edaSGreg Roach { 37*0ecdbde6SGreg Roach $placeMock = $this->createMock(Place::class); 38*0ecdbde6SGreg Roach $placeMock->method('gedcomName')->willReturn($place); 3916d0b7f7SRico Sonntag 4016d0b7f7SRico Sonntag return $placeMock; 4116d0b7f7SRico Sonntag } 4216d0b7f7SRico Sonntag 4316d0b7f7SRico Sonntag /** 4415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 4515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 4652348eb8SGreg Roach * 4752348eb8SGreg Roach * @return void 48a4500ed5SGreg Roach */ 499b802b22SGreg Roach public function testForeignCountry(): void 50c1010edaSGreg Roach { 51*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 52*0ecdbde6SGreg Roach $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Westminster, London, England')); 53a4500ed5SGreg Roach 54*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 55*0ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('United States'); 56a4500ed5SGreg Roach 57a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 58a4500ed5SGreg Roach 59342dcecdSGreg Roach $this->assertSame('England', $column->generate($individual, $individual)); 60a4500ed5SGreg Roach } 61a4500ed5SGreg Roach 62a4500ed5SGreg Roach /** 6315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 6415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 6552348eb8SGreg Roach * 6652348eb8SGreg Roach * @return void 67a4500ed5SGreg Roach */ 689b802b22SGreg Roach public function testJustCountry(): void 69c1010edaSGreg Roach { 70*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 71*0ecdbde6SGreg Roach $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('United States')); 72a4500ed5SGreg Roach 73*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 74*0ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('United States'); 75a4500ed5SGreg Roach 76a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 77a4500ed5SGreg Roach 78342dcecdSGreg Roach $this->assertSame('', $column->generate($individual, $individual)); 79a4500ed5SGreg Roach } 80a4500ed5SGreg Roach 81a4500ed5SGreg Roach /** 8215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 8315d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 8452348eb8SGreg Roach * 8552348eb8SGreg Roach * @return void 86a4500ed5SGreg Roach */ 879b802b22SGreg Roach public function testKnownState(): void 88c1010edaSGreg Roach { 89*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 90*0ecdbde6SGreg Roach $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Maryland, United States')); 91a4500ed5SGreg Roach 92*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 93*0ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('United States'); 94a4500ed5SGreg Roach 95a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 96a4500ed5SGreg Roach 97342dcecdSGreg Roach $this->assertSame('Maryland', $column->generate($individual, $individual)); 98a4500ed5SGreg Roach } 99a4500ed5SGreg Roach 100a4500ed5SGreg Roach /** 10115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 10215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 10352348eb8SGreg Roach * 10452348eb8SGreg Roach * @return void 105a4500ed5SGreg Roach */ 1069b802b22SGreg Roach public function testKnownStateAndTown(): void 107c1010edaSGreg Roach { 108*0ecdbde6SGreg Roach $individual = $this->createMock(Individual::class); 109*0ecdbde6SGreg Roach $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Miami, Florida, United States')); 110a4500ed5SGreg Roach 111*0ecdbde6SGreg Roach $census = $this->createMock(CensusInterface::class); 112*0ecdbde6SGreg Roach $census->method('censusPlace')->willReturn('United States'); 113a4500ed5SGreg Roach 114a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 115a4500ed5SGreg Roach 116342dcecdSGreg Roach $this->assertSame('Florida', $column->generate($individual, $individual)); 117a4500ed5SGreg Roach } 118a4500ed5SGreg Roach} 119