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