. */ namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Date; use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Family; use Fisharebest\Webtrees\Individual; use Mockery; /** * Test harness for the class CensusColumnConditionEnglish */ class CensusColumnConditionEnglishTest extends \PHPUnit_Framework_TestCase { /** * Delete mock objects */ public function tearDown() { Mockery::close(); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoSpouseFamilies() { $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn(array()); $census = Mockery::mock(CensusInterface::class); $column = new CensusColumnConditionEnglish($census, '', ''); $this->assertSame('Unm', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoFamilyNoFacts() { $family = Mockery::mock(Family::class); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->andReturn(array()); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); $census = Mockery::mock(CensusInterface::class); $column = new CensusColumnConditionEnglish($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('Mar', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoFamilyUnmarried() { $fact = Mockery::mock(Fact::class); $family = Mockery::mock(Family::class); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact)); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); $census = Mockery::mock(CensusInterface::class); $column = new CensusColumnConditionEnglish($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('Unm', $column->generate($individual)); } /** * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn */ public function testNoFamilyDivorced() { $fact = Mockery::mock(Fact::class); $family = Mockery::mock(Family::class); $family->shouldReceive('getMarriageDate')->andReturn(new Date('')); $family->shouldReceive('getFacts')->with('_NMR')->andReturn(array()); $family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact)); $individual = Mockery::mock(Individual::class); $individual->shouldReceive('getSpouseFamilies')->andReturn(array($family)); $census = Mockery::mock(CensusInterface::class); $column = new CensusColumnConditionEnglish($census, '', ''); $census->shouldReceive('censusDate')->andReturn('30 JUN 1830'); $this->assertSame('Div', $column->generate($individual)); } }