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