1a53db70dSGreg Roach<?php 2a53db70dSGreg Roach 3a53db70dSGreg Roach/** 4a53db70dSGreg Roach * webtrees: online genealogy 5*6bdf7674SGreg Roach * Copyright (C) 2017 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 */ 17a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census; 18a53db70dSGreg Roach 19a53db70dSGreg Roachuse Mockery; 20a53db70dSGreg Roach 21a53db70dSGreg Roach/** 22a53db70dSGreg Roach * Test harness for the class CensusColumnMotherBirthPlace 23a53db70dSGreg Roach */ 24a53db70dSGreg Roachclass CensusColumnMotherBirthPlaceTest extends \PHPUnit_Framework_TestCase { 25a53db70dSGreg Roach /** 26a53db70dSGreg Roach * Delete mock objects 27a53db70dSGreg Roach */ 28a53db70dSGreg Roach public function tearDown() { 29a53db70dSGreg Roach Mockery::close(); 30a53db70dSGreg Roach } 31a53db70dSGreg Roach 32a53db70dSGreg Roach /** 33a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlace 34a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 35a53db70dSGreg Roach */ 36a53db70dSGreg Roach public function testSameCountry() { 37c314ecc9SGreg Roach $mother = Mockery::mock('Fisharebest\Webtrees\Individual'); 38a53db70dSGreg Roach $mother->shouldReceive('getBirthPlace')->andReturn('London, England'); 39a53db70dSGreg Roach 40c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 41a53db70dSGreg Roach $family->shouldReceive('getWife')->andReturn($mother); 42a53db70dSGreg Roach 43c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 44a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 45a53db70dSGreg Roach 46c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 47a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 48a53db70dSGreg Roach 49a53db70dSGreg Roach $column = new CensusColumnMotherBirthPlace($census, '', ''); 50a53db70dSGreg Roach 51a53db70dSGreg Roach $this->assertSame('London', $column->generate($individual)); 52a53db70dSGreg Roach } 53a53db70dSGreg Roach 54a53db70dSGreg Roach /** 55a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlace 56a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 57a53db70dSGreg Roach */ 58a53db70dSGreg Roach public function testDifferentCountry() { 59c314ecc9SGreg Roach $mother = Mockery::mock('Fisharebest\Webtrees\Individual'); 60a53db70dSGreg Roach $mother->shouldReceive('getBirthPlace')->andReturn('London, England'); 61a53db70dSGreg Roach 62c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 63a53db70dSGreg Roach $family->shouldReceive('getWife')->andReturn($mother); 64a53db70dSGreg Roach 65c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 66a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 67a53db70dSGreg Roach 68c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 69a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('Ireland'); 70a53db70dSGreg Roach 71a53db70dSGreg Roach $column = new CensusColumnMotherBirthPlace($census, '', ''); 72a53db70dSGreg Roach 73a53db70dSGreg Roach $this->assertSame('London, England', $column->generate($individual)); 74a53db70dSGreg Roach } 75a53db70dSGreg Roach 76a53db70dSGreg Roach /** 77a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlace 78a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 79a53db70dSGreg Roach */ 80a53db70dSGreg Roach public function testPlaceNoParent() { 81c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 82a53db70dSGreg Roach $family->shouldReceive('getWife')->andReturn(null); 83a53db70dSGreg Roach 84c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 85a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 86a53db70dSGreg Roach 87c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 88a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 89a53db70dSGreg Roach 90a53db70dSGreg Roach $column = new CensusColumnMotherBirthPlace($census, '', ''); 91a53db70dSGreg Roach 92a53db70dSGreg Roach $this->assertSame('', $column->generate($individual)); 93a53db70dSGreg Roach } 94a53db70dSGreg Roach 95a53db70dSGreg Roach /** 96a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlace 97a53db70dSGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 98a53db70dSGreg Roach */ 99a53db70dSGreg Roach public function testPlaceNoParentFamily() { 100c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 101a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null); 102a53db70dSGreg Roach 103c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 104a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 105a53db70dSGreg Roach 106a53db70dSGreg Roach $column = new CensusColumnMotherBirthPlace($census, '', ''); 107a53db70dSGreg Roach 108a53db70dSGreg Roach $this->assertSame('', $column->generate($individual)); 109a53db70dSGreg Roach } 110a53db70dSGreg Roach} 111