1<?php 2/** 3 * webtrees: online genealogy 4 * Copyright (C) 2018 webtrees development team 5 * This program is free software: you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation, either version 3 of the License, or 8 * (at your option) any later version. 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * You should have received a copy of the GNU General Public License 14 * along with this program. If not, see <http://www.gnu.org/licenses/>. 15 */ 16namespace Fisharebest\Webtrees\Census; 17 18use Fisharebest\Webtrees\Date; 19use Mockery; 20 21/** 22 * Test harness for the class CensusColumnConditionFrenchVeuve 23 */ 24class CensusColumnConditionFrenchVeuveTest extends \Fisharebest\Webtrees\TestCase 25{ 26 /** 27 * Delete mock objects 28 */ 29 public function tearDown() 30 { 31 Mockery::close(); 32 } 33 34 /** 35 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 36 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 37 */ 38 public function testNoSpouseFamiliesMale() 39 { 40 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 41 $individual->shouldReceive('getSex')->andReturn('M'); 42 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 43 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 44 45 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 46 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 47 48 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 49 50 $this->assertSame('', $column->generate($individual, $individual)); 51 } 52 53 /** 54 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 55 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 56 */ 57 public function testNoSpouseFamiliesFemale() 58 { 59 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 60 $individual->shouldReceive('getSex')->andReturn('F'); 61 $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 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 CensusColumnConditionFrenchVeuve($census, '', ''); 68 69 $this->assertSame('', $column->generate($individual, $individual)); 70 } 71 72 /** 73 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 74 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 75 */ 76 public function testNoFamilyFactsMale() 77 { 78 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 79 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 80 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 81 82 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 83 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 84 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 85 $individual->shouldReceive('getSex')->andReturn('M'); 86 87 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 88 89 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 90 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 91 92 $this->assertSame('', $column->generate($individual, $individual)); 93 } 94 95 /** 96 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 97 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 98 */ 99 public function testNoFamilyFactsFemale() 100 { 101 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 102 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 103 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 104 105 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 106 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 107 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 108 $individual->shouldReceive('getSex')->andReturn('F'); 109 110 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 111 112 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 113 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 114 115 $this->assertSame('', $column->generate($individual, $individual)); 116 } 117 118 /** 119 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 120 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 121 */ 122 public function testSpouseDeadMale() 123 { 124 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 125 126 $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 127 $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 128 129 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 130 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 131 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 132 $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 133 $family->shouldReceive('getSpouse')->andReturn($spouse); 134 135 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 136 $individual->shouldReceive('getSex')->andReturn('M'); 137 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 138 139 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 140 141 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 142 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 143 144 $this->assertSame('', $column->generate($individual, $individual)); 145 } 146 147 /** 148 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 149 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 150 */ 151 public function testSpouseDeadFemale() 152 { 153 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 154 155 $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); 156 $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); 157 158 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 159 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 160 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 161 $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); 162 $family->shouldReceive('getSpouse')->andReturn($spouse); 163 164 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 165 $individual->shouldReceive('getSex')->andReturn('F'); 166 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 167 168 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 169 170 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 171 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 172 173 $this->assertSame('1', $column->generate($individual, $individual)); 174 } 175 176 /** 177 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 178 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 179 */ 180 public function testNoFamilyUnmarriedMale() 181 { 182 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 183 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 184 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 185 186 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 187 $individual->shouldReceive('getSex')->andReturn('M'); 188 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 189 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 190 191 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 192 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 193 194 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 195 196 $this->assertSame('', $column->generate($individual, $individual)); 197 } 198 199 /** 200 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 201 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 202 */ 203 public function testNoFamilyUnmarriedFemale() 204 { 205 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 206 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 207 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 208 209 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 210 $individual->shouldReceive('getSex')->andReturn('F'); 211 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 212 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); 213 214 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 215 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 216 217 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 218 219 $this->assertSame('', $column->generate($individual, $individual)); 220 } 221 222 /** 223 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 224 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 225 */ 226 public function testChildMale() 227 { 228 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 229 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 230 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 231 232 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 233 $individual->shouldReceive('getSex')->andReturn('M'); 234 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 235 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 236 237 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 238 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 239 240 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 241 242 $this->assertSame('', $column->generate($individual, $individual)); 243 } 244 245 /** 246 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 247 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 248 */ 249 public function testChildFemale() 250 { 251 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 252 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 253 $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); 254 255 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 256 $individual->shouldReceive('getSex')->andReturn('F'); 257 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 258 $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); 259 260 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 261 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 262 263 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 264 265 $this->assertSame('', $column->generate($individual, $individual)); 266 } 267 268 /** 269 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 270 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 271 */ 272 public function testDivorcedMale() 273 { 274 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 275 276 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 277 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 278 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 279 $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 280 281 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 282 $individual->shouldReceive('getSex')->andReturn('M'); 283 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 284 285 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 286 287 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 288 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 289 290 $this->assertSame('', $column->generate($individual, $individual)); 291 } 292 293 /** 294 * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionFrenchVeuve 295 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition 296 */ 297 public function testDivorcedFemale() 298 { 299 $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); 300 301 $family = Mockery::mock('Fisharebest\Webtrees\Family'); 302 $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); 303 $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); 304 $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); 305 306 $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 307 $individual->shouldReceive('getSex')->andReturn('F'); 308 $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); 309 310 $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 311 312 $column = new CensusColumnConditionFrenchVeuve($census, '', ''); 313 $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); 314 315 $this->assertSame('', $column->generate($individual, $individual)); 316 } 317} 318