xref: /webtrees/tests/app/Census/CensusColumnConditionEnglishTest.php (revision c314ecc9a18e5e740a1c0fcb7379ef541f969dc5)
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() {
41*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
42e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
4373d4df56SGreg Roach
44*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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() {
56*c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
5773d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
58e2052359SGreg Roach		$family->shouldReceive('getFacts')->andReturn(array());
5973d4df56SGreg Roach
60*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
61e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
6273d4df56SGreg Roach
63*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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() {
76*c314ecc9SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
7773d4df56SGreg Roach
78*c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
7973d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
80e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array($fact));
8173d4df56SGreg Roach
82*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
83e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
8473d4df56SGreg Roach
85*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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() {
98*c314ecc9SGreg Roach		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
9973d4df56SGreg Roach
100*c314ecc9SGreg Roach		$family = Mockery::mock('Fisharebest\Webtrees\Family');
10173d4df56SGreg Roach		$family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
102e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('_NMR')->andReturn(array());
103e2052359SGreg Roach		$family->shouldReceive('getFacts')->with('DIV')->andReturn(array($fact));
10473d4df56SGreg Roach
105*c314ecc9SGreg Roach		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
106e2052359SGreg Roach		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
10773d4df56SGreg Roach
108*c314ecc9SGreg Roach		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
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