1a4500ed5SGreg Roach<?php 2a4500ed5SGreg Roach 3a4500ed5SGreg Roach/** 4a4500ed5SGreg Roach * webtrees: online genealogy 5*6bdf7674SGreg Roach * Copyright (C) 2017 webtrees development team 6a4500ed5SGreg Roach * This program is free software: you can redistribute it and/or modify 7a4500ed5SGreg Roach * it under the terms of the GNU General Public License as published by 8a4500ed5SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9a4500ed5SGreg Roach * (at your option) any later version. 10a4500ed5SGreg Roach * This program is distributed in the hope that it will be useful, 11a4500ed5SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12a4500ed5SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13a4500ed5SGreg Roach * GNU General Public License for more details. 14a4500ed5SGreg Roach * You should have received a copy of the GNU General Public License 15a4500ed5SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16a4500ed5SGreg Roach */ 17a4500ed5SGreg Roachnamespace Fisharebest\Webtrees\Census; 18a4500ed5SGreg Roach 19a4500ed5SGreg Roachuse Mockery; 20a4500ed5SGreg Roach 21a4500ed5SGreg Roach/** 22a4500ed5SGreg Roach * Test harness for the class CensusColumnBirthPlaceSimple 23a4500ed5SGreg Roach */ 24a4500ed5SGreg Roachclass CensusColumnBirthPlaceSimpleTest extends \PHPUnit_Framework_TestCase { 25a4500ed5SGreg Roach /** 26a4500ed5SGreg Roach * Delete mock objects 27a4500ed5SGreg Roach */ 28a4500ed5SGreg Roach public function tearDown() { 29a4500ed5SGreg Roach Mockery::close(); 30a4500ed5SGreg Roach } 31a4500ed5SGreg Roach 32a4500ed5SGreg Roach /** 33a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 34a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 35a4500ed5SGreg Roach */ 36a4500ed5SGreg Roach public function testForeignCountry() { 37c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 38a4500ed5SGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('Westminster, London, England'); 39a4500ed5SGreg Roach 40c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 41a4500ed5SGreg Roach $census->shouldReceive('censusPlace')->andReturn('United States'); 42a4500ed5SGreg Roach 43a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 44a4500ed5SGreg Roach 45a4500ed5SGreg Roach $this->assertSame('England', $column->generate($individual)); 46a4500ed5SGreg Roach } 47a4500ed5SGreg Roach 48a4500ed5SGreg Roach /** 49a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 50a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 51a4500ed5SGreg Roach */ 52a4500ed5SGreg Roach public function testJustCountry() { 53c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 54a4500ed5SGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('United States'); 55a4500ed5SGreg Roach 56c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 57a4500ed5SGreg Roach $census->shouldReceive('censusPlace')->andReturn('United States'); 58a4500ed5SGreg Roach 59a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 60a4500ed5SGreg Roach 61a4500ed5SGreg Roach $this->assertSame('', $column->generate($individual)); 62a4500ed5SGreg Roach } 63a4500ed5SGreg Roach 64a4500ed5SGreg Roach /** 65a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 66a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 67a4500ed5SGreg Roach */ 68a4500ed5SGreg Roach public function testKnownState() { 69c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 70a4500ed5SGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('Maryland, United States'); 71a4500ed5SGreg Roach 72c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 73a4500ed5SGreg Roach $census->shouldReceive('censusPlace')->andReturn('United States'); 74a4500ed5SGreg Roach 75a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 76a4500ed5SGreg Roach 77a4500ed5SGreg Roach $this->assertSame('Maryland', $column->generate($individual)); 78a4500ed5SGreg Roach } 79a4500ed5SGreg Roach 80a4500ed5SGreg Roach /** 81a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple 82a4500ed5SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 83a4500ed5SGreg Roach */ 84a4500ed5SGreg Roach public function testKnownStateAndTown() { 85c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 86a4500ed5SGreg Roach $individual->shouldReceive('getBirthPlace')->andReturn('Miami, Florida, United States'); 87a4500ed5SGreg Roach 88c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 89a4500ed5SGreg Roach $census->shouldReceive('censusPlace')->andReturn('United States'); 90a4500ed5SGreg Roach 91a4500ed5SGreg Roach $column = new CensusColumnBirthPlaceSimple($census, '', ''); 92a4500ed5SGreg Roach 93a4500ed5SGreg Roach $this->assertSame('Florida', $column->generate($individual)); 94a4500ed5SGreg Roach } 95a4500ed5SGreg Roach} 96