xref: /webtrees/tests/app/Census/CensusColumnYearsMarriedTest.php (revision 52348eb8c11b06a8488e13475e6561273832716a)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16namespace Fisharebest\Webtrees\Census;
17
18use Fisharebest\Webtrees\Date;
19use Mockery;
20
21/**
22 * Test harness for the class CensusColumnYearsMarried
23 */
24class CensusColumnYearsMarriedTest extends \Fisharebest\Webtrees\TestCase
25{
26    /**
27     * Delete mock objects
28     */
29    public function tearDown()
30    {
31        Mockery::close();
32    }
33
34    /**
35     * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried
36     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
37     *
38     * @return void
39     */
40    public function testNoSpouseFamily()
41    {
42        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
43        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
44
45        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
46        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
47
48        $column = new CensusColumnYearsMarried($census, '', '');
49
50        $this->assertSame('', $column->generate($individual, $individual));
51    }
52
53    /**
54     * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried
55     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
56     *
57     * @return void
58     */
59    public function testNoMarriage()
60    {
61        $family = Mockery::mock('Fisharebest\Webtrees\Family');
62        $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([]);
63
64        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
65        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
66
67        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
68        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
69
70        $column = new CensusColumnYearsMarried($census, '', '');
71
72        $this->assertSame('', $column->generate($individual, $individual));
73    }
74
75    /**
76     * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried
77     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
78     *
79     * @return void
80     */
81    public function testUndatedMarriage()
82    {
83        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
84        $fact->shouldReceive('getDate')->andReturn(new Date(''));
85
86        $family = Mockery::mock('Fisharebest\Webtrees\Family');
87        $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]);
88
89        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
90        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
91
92        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
93        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
94
95        $column = new CensusColumnYearsMarried($census, '', '');
96
97        $this->assertSame('', $column->generate($individual, $individual));
98    }
99
100    /**
101     * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried
102     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
103     *
104     * @return void
105     */
106    public function testMarriageAfterCensus()
107    {
108        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
109        $fact->shouldReceive('getDate')->andReturn(new Date('1861'));
110
111        $family = Mockery::mock('Fisharebest\Webtrees\Family');
112        $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]);
113
114        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
115        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
116
117        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
118        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
119
120        $column = new CensusColumnYearsMarried($census, '', '');
121
122        $this->assertSame('', $column->generate($individual, $individual));
123    }
124
125    /**
126     * @covers \Fisharebest\Webtrees\Census\CensusColumnYearsMarried
127     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
128     *
129     * @return void
130     */
131    public function testMarriageBeforeCensus()
132    {
133        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
134        $fact->shouldReceive('getDate')->andReturn(new Date('OCT 1851'));
135
136        $family = Mockery::mock('Fisharebest\Webtrees\Family');
137        $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]);
138
139        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
140        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
141
142        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
143        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
144
145        $column = new CensusColumnYearsMarried($census, '', '');
146
147        $this->assertSame('8', $column->generate($individual, $individual));
148    }
149}
150