xref: /webtrees/tests/app/Census/CensusColumnMarriedWithinYearTest.php (revision 3976b4703df669696105ed6b024b96d433c8fbdb)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2019 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 */
17declare(strict_types=1);
18
19namespace Fisharebest\Webtrees\Census;
20
21use Fisharebest\Webtrees\Date;
22use Fisharebest\Webtrees\Fact;
23use Fisharebest\Webtrees\Family;
24use Fisharebest\Webtrees\Individual;
25use Illuminate\Support\Collection;
26
27/**
28 * Test harness for the class CensusColumnMarriedWithinYear
29 */
30class CensusColumnMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase
31{
32    /**
33     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
34     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
35     *
36     * @return void
37     */
38    public function testMarriedWithinYear(): void
39    {
40        $fact = $this->createMock(Fact::class);
41        $fact->method('date')->willReturn(new Date('01 DEC 1859'));
42
43        $family = $this->createMock(Family::class);
44        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
45
46        $individual = $this->createMock(Individual::class);
47        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
48
49        $census = $this->createMock(CensusInterface::class);
50        $census->method('censusDate')->willReturn('01 JUN 1860');
51
52        $column = new CensusColumnMarriedWithinYear($census, '', '');
53
54        $this->assertSame('Y', $column->generate($individual, $individual));
55    }
56
57    /**
58     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
59     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
60     *
61     * @return void
62     */
63    public function testMarriedOverYearBeforeTheCensus(): void
64    {
65        $fact = $this->createMock(Fact::class);
66        $fact->method('date')->willReturn(new Date('01 JAN 1859'));
67
68        $family = $this->createMock(Family::class);
69        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
70
71        $individual = $this->createMock(Individual::class);
72        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
73
74        $census = $this->createMock(CensusInterface::class);
75        $census->method('censusDate')->willReturn('01 JUN 1860');
76
77        $column = new CensusColumnMarriedWithinYear($census, '', '');
78
79        $this->assertSame('', $column->generate($individual, $individual));
80    }
81
82    /**
83     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
84     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
85     *
86     * @return void
87     */
88    public function testMarriedAfterTheCensus(): void
89    {
90        $fact = $this->createMock(Fact::class);
91        $fact->method('date')->willReturn(new Date('02 JUN 1860'));
92
93        $family = $this->createMock(Family::class);
94        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
95
96        $individual = $this->createMock(Individual::class);
97        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
98
99        $census = $this->createMock(CensusInterface::class);
100        $census->method('censusDate')->willReturn('01 JUN 1860');
101
102        $column = new CensusColumnMarriedWithinYear($census, '', '');
103
104        $this->assertSame('', $column->generate($individual, $individual));
105    }
106
107    /**
108     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
109     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
110     *
111     * @return void
112     */
113    public function testNoMarriage(): void
114    {
115        $family = $this->createMock(Family::class);
116        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
117
118        $individual = $this->createMock(Individual::class);
119        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
120
121        $census = $this->createMock(CensusInterface::class);
122        $census->method('censusDate')->willReturn('01 JUN 1860');
123
124        $column = new CensusColumnMarriedWithinYear($census, '', '');
125
126        $this->assertSame('', $column->generate($individual, $individual));
127    }
128
129    /**
130     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
131     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
132     *
133     * @return void
134     */
135    public function testNoSpouseFamily(): void
136    {
137        $individual = $this->createMock(Individual::class);
138        $individual->method('spouseFamilies')->willReturn(new Collection());
139
140        $census = $this->createMock(CensusInterface::class);
141        $census->method('censusDate')->willReturn('01 JUN 1860');
142
143        $column = new CensusColumnMarriedWithinYear($census, '', '');
144
145        $this->assertSame('', $column->generate($individual, $individual));
146    }
147}
148