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