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