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