1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2016 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\Date; 20use Fisharebest\Webtrees\Fact; 21use Fisharebest\Webtrees\Family; 22use Fisharebest\Webtrees\Individual; 23use Mockery; 24 25/** 26 * Test harness for the class CensusColumnConditionFrenchVeuf 27 */ 28class CensusColumnConditionFrenchVeufTest extends \PHPUnit_Framework_TestCase { 29 /** 30 * Delete mock objects 31 */ 32 public function tearDown() { 33 Mockery::close(); 34 } 35 36 /** 37 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 38 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 39 */ 40 public function testNoSpouseFamiliesMale() { 41 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 42 $individual->shouldReceive('getSex')->andReturn('M'); 43 $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); 44 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 45 46 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 47 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 48 49 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 50 51 $this->assertSame('', $column->generate($individual)); 52 } 53 54 /** 55 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 56 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 57 */ 58 public function testNoSpouseFamiliesFemale() { 59 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 60 $individual->shouldReceive('getSex')->andReturn('F'); 61 $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); 62 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 63 64 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 65 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 66 67 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 68 69 $this->assertSame('', $column->generate($individual)); 70 } 71 72 /** 73 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 74 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 75 */ 76 public function testNoFamilyNoFactsMale() { 77 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 78 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 79 $family->shouldReceive('getFacts')->andReturn(array()); 80 81 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 82 $individual->shouldReceive('getSex')->andReturn('M'); 83 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 84 85 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 86 87 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 88 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 89 90 $this->assertSame('', $column->generate($individual)); 91 } 92 93 /** 94 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 95 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 96 */ 97 public function testNoFamilyNoFactsFemale() { 98 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 99 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 100 $family->shouldReceive('getFacts')->andReturn(array()); 101 102 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 103 $individual->shouldReceive('getSex')->andReturn('F'); 104 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 105 106 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 107 108 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 109 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 110 111 $this->assertSame('', $column->generate($individual)); 112 } 113 114 /** 115 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 116 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 117 */ 118 public function testNoFamilyUnmarriedMale() { 119 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 120 121 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 122 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 123 $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 124 125 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 126 $individual->shouldReceive('getSex')->andReturn('M'); 127 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 128 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 129 130 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 131 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 132 133 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 134 135 $this->assertSame('', $column->generate($individual)); 136 } 137 138 /** 139 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 140 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 141 */ 142 public function testNoFamilyUnmarriedFemale() { 143 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 144 145 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 146 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 147 $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 148 149 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 150 $individual->shouldReceive('getSex')->andReturn('F'); 151 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 152 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 153 154 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 155 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 156 157 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 158 159 $this->assertSame('', $column->generate($individual)); 160 } 161 162 /** 163 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 164 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 165 */ 166 public function testChildMale() { 167 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 168 169 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 170 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 171 $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 172 173 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 174 $individual->shouldReceive('getSex')->andReturn('M'); 175 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 176 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 177 178 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 179 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 180 181 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 182 183 $this->assertSame('', $column->generate($individual)); 184 } 185 186 /** 187 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 188 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 189 */ 190 public function testChildFemale() { 191 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 192 193 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 194 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 195 $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); 196 197 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 198 $individual->shouldReceive('getSex')->andReturn('F'); 199 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 200 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 201 202 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 203 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 204 205 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 206 207 $this->assertSame('', $column->generate($individual)); 208 } 209 210 /** 211 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 212 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 213 */ 214 public function testDivorcedMale() { 215 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 216 217 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 218 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 219 $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array()); 220 $family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact)); 221 222 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 223 $individual->shouldReceive('getSex')->andReturn('M'); 224 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 225 226 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 227 228 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 229 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 230 231 $this->assertSame('', $column->generate($individual)); 232 } 233 234 /** 235 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 236 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 237 */ 238 public function testDivorcedFemale() { 239 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 240 241 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 242 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 243 $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array()); 244 $family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact)); 245 246 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 247 $individual->shouldReceive('getSex')->andReturn('F'); 248 $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); 249 250 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 251 252 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 253 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 254 255 $this->assertSame('', $column->generate($individual)); 256 } 257} 258