xref: /webtrees/tests/app/Census/CensusColumnFullNameTest.php (revision dbfc3863950ec8bae86dadccc2608863d6ffb574)
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 CensusColumnFullName
31 */
32class CensusColumnFullNameTest extends TestCase
33{
34    /**
35     * @covers \Fisharebest\Webtrees\Census\CensusColumnFullName
36     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
37     *
38     * @return void
39     */
40    public function xxxtestFullName(): void
41    {
42        $individual = $this->createStub(Individual::class);
43        $individual->method('getAllNames')->willReturn([['full' => 'Joe Bloggs']]);
44        $individual->method('spouseFamilies')->willReturn(new Collection());
45
46        $census = $this->createStub(CensusInterface::class);
47        $census->method('censusDate')->willReturn('');
48
49        $column = new CensusColumnFullName($census, '', '');
50
51        self::assertSame('Joe Bloggs', $column->generate($individual, $individual));
52    }
53
54    /**
55     * @covers \Fisharebest\Webtrees\Census\CensusColumnFullName
56     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
57     *
58     * @return void
59     */
60    public function testMarriedName(): void
61    {
62        $wife_names = [
63            ['type' => 'NAME', 'full' => 'Jane Bloggs'],
64            ['type' => '_MARNM', 'full' => 'Jane Smith', 'surn' => 'SMITH'],
65        ];
66
67        $husband_names = [
68            ['type' => 'NAME', 'full' => 'Joe Smith', 'surn' => 'SMITH'],
69        ];
70
71        $marriage_date = new Date('02 DATE 2019');
72
73        $marriage = $this->createStub(Fact::class);
74        $marriage->method('date')->willReturn($marriage_date);
75
76        $spouse = $this->createStub(Individual::class);
77        $spouse->method('getAllNames')->willReturn($husband_names);
78
79        $family = $this->createStub(Family::class);
80        $family->method('facts')->willReturn(new Collection([$marriage]));
81        $family->method('getMarriageDate')->willReturn($marriage_date);
82        $family->method('spouse')->willReturn($spouse);
83
84        $individual = $this->createStub(Individual::class);
85        $individual->method('getAllNames')->willReturn($wife_names);
86        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
87
88        $census = $this->createStub(CensusInterface::class);
89        $census->method('censusDate')->willReturn('01 JAN 2020');
90
91        $column = new CensusColumnFullName($census, '', '');
92
93        self::assertSame('Jane Smith', $column->generate($individual, $individual));
94    }
95}
96