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