xref: /webtrees/tests/app/Census/CensusColumnConditionDanishTest.php (revision 52bcc40297e06e51c5cc74d5ddd66c750aefef51)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Census;
19
20use Fisharebest\Webtrees\Date;
21use Fisharebest\Webtrees\Fact;
22use Fisharebest\Webtrees\Family;
23use Fisharebest\Webtrees\Individual;
24use Mockery;
25
26/**
27 * Test harness for the class CensusColumnConditionDanish
28 */
29class CensusColumnConditionDanishTest extends \Fisharebest\Webtrees\TestCase
30{
31    /**
32     * Delete mock objects
33     *
34     * @return void
35     */
36    public function tearDown()
37    {
38        Mockery::close();
39    }
40
41    /**
42     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
43     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
44     *
45     * @return void
46     */
47    public function testNoSpouseFamiliesMale(): void
48    {
49        $individual = Mockery::mock(Individual::class);
50        $individual->shouldReceive('getSex')->andReturn('M');
51        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
52        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
53
54        $census = Mockery::mock(CensusInterface::class);
55        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
56
57        $column = new CensusColumnConditionDanish($census, '', '');
58
59        $this->assertSame('Ugift', $column->generate($individual, $individual));
60    }
61
62    /**
63     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
64     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
65     *
66     * @return void
67     */
68    public function testNoSpouseFamiliesFemale(): void
69    {
70        $individual = Mockery::mock(Individual::class);
71        $individual->shouldReceive('getSex')->andReturn('F');
72        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
73        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
74
75        $census = Mockery::mock(CensusInterface::class);
76        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
77
78        $column = new CensusColumnConditionDanish($census, '', '');
79
80        $this->assertSame('Ugift', $column->generate($individual, $individual));
81    }
82
83    /**
84     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
85     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
86     *
87     * @return void
88     */
89    public function testNoFamilyFactsMale(): void
90    {
91        $family = Mockery::mock(Family::class);
92        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
93        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
94
95        $individual = Mockery::mock(Individual::class);
96        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
97        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
98        $individual->shouldReceive('getSex')->andReturn('M');
99
100        $census = Mockery::mock(CensusInterface::class);
101
102        $column = new CensusColumnConditionDanish($census, '', '');
103        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
104
105        $this->assertSame('Ugift', $column->generate($individual, $individual));
106    }
107
108    /**
109     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
110     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
111     *
112     * @return void
113     */
114    public function testNoFamilyFactsFemale(): void
115    {
116        $family = Mockery::mock(Family::class);
117        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
118        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
119
120        $individual = Mockery::mock(Individual::class);
121        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
122        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
123        $individual->shouldReceive('getSex')->andReturn('F');
124
125        $census = Mockery::mock(CensusInterface::class);
126
127        $column = new CensusColumnConditionDanish($census, '', '');
128        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
129
130        $this->assertSame('Ugift', $column->generate($individual, $individual));
131    }
132
133    /**
134     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
135     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
136     *
137     * @return void
138     */
139    public function testSpouseDeadMale(): void
140    {
141        $fact = Mockery::mock(Fact::class);
142
143        $spouse = Mockery::mock(Individual::class);
144        $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
145
146        $family = Mockery::mock(Family::class);
147        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
148        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
149        $family->shouldReceive('facts')->with(['DIV'])->andReturn([]);
150        $family->shouldReceive('getSpouse')->andReturn($spouse);
151
152        $individual = Mockery::mock(Individual::class);
153        $individual->shouldReceive('getSex')->andReturn('M');
154        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
155
156        $census = Mockery::mock(CensusInterface::class);
157
158        $column = new CensusColumnConditionDanish($census, '', '');
159        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
160
161        $this->assertSame('Gift', $column->generate($individual, $individual));
162    }
163
164    /**
165     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
166     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
167     *
168     * @return void
169     */
170    public function testSpouseDeadFemale(): void
171    {
172        $fact = Mockery::mock(Fact::class);
173
174        $spouse = Mockery::mock(Individual::class);
175        $spouse->shouldReceive('getDeathDate')->andReturn(new Date('1820'));
176
177        $family = Mockery::mock(Family::class);
178        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
179        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
180        $family->shouldReceive('facts')->with(['DIV'])->andReturn([]);
181        $family->shouldReceive('getSpouse')->andReturn($spouse);
182
183        $individual = Mockery::mock(Individual::class);
184        $individual->shouldReceive('getSex')->andReturn('F');
185        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
186
187        $census = Mockery::mock(CensusInterface::class);
188
189        $column = new CensusColumnConditionDanish($census, '', '');
190        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
191
192        $this->assertSame('Gift', $column->generate($individual, $individual));
193    }
194
195    /**
196     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
197     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
198     *
199     * @return void
200     */
201    public function testNoFamilyUnmarriedMale(): void
202    {
203        $family = Mockery::mock(Family::class);
204        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
205        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
206
207        $individual = Mockery::mock(Individual::class);
208        $individual->shouldReceive('getSex')->andReturn('M');
209        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
210        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
211
212        $census = Mockery::mock(CensusInterface::class);
213        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
214
215        $column = new CensusColumnConditionDanish($census, '', '');
216
217        $this->assertSame('Ugift', $column->generate($individual, $individual));
218    }
219
220    /**
221     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
222     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
223     *
224     * @return void
225     */
226    public function testNoFamilyUnmarriedFemale(): void
227    {
228        $family = Mockery::mock(Family::class);
229        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
230        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
231
232        $individual = Mockery::mock(Individual::class);
233        $individual->shouldReceive('getSex')->andReturn('F');
234        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
235        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1800'));
236
237        $census = Mockery::mock(CensusInterface::class);
238        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
239
240        $column = new CensusColumnConditionDanish($census, '', '');
241
242        $this->assertSame('Ugift', $column->generate($individual, $individual));
243    }
244
245    /**
246     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
247     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
248     *
249     * @return void
250     */
251    public function testChildMale(): void
252    {
253        $family = Mockery::mock(Family::class);
254        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
255        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
256
257        $individual = Mockery::mock(Individual::class);
258        $individual->shouldReceive('getSex')->andReturn('M');
259        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
260        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
261
262        $census = Mockery::mock(CensusInterface::class);
263        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
264
265        $column = new CensusColumnConditionDanish($census, '', '');
266
267        $this->assertSame('', $column->generate($individual, $individual));
268    }
269
270    /**
271     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
272     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
273     *
274     * @return void
275     */
276    public function testChildFemale(): void
277    {
278        $family = Mockery::mock(Family::class);
279        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
280        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
281
282        $individual = Mockery::mock(Individual::class);
283        $individual->shouldReceive('getSex')->andReturn('F');
284        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
285        $individual->shouldReceive('getEstimatedBirthDate')->andReturn(new Date('1820'));
286
287        $census = Mockery::mock(CensusInterface::class);
288        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
289
290        $column = new CensusColumnConditionDanish($census, '', '');
291
292        $this->assertSame('', $column->generate($individual, $individual));
293    }
294
295    /**
296     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
297     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
298     *
299     * @return void
300     */
301    public function testDivorcedMale(): void
302    {
303        $fact = Mockery::mock(Fact::class);
304
305        $family = Mockery::mock(Family::class);
306        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
307        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
308        $family->shouldReceive('facts')->with(['DIV'])->andReturn([$fact]);
309
310        $individual = Mockery::mock(Individual::class);
311        $individual->shouldReceive('getSex')->andReturn('M');
312        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
313
314        $census = Mockery::mock(CensusInterface::class);
315
316        $column = new CensusColumnConditionDanish($census, '', '');
317        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
318
319        $this->assertSame('Skilt', $column->generate($individual, $individual));
320    }
321
322    /**
323     * @covers \Fisharebest\Webtrees\Census\CensusColumnConditionDanish
324     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumnCondition
325     *
326     * @return void
327     */
328    public function testDivorcedFemale(): void
329    {
330        $fact = Mockery::mock(Fact::class);
331
332        $family = Mockery::mock(Family::class);
333        $family->shouldReceive('getMarriageDate')->andReturn(new Date(''));
334        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
335        $family->shouldReceive('facts')->with(['DIV'])->andReturn([$fact]);
336
337        $individual = Mockery::mock(Individual::class);
338        $individual->shouldReceive('getSex')->andReturn('F');
339        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
340
341        $census = Mockery::mock(CensusInterface::class);
342
343        $column = new CensusColumnConditionDanish($census, '', '');
344        $census->shouldReceive('censusDate')->andReturn('30 JUN 1830');
345
346        $this->assertSame('Skilt', $column->generate($individual, $individual));
347    }
348}
349