xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision afa67798854828b1edc33dd077960ec2b18e6140)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2021 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 <https://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 = self::createMock(Fact::class);
43        $fact->method('date')->willReturn(new Date('01 DEC 1859'));
44
45        $family = self::createMock(Family::class);
46        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
47
48        $individual = self::createMock(Individual::class);
49        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
50
51        $census = self::createMock(CensusInterface::class);
52        $census->method('censusDate')->willReturn('01 JUN 1860');
53
54        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
55
56        self::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 = self::createMock(Fact::class);
68        $fact->method('date')->willReturn(new Date('01 JAN 1859'));
69
70        $family = self::createMock(Family::class);
71        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
72
73        $individual = self::createMock(Individual::class);
74        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
75
76        $census = self::createMock(CensusInterface::class);
77        $census->method('censusDate')->willReturn('01 JUN 1860');
78
79        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
80
81        self::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 = self::createMock(Fact::class);
93        $fact->method('date')->willReturn(new Date('02 JUN 1860'));
94
95        $family = self::createMock(Family::class);
96        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
97
98        $individual = self::createMock(Individual::class);
99        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
100
101        $census = self::createMock(CensusInterface::class);
102        $census->method('censusDate')->willReturn('01 JUN 1860');
103
104        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
105
106        self::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 = self::createMock(Family::class);
118        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
119
120        $individual = self::createMock(Individual::class);
121        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
122
123        $census = self::createMock(CensusInterface::class);
124        $census->method('censusDate')->willReturn('01 JUN 1860');
125
126        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
127
128        self::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 = self::createMock(Individual::class);
140        $individual->method('spouseFamilies')->willReturn(new Collection());
141
142        $census = self::createMock(CensusInterface::class);
143        $census->method('censusDate')->willReturn('01 JUN 1860');
144
145        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
146
147        self::assertSame('', $column->generate($individual, $individual));
148    }
149}
150