xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision 5254a68afb63ebac346daaa82fe6970d5b34961b)
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 CensusColumnMonthIfMarriedWithinYear
23 */
24class CensusColumnMonthIfMarriedWithinYearTest 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\CensusColumnMonthIfMarriedWithinYear
36     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
37     */
38    public function testMarriedWithinYear()
39    {
40        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
41        $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
42
43        $family = Mockery::mock('Fisharebest\Webtrees\Family');
44        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
45
46        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
47        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
48
49        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
50        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
51
52        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
53
54        $this->assertSame('Dec', $column->generate($individual, $individual));
55    }
56
57    /**
58     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
59     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
60     */
61    public function testMarriedOverYearBeforeTheCensus()
62    {
63        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
64        $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859'));
65
66        $family = Mockery::mock('Fisharebest\Webtrees\Family');
67        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
68
69        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
70        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
71
72        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
73        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
74
75        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
76
77        $this->assertSame('', $column->generate($individual, $individual));
78    }
79
80    /**
81     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
82     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
83     */
84    public function testMarriedAfterTheCensus()
85    {
86        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
87        $fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860'));
88
89        $family = Mockery::mock('Fisharebest\Webtrees\Family');
90        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
91
92        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
93        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
94
95        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
96        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
97
98        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
99
100        $this->assertSame('', $column->generate($individual, $individual));
101    }
102
103    /**
104     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
105     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
106     */
107    public function testNoMarriage()
108    {
109        $family = Mockery::mock('Fisharebest\Webtrees\Family');
110        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
111
112        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
113        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
114
115        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
116        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
117
118        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
119
120        $this->assertSame('', $column->generate($individual, $individual));
121    }
122
123    /**
124     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
125     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
126     */
127    public function testNoSpouseFamily()
128    {
129        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
130        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
131
132        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
133        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
134
135        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
136
137        $this->assertSame('', $column->generate($individual, $individual));
138    }
139}
140