xref: /webtrees/tests/app/Census/CensusColumnConditionEnglishTest.php (revision e20523594b1c9198044ea2549fd5fab80283ede4)
173d4df56SGreg Roach<?php
273d4df56SGreg Roach
373d4df56SGreg Roach/**
473d4df56SGreg Roach * webtrees: online genealogy
573d4df56SGreg Roach * Copyright (C) 2015 webtrees development team
673d4df56SGreg Roach * This program is free software: you can redistribute it and/or modify
773d4df56SGreg Roach * it under the terms of the GNU General Public License as published by
873d4df56SGreg Roach * the Free Software Foundation, either version 3 of the License, or
973d4df56SGreg Roach * (at your option) any later version.
1073d4df56SGreg Roach * This program is distributed in the hope that it will be useful,
1173d4df56SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1273d4df56SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1373d4df56SGreg Roach * GNU General Public License for more details.
1473d4df56SGreg Roach * You should have received a copy of the GNU General Public License
1573d4df56SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1673d4df56SGreg Roach */
1773d4df56SGreg Roachnamespace Fisharebest\Webtrees\Census;
1873d4df56SGreg Roach
1973d4df56SGreg Roachuse Fisharebest\Webtrees\Date;
2073d4df56SGreg Roachuse Fisharebest\Webtrees\Fact;
2173d4df56SGreg Roachuse Fisharebest\Webtrees\Family;
2273d4df56SGreg Roachuse Fisharebest\Webtrees\Individual;
2373d4df56SGreg Roachuse Mockery;
2473d4df56SGreg Roach
2573d4df56SGreg Roach/**
2673d4df56SGreg Roach * Test harness for the class CensusColumnConditionEnglish
2773d4df56SGreg Roach */
2873d4df56SGreg Roachclass CensusColumnConditionEnglishTest extends \PHPUnit_Framework_TestCase {
2973d4df56SGreg Roach	/**
3073d4df56SGreg Roach	 * Delete mock objects
3173d4df56SGreg Roach	 */
3273d4df56SGreg Roach	public function tearDown() {
3373d4df56SGreg Roach		Mockery::close();
3473d4df56SGreg Roach	}
3573d4df56SGreg Roach
3673d4df56SGreg Roach	/**
3773d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish
3873d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
3973d4df56SGreg Roach	 */
4073d4df56SGreg Roach	public function testNoSpouseFamilies() {
4173d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
42*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
4373d4df56SGreg Roach
4473d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
4573d4df56SGreg Roach
4673d4df56SGreg Roach		$column = new CensusColumnConditionEnglish($census, '', '');
4773d4df56SGreg Roach
4873d4df56SGreg Roach		$this->assertSame('Unm', $column->generate($individual));
4973d4df56SGreg Roach	}
5073d4df56SGreg Roach
5173d4df56SGreg Roach	/**
5273d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish
5373d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
5473d4df56SGreg Roach	 */
5573d4df56SGreg Roach	public function testNoFamilyNoFacts() {
5673d4df56SGreg Roach		$family = Mockery::mock(Family::class);
5773d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
58*e2052359SGreg Roach		$family->shouldReceive('getFacts')->andReturn(array());
5973d4df56SGreg Roach
6073d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
61*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
6273d4df56SGreg Roach
6373d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
6473d4df56SGreg Roach
6573d4df56SGreg Roach		$column = new CensusColumnConditionEnglish($census, '', '');
6673d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
6773d4df56SGreg Roach
6873d4df56SGreg Roach		$this->assertSame('Mar', $column->generate($individual));
6973d4df56SGreg Roach	}
7073d4df56SGreg Roach
7173d4df56SGreg Roach	/**
7273d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish
7373d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
7473d4df56SGreg Roach	 */
7573d4df56SGreg Roach	public function testNoFamilyUnmarried() {
7673d4df56SGreg Roach		$fact = Mockery::mock(Fact::class);
7773d4df56SGreg Roach
7873d4df56SGreg Roach		$family = Mockery::mock(Family::class);
7973d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
80*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
8173d4df56SGreg Roach
8273d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
83*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
8473d4df56SGreg Roach
8573d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
8673d4df56SGreg Roach
8773d4df56SGreg Roach		$column = new CensusColumnConditionEnglish($census, '', '');
8873d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
8973d4df56SGreg Roach
9073d4df56SGreg Roach		$this->assertSame('Unm', $column->generate($individual));
9173d4df56SGreg Roach	}
9273d4df56SGreg Roach
9373d4df56SGreg Roach	/**
9473d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\CensusColumnConditionEnglish
9573d4df56SGreg Roach	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
9673d4df56SGreg Roach	 */
9773d4df56SGreg Roach	public function testNoFamilyDivorced() {
9873d4df56SGreg Roach		$fact = Mockery::mock(Fact::class);
9973d4df56SGreg Roach
10073d4df56SGreg Roach		$family = Mockery::mock(Family::class);
10173d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
102*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array());
103*e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact));
10473d4df56SGreg Roach
10573d4df56SGreg Roach		$individual = Mockery::mock(Individual::class);
106*e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
10773d4df56SGreg Roach
10873d4df56SGreg Roach		$census = Mockery::mock(CensusInterface::class);
10973d4df56SGreg Roach
11073d4df56SGreg Roach		$column = new CensusColumnConditionEnglish($census, '', '');
11173d4df56SGreg Roach		$census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
11273d4df56SGreg Roach
11373d4df56SGreg Roach		$this->assertSame('Div', $column->generate($individual));
11473d4df56SGreg Roach	}
11573d4df56SGreg Roach}
116