xref: /webtrees/tests/app/Census/CensusColumnMarriedWithinYearTest.php (revision 7c7db574d0bdf9952c8ec99186bddc01aa06fd48)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2023 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 CensusColumnMarriedWithinYear
31 */
32class CensusColumnMarriedWithinYearTest extends TestCase
33{
34    /**
35     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
36     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
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        self::assertSame('Y', $column->generate($individual, $individual));
55    }
56
57    /**
58     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
59     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
60     */
61    public function testMarriedOverYearBeforeTheCensus(): void
62    {
63        $fact = $this->createMock(Fact::class);
64        $fact->method('date')->willReturn(new Date('01 JAN 1859'));
65
66        $family = $this->createMock(Family::class);
67        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
68
69        $individual = $this->createMock(Individual::class);
70        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
71
72        $census = $this->createMock(CensusInterface::class);
73        $census->method('censusDate')->willReturn('01 JUN 1860');
74
75        $column = new CensusColumnMarriedWithinYear($census, '', '');
76
77        self::assertSame('', $column->generate($individual, $individual));
78    }
79
80    /**
81     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
82     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
83     */
84    public function testMarriedAfterTheCensus(): void
85    {
86        $fact = $this->createMock(Fact::class);
87        $fact->method('date')->willReturn(new Date('02 JUN 1860'));
88
89        $family = $this->createMock(Family::class);
90        $family->method('facts')->with(['MARR'])->willReturn(new Collection([$fact]));
91
92        $individual = $this->createMock(Individual::class);
93        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
94
95        $census = $this->createMock(CensusInterface::class);
96        $census->method('censusDate')->willReturn('01 JUN 1860');
97
98        $column = new CensusColumnMarriedWithinYear($census, '', '');
99
100        self::assertSame('', $column->generate($individual, $individual));
101    }
102
103    /**
104     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
105     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
106     */
107    public function testNoMarriage(): void
108    {
109        $family = $this->createMock(Family::class);
110        $family->method('facts')->with(['MARR'])->willReturn(new Collection());
111
112        $individual = $this->createMock(Individual::class);
113        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
114
115        $census = $this->createMock(CensusInterface::class);
116        $census->method('censusDate')->willReturn('01 JUN 1860');
117
118        $column = new CensusColumnMarriedWithinYear($census, '', '');
119
120        self::assertSame('', $column->generate($individual, $individual));
121    }
122
123    /**
124     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
125     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
126     */
127    public function testNoSpouseFamily(): void
128    {
129        $individual = $this->createMock(Individual::class);
130        $individual->method('spouseFamilies')->willReturn(new Collection());
131
132        $census = $this->createMock(CensusInterface::class);
133        $census->method('censusDate')->willReturn('01 JUN 1860');
134
135        $column = new CensusColumnMarriedWithinYear($census, '', '');
136
137        self::assertSame('', $column->generate($individual, $individual));
138    }
139}
140