xref: /webtrees/tests/app/Census/CensusColumnAgeMarriedTest.php (revision fc747c0fe6ab8c4d4d65bbb60eb220a1c792d7f6)
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     * @return void
30     */
31    public function tearDown()
32    {
33        Mockery::close();
34    }
35
36    /**
37     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
38     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
39     *
40     * @return void
41     */
42    public function testAgeMarried()
43    {
44        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
45        $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
46
47        $family = Mockery::mock('Fisharebest\Webtrees\Family');
48        $family->shouldReceive('getFacts')->with('MARR', true)->andReturn([$fact]);
49
50        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
51        $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
52        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
53
54        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
55        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
56
57        $column = new CensusColumnAgeMarried($census, '', '');
58
59        $this->assertSame('19', $column->generate($individual, $individual));
60    }
61
62    /**
63     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
64     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
65     *
66     * @return void
67     */
68    public function testNoBirthDate()
69    {
70        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
71        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
72        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
73
74        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
75        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
76
77        $column = new CensusColumnAgeMarried($census, '', '');
78
79        $this->assertSame('', $column->generate($individual, $individual));
80    }
81
82    /**
83     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
84     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
85     *
86     * @return void
87     */
88    public function testNoMarriage()
89    {
90        $family = Mockery::mock('Fisharebest\Webtrees\Family');
91        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
92
93        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
94        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
95        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
96
97        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
98        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
99
100        $column = new CensusColumnAgeMarried($census, '', '');
101
102        $this->assertSame('', $column->generate($individual, $individual));
103    }
104
105    /**
106     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
107     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
108     *
109     * @return void
110     */
111    public function testNoSpouseFamily()
112    {
113        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
114        $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
115        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
116
117        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
118        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
119
120        $column = new CensusColumnAgeMarried($census, '', '');
121
122        $this->assertSame('', $column->generate($individual, $individual));
123    }
124}
125