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