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