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