xref: /webtrees/tests/app/Census/CensusColumnMarriedWithinYearTest.php (revision 8e2171fe0219e8c030e0832b6bca4eb535e71337)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2015 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 */
17
18namespace Fisharebest\Webtrees\Census;
19
20use Fisharebest\Localization\Translator;
21use Fisharebest\Webtrees\Date;
22use Fisharebest\Webtrees\Fact;
23use Fisharebest\Webtrees\Family;
24use Fisharebest\Webtrees\I18N;
25use Fisharebest\Webtrees\Individual;
26use Mockery;
27
28/**
29 * Test harness for the class CensusColumnMarriedWithinYear
30 */
31class CensusColumnMarriedWithinYearTest extends \PHPUnit_Framework_TestCase {
32	/**
33	 * Delete mock objects
34	 */
35	public function tearDown() {
36		Mockery::close();
37	}
38
39	/**
40	 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
41	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
42	 */
43	public function testMarriedWithinYear() {
44		$fact = Mockery::mock(Fact::class);
45		$fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
46
47		$family = Mockery::mock(Family::class);
48		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
49
50		$individual = Mockery::mock(Individual::class);
51		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
52
53		$census = Mockery::mock(CensusInterface::class);
54		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
55
56		$column = new CensusColumnMarriedWithinYear($census, '', '');
57
58		$this->assertSame('Y', $column->generate($individual));
59	}
60
61	/**
62	 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
63	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
64	 */
65	public function testNotMarriedWithinYear() {
66		$fact = Mockery::mock(Fact::class);
67		$fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859'));
68
69		$family = Mockery::mock(Family::class);
70		$family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
71
72		$individual = Mockery::mock(Individual::class);
73		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
74
75		$census = Mockery::mock(CensusInterface::class);
76		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
77
78		$column = new CensusColumnMarriedWithinYear($census, '', '');
79
80		$this->assertSame('', $column->generate($individual));
81	}
82
83	/**
84	 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
85	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
86	 */
87	public function testNoMarriage() {
88		$family = Mockery::mock(Family::class);
89		$family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
90
91		$individual = Mockery::mock(Individual::class);
92		$individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
93
94		$census = Mockery::mock(CensusInterface::class);
95		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
96
97		$column = new CensusColumnMarriedWithinYear($census, '', '');
98
99		$this->assertSame('', $column->generate($individual));
100	}
101
102	/**
103	 * @covers Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
104	 * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn
105	 */
106	public function testNoSpouseFamily() {
107		$individual = Mockery::mock(Individual::class);
108		$individual->shouldReceive('getSpouseFamilies')->andReturn([]);
109
110		$census = Mockery::mock(CensusInterface::class);
111		$census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
112
113		$column = new CensusColumnMarriedWithinYear($census, '', '');
114
115		$this->assertSame('', $column->generate($individual));
116	}
117}
118