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