xref: /webtrees/tests/app/Census/CensusColumnAgeMarriedTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
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 CensusColumnAgeMarried
23 */
24class CensusColumnAgeMarriedTest 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\CensusColumnAgeMarried
36     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
37     */
38    public function testAgeMarried()
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', true)->andReturn([$fact]);
45
46        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
47        $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
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 CensusColumnAgeMarried($census, '', '');
54
55        $this->assertSame('19', $column->generate($individual, $individual));
56    }
57
58    /**
59     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
60     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
61     */
62    public function testNoBirthDate()
63    {
64        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
65        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
66        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
67
68        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
69        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
70
71        $column = new CensusColumnAgeMarried($census, '', '');
72
73        $this->assertSame('', $column->generate($individual, $individual));
74    }
75
76    /**
77     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
78     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
79     */
80    public function testNoMarriage()
81    {
82        $family = Mockery::mock('Fisharebest\Webtrees\Family');
83        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
84
85        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
86        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
87        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
88
89        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
90        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
91
92        $column = new CensusColumnAgeMarried($census, '', '');
93
94        $this->assertSame('', $column->generate($individual, $individual));
95    }
96
97    /**
98     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
99     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
100     */
101    public function testNoSpouseFamily()
102    {
103        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
104        $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
105        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
106
107        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
108        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
109
110        $column = new CensusColumnAgeMarried($census, '', '');
111
112        $this->assertSame('', $column->generate($individual, $individual));
113    }
114}
115