1<?php 2 3/** 4 * webtrees: online genealogy 5 * Copyright (C) 2018 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 Mockery; 21 22/** 23 * Test harness for the class CensusColumnConditionFrenchVeuf 24 */ 25class CensusColumnConditionFrenchVeufTest extends \PHPUnit\Framework\TestCase 26{ 27 /** 28 * Delete mock objects 29 */ 30 public function tearDown() 31 { 32 Mockery::close(); 33 } 34 35 /** 36 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 37 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 38 */ 39 public function testNoSpouseFamiliesMale() 40 { 41 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 42 $individual->shouldReceive('getSex')->andReturn('M'); 43 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 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, $individual)); 52 } 53 54 /** 55 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 56 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 57 */ 58 public function testNoSpouseFamiliesFemale() 59 { 60 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 61 $individual->shouldReceive('getSex')->andReturn('F'); 62 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 63 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 64 65 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 66 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 67 68 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 69 70 $this->assertSame('', $column->generate($individual, $individual)); 71 } 72 73 /** 74 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 75 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 76 */ 77 public function testNoFamilyFactsMale() 78 { 79 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 80 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 81 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 82 83 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 84 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 85 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 86 $individual->shouldReceive('getSex')->andReturn('M'); 87 88 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 89 90 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 91 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 92 93 $this->assertSame('', $column->generate($individual, $individual)); 94 } 95 96 /** 97 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 98 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 99 */ 100 public function testNoFamilyFactsFemale() 101 { 102 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 103 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 104 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 105 106 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 107 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 108 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 109 $individual->shouldReceive('getSex')->andReturn('F'); 110 111 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 112 113 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 114 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 115 116 $this->assertSame('', $column->generate($individual, $individual)); 117 } 118 119 /** 120 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 121 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 122 */ 123 public function testSpouseDeadMale() 124 { 125 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 126 127 $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 128 $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 129 130 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 131 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 132 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 133 $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 134 $family->shouldReceive('getSpouse')->andReturn($spouse); 135 136 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 137 $individual->shouldReceive('getSex')->andReturn('M'); 138 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 139 140 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 141 142 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 143 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 144 145 $this->assertSame('1', $column->generate($individual, $individual)); 146 } 147 148 /** 149 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 150 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 151 */ 152 public function testSpouseDeadFemale() 153 { 154 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 155 156 $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 157 $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 158 159 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 160 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 161 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 162 $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 163 $family->shouldReceive('getSpouse')->andReturn($spouse); 164 165 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 166 $individual->shouldReceive('getSex')->andReturn('F'); 167 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 168 169 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 170 171 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 172 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 173 174 $this->assertSame('', $column->generate($individual, $individual)); 175 } 176 177 /** 178 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 179 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 180 */ 181 public function testNoFamilyUnmarriedMale() 182 { 183 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 184 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 185 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 186 187 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 188 $individual->shouldReceive('getSex')->andReturn('M'); 189 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 190 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 191 192 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 193 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 194 195 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 196 197 $this->assertSame('', $column->generate($individual, $individual)); 198 } 199 200 /** 201 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 202 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 203 */ 204 public function testNoFamilyUnmarriedFemale() 205 { 206 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 207 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 208 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 209 210 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 211 $individual->shouldReceive('getSex')->andReturn('F'); 212 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 213 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 214 215 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 216 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 217 218 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 219 220 $this->assertSame('', $column->generate($individual, $individual)); 221 } 222 223 /** 224 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 225 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 226 */ 227 public function testChildMale() 228 { 229 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 230 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 231 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 232 233 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 234 $individual->shouldReceive('getSex')->andReturn('M'); 235 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 236 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 237 238 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 239 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 240 241 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 242 243 $this->assertSame('', $column->generate($individual, $individual)); 244 } 245 246 /** 247 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 248 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 249 */ 250 public function testChildFemale() 251 { 252 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 253 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 254 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 255 256 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 257 $individual->shouldReceive('getSex')->andReturn('F'); 258 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 259 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 260 261 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 262 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 263 264 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 265 266 $this->assertSame('', $column->generate($individual, $individual)); 267 } 268 269 /** 270 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 271 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 272 */ 273 public function testDivorcedMale() 274 { 275 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 276 277 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 278 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 279 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 280 $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 281 282 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 283 $individual->shouldReceive('getSex')->andReturn('M'); 284 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 285 286 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 287 288 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 289 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 290 291 $this->assertSame('', $column->generate($individual, $individual)); 292 } 293 294 /** 295 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuf 296 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 297 */ 298 public function testDivorcedFemale() 299 { 300 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 301 302 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 303 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 304 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 305 $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 306 307 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 308 $individual->shouldReceive('getSex')->andReturn('F'); 309 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 310 311 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 312 313 $column = new CensusColumnConditionFrenchVeuf($census, '', ''); 314 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 315 316 $this->assertSame('', $column->generate($individual, $individual)); 317 } 318} 319