1a53db70dSGreg Roach<?php 2a53db70dSGreg Roach 3a53db70dSGreg Roach/** 4a53db70dSGreg Roach * webtrees: online genealogy 56bdf7674SGreg 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 CensusColumnFatherForeign 23a53db70dSGreg Roach */ 24*3e983931SGreg Roachclass CensusColumnFatherForeignTest 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 /** 3316d0b7f7SRico Sonntag * Get place mock. 3416d0b7f7SRico Sonntag * 3516d0b7f7SRico Sonntag * @param string $place Gedcom Place 3616d0b7f7SRico Sonntag * 3716d0b7f7SRico Sonntag * @return \Fisharebest\Webtrees\Place 3816d0b7f7SRico Sonntag */ 398d68cabeSGreg Roach private function getPlaceMock($place) { 4016d0b7f7SRico Sonntag $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place'); 4116d0b7f7SRico Sonntag $placeMock->shouldReceive('getGedcomName')->andReturn($place); 4216d0b7f7SRico Sonntag 4316d0b7f7SRico Sonntag return $placeMock; 4416d0b7f7SRico Sonntag } 4516d0b7f7SRico Sonntag 4616d0b7f7SRico Sonntag /** 4715d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 4815d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 49a53db70dSGreg Roach */ 50a53db70dSGreg Roach public function testSameCountry() { 51c314ecc9SGreg Roach $father = Mockery::mock('Fisharebest\Webtrees\Individual'); 5216d0b7f7SRico Sonntag $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 53a53db70dSGreg Roach 54c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 55a53db70dSGreg Roach $family->shouldReceive('getHusband')->andReturn($father); 56a53db70dSGreg Roach 57c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 58a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 59a53db70dSGreg Roach 60c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 61a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 62a53db70dSGreg Roach 63a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 64a53db70dSGreg Roach 65a53db70dSGreg Roach $this->assertSame('', $column->generate($individual)); 66a53db70dSGreg Roach } 67a53db70dSGreg Roach 68a53db70dSGreg Roach /** 6915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 7015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 71a53db70dSGreg Roach */ 72a53db70dSGreg Roach public function testDifferentCountry() { 73c314ecc9SGreg Roach $father = Mockery::mock('Fisharebest\Webtrees\Individual'); 7416d0b7f7SRico Sonntag $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England')); 75a53db70dSGreg Roach 76c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 77a53db70dSGreg Roach $family->shouldReceive('getHusband')->andReturn($father); 78a53db70dSGreg Roach 79c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 80a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 81a53db70dSGreg Roach 82c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 83a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('Ireland'); 84a53db70dSGreg Roach 85a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 86a53db70dSGreg Roach 87a53db70dSGreg Roach $this->assertSame('Y', $column->generate($individual)); 88a53db70dSGreg Roach } 89a53db70dSGreg Roach 90a53db70dSGreg Roach /** 9115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 9215d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 93a53db70dSGreg Roach */ 94a53db70dSGreg Roach public function testPlaceNoParent() { 95c314ecc9SGreg Roach $family = Mockery::mock('Fisharebest\Webtrees\Family'); 96a53db70dSGreg Roach $family->shouldReceive('getHusband')->andReturn(null); 97a53db70dSGreg Roach 98c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 99a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family); 100a53db70dSGreg Roach 101c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 102a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 103a53db70dSGreg Roach 104a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 105a53db70dSGreg Roach 106a53db70dSGreg Roach $this->assertSame('', $column->generate($individual)); 107a53db70dSGreg Roach } 108a53db70dSGreg Roach 109a53db70dSGreg Roach /** 11015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFatherForeign 11115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 112a53db70dSGreg Roach */ 113a53db70dSGreg Roach public function testPlaceNoParentFamily() { 114c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 115a53db70dSGreg Roach $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null); 116a53db70dSGreg Roach 117c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 118a53db70dSGreg Roach $census->shouldReceive('censusPlace')->andReturn('England'); 119a53db70dSGreg Roach 120a53db70dSGreg Roach $column = new CensusColumnFatherForeign($census, '', ''); 121a53db70dSGreg Roach 122a53db70dSGreg Roach $this->assertSame('', $column->generate($individual)); 123a53db70dSGreg Roach } 124a53db70dSGreg Roach} 125