xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision 73df4c545c87012519818766e1a8eb02272a59b5)
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 CensusColumnMonthIfMarriedWithinYear
24 */
25class CensusColumnMonthIfMarriedWithinYearTest 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\CensusColumnMonthIfMarriedWithinYear
35	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
36	 */
37	public function testMarriedWithinYear() {
38		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
39		$fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
40
41		$family = Mockery::mock('Fisharebest\Webtrees\Family');
42		$family->shouldReceive('getFacts')->with('MARR')->andReturn(array($fact));
43
44		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
45		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
46
47		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
48		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
49
50		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
51
52		$this->assertSame('Dec', $column->generate($individual));
53	}
54
55	/**
56	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
57	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
58	 */
59	public function testNotMarriedWithinYear() {
60		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
61		$fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859'));
62
63		$family = Mockery::mock('Fisharebest\Webtrees\Family');
64		$family->shouldReceive('getFacts')->with('MARR')->andReturn(array($fact));
65
66		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
67		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
68
69		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
70		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
71
72		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
73
74		$this->assertSame('', $column->generate($individual));
75	}
76
77	/**
78	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
79	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
80	 */
81	public function testNoMarriage() {
82		$family = Mockery::mock('Fisharebest\Webtrees\Family');
83		$family->shouldReceive('getFacts')->with('MARR')->andReturn(array());
84
85		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
86		$individual->shouldReceive('getSpouseFamilies')->andReturn(array($family));
87
88		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
89		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
90
91		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
92
93		$this->assertSame('', $column->generate($individual));
94	}
95
96	/**
97	 * @covers Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
98	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
99	 */
100	public function testNoSpouseFamily() {
101		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
102		$individual->shouldReceive('getSpouseFamilies')->andReturn(array());
103
104		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
105		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
106
107		$column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
108
109		$this->assertSame('', $column->generate($individual));
110	}
111}
112