. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Mockery; /** * Test harness for the class CensusColumnConditionUs */ class CensusColumnConditionUsTest extends \PHPUnit_Framework_TestCase { /** * Delete mock objects */ public function tearDown() { Mockery::close(); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testNoSpouseFamiliesMale() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnConditionUs($census, '', ''); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testNoSpouseFamiliesFemale() { $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getSpouseFamilies')->andReturn([]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnConditionUs($census, '', ''); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testNoFamilyFactsMale() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); $individual->shouldReceive('getSex')->andReturn('M'); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnConditionUs($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testNoFamilyFactsFemale() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); $individual->shouldReceive('getSex')->andReturn('F'); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnConditionUs($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testSpouseDeadMale() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); $family->shouldReceive('getSpouse')->andReturn($spouse); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnConditionUs($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('W', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testSpouseDeadFemale() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $spouse = Mockery::mock('Fisharebest\Webtrees\Individual'); $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820')); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); $family->shouldReceive('getFacts')->with('DIV')->andReturn([]); $family->shouldReceive('getSpouse')->andReturn($spouse); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnConditionUs($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('W', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testNoFamilyUnmarriedMale() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnConditionUs($census, '', ''); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testNoFamilyUnmarriedFemale() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnConditionUs($census, '', ''); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testChildMale() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnConditionUs($census, '', ''); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testChildFemale() { $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820')); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $column = new CensusColumnConditionUs($census, '', ''); $this->assertSame('S', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testDivorcedMale() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('M'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnConditionUs($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('D', $column->generate($individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionUs * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition */ public function testDivorcedFemale() { $fact = Mockery::mock('Fisharebest\Webtrees\Fact'); $family = Mockery::mock('Fisharebest\Webtrees\Family'); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]); $family->shouldReceive('getFacts')->with('DIV')->andReturn([$fact]); $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); $individual->shouldReceive('getSex')->andReturn('F'); $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]); $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); $column = new CensusColumnConditionUs($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('D', $column->generate($individual)); } }