1101af0b4SGreg Roach<?php 2101af0b4SGreg Roach 3101af0b4SGreg Roach/** 4101af0b4SGreg Roach * webtrees: online genealogy 5101af0b4SGreg Roach * Copyright (C) 2015 webtrees development team 6101af0b4SGreg Roach * This program is free software: you can redistribute it and/or modify 7101af0b4SGreg Roach * it under the terms of the GNU General Public License as published by 8101af0b4SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9101af0b4SGreg Roach * (at your option) any later version. 10101af0b4SGreg Roach * This program is distributed in the hope that it will be useful, 11101af0b4SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12101af0b4SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13101af0b4SGreg Roach * GNU General Public License for more details. 14101af0b4SGreg Roach * You should have received a copy of the GNU General Public License 15101af0b4SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16101af0b4SGreg Roach */ 17101af0b4SGreg Roach 18101af0b4SGreg Roachnamespace Fisharebest\Webtrees\Census; 19101af0b4SGreg Roach 20101af0b4SGreg Roachuse Fisharebest\Webtrees\Date; 21*73d4df56SGreg Roachuse Fisharebest\Webtrees\Fact; 22*73d4df56SGreg Roachuse Fisharebest\Webtrees\Family; 23101af0b4SGreg Roachuse Fisharebest\Webtrees\Individual; 24101af0b4SGreg Roachuse Mockery; 25101af0b4SGreg Roach 26101af0b4SGreg Roach/** 27*73d4df56SGreg Roach * Test harness for the class CensusColumnConditionDanish 28101af0b4SGreg Roach */ 29101af0b4SGreg Roachclass CensusColumnConditionDanishTest extends \PHPUnit_Framework_TestCase { 30101af0b4SGreg Roach /** 31101af0b4SGreg Roach * Delete mock objects 32101af0b4SGreg Roach */ 33101af0b4SGreg Roach public function tearDown() { 34101af0b4SGreg Roach Mockery::close(); 35101af0b4SGreg Roach } 36101af0b4SGreg Roach 37101af0b4SGreg Roach /** 38*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 39101af0b4SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 40101af0b4SGreg Roach */ 41*73d4df56SGreg Roach public function testNoSpouseFamilies() { 42101af0b4SGreg Roach $individual = Mockery::mock(Individual::class); 43*73d4df56SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 44101af0b4SGreg Roach 45101af0b4SGreg Roach $census = Mockery::mock(CensusInterface::class); 46101af0b4SGreg Roach 47*73d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 48101af0b4SGreg Roach 49*73d4df56SGreg Roach $this->assertSame('Ugift', $column->generate($individual)); 50*73d4df56SGreg Roach } 51*73d4df56SGreg Roach 52*73d4df56SGreg Roach /** 53*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 54*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 55*73d4df56SGreg Roach */ 56*73d4df56SGreg Roach public function testNoFamilyNoFacts() { 57*73d4df56SGreg Roach $family = Mockery::mock(Family::class); 58*73d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 59*73d4df56SGreg Roach $family->shouldReceive('getFacts')->andReturn([]); 60*73d4df56SGreg Roach 61*73d4df56SGreg Roach $individual = Mockery::mock(Individual::class); 62*73d4df56SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 63*73d4df56SGreg Roach 64*73d4df56SGreg Roach $census = Mockery::mock(CensusInterface::class); 65*73d4df56SGreg Roach 66*73d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 67*73d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 68*73d4df56SGreg Roach 69*73d4df56SGreg Roach $this->assertSame('Gift', $column->generate($individual)); 70*73d4df56SGreg Roach } 71*73d4df56SGreg Roach 72*73d4df56SGreg Roach /** 73*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 74*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 75*73d4df56SGreg Roach */ 76*73d4df56SGreg Roach public function testNoFamilyUnmarried() { 77*73d4df56SGreg Roach $fact = Mockery::mock(Fact::class); 78*73d4df56SGreg Roach 79*73d4df56SGreg Roach $family = Mockery::mock(Family::class); 80*73d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 81*73d4df56SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([$fact]); 82*73d4df56SGreg Roach 83*73d4df56SGreg Roach $individual = Mockery::mock(Individual::class); 84*73d4df56SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 85*73d4df56SGreg Roach 86*73d4df56SGreg Roach $census = Mockery::mock(CensusInterface::class); 87*73d4df56SGreg Roach 88*73d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 89*73d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 90*73d4df56SGreg Roach 91*73d4df56SGreg Roach $this->assertSame('Ugift', $column->generate($individual)); 92*73d4df56SGreg Roach } 93*73d4df56SGreg Roach 94*73d4df56SGreg Roach /** 95*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnConditionDanish 96*73d4df56SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 97*73d4df56SGreg Roach */ 98*73d4df56SGreg Roach public function testNoFamilyDivorced() { 99*73d4df56SGreg Roach $fact = Mockery::mock(Fact::class); 100*73d4df56SGreg Roach 101*73d4df56SGreg Roach $family = Mockery::mock(Family::class); 102*73d4df56SGreg Roach $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 103*73d4df56SGreg Roach $family->shouldReceive('getFacts')->with('_NMR')->andReturn([]); 104*73d4df56SGreg Roach $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 105*73d4df56SGreg Roach 106*73d4df56SGreg Roach $individual = Mockery::mock(Individual::class); 107*73d4df56SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 108*73d4df56SGreg Roach 109*73d4df56SGreg Roach $census = Mockery::mock(CensusInterface::class); 110*73d4df56SGreg Roach 111*73d4df56SGreg Roach $column = new CensusColumnConditionDanish($census, '', ''); 112*73d4df56SGreg Roach $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 113*73d4df56SGreg Roach 114*73d4df56SGreg Roach $this->assertSame('Skilt', $column->generate($individual)); 115101af0b4SGreg Roach } 116101af0b4SGreg Roach} 117