xref: /webtrees/tests/app/Census/CensusColumnMarriedWithinYearTest.php (revision 0a016d046f63b3b1ece7ec913216782c17f0cbad)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2017 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 CensusColumnMarriedWithinYear
24 */
25class CensusColumnMarriedWithinYearTest 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\CensusColumnMarriedWithinYear
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([$fact]);
43
44		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
45		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
46
47		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
48		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
49
50		$column = new CensusColumnMarriedWithinYear($census, '', '');
51
52		$this->assertSame('Y', $column->generate($individual));
53	}
54
55	/**
56	 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
57	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
58	 */
59	public function testMarriedOverYearBeforeTheCensus() {
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([$fact]);
65
66		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
67		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
68
69		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
70		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
71
72		$column = new CensusColumnMarriedWithinYear($census, '', '');
73
74		$this->assertSame('', $column->generate($individual));
75	}
76
77	/**
78	 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
79	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
80	 */
81	public function testMarriedAfterTheCensus() {
82		$fact = Mockery::mock('Fisharebest\Webtrees\Fact');
83		$fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860'));
84
85		$family = Mockery::mock('Fisharebest\Webtrees\Family');
86		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
87
88		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
89		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
90
91		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
92		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
93
94		$column = new CensusColumnMarriedWithinYear($census, '', '');
95
96		$this->assertSame('', $column->generate($individual));
97	}
98
99	/**
100	 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
101	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
102	 */
103	public function testNoMarriage() {
104		$family = Mockery::mock('Fisharebest\Webtrees\Family');
105		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
106
107		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
108		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
109
110		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
111		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
112
113		$column = new CensusColumnMarriedWithinYear($census, '', '');
114
115		$this->assertSame('', $column->generate($individual));
116	}
117
118	/**
119	 * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
120	 * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
121	 */
122	public function testNoSpouseFamily() {
123		$individual = Mockery::mock('Fisharebest\Webtrees\Individual');
124		$individual->shouldReceive('getSpouseFamilies')->andReturn([]);
125
126		$census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
127		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
128
129		$column = new CensusColumnMarriedWithinYear($census, '', '');
130
131		$this->assertSame('', $column->generate($individual));
132	}
133}
134