xref: /webtrees/tests/app/Census/CensusColumnFullNameTest.php (revision 62ff2f188c699b1144fb2ca2d6da1358d5e1a745)
1db7d25eeSGreg Roach<?php
23976b470SGreg Roach
3db7d25eeSGreg Roach/**
4db7d25eeSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify
7db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by
8db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9db7d25eeSGreg Roach * (at your option) any later version.
10db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful,
11db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13db7d25eeSGreg Roach * GNU General Public License for more details.
14db7d25eeSGreg Roach * You should have received a copy of the GNU General Public License
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16db7d25eeSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
20db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
21db7d25eeSGreg Roach
22af7ed6cbSGreg Roachuse Fisharebest\Webtrees\Date;
23af7ed6cbSGreg Roachuse Fisharebest\Webtrees\Fact;
24af7ed6cbSGreg Roachuse Fisharebest\Webtrees\Family;
25ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
263cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
2739ca88baSGreg Roachuse Illuminate\Support\Collection;
28202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
29db7d25eeSGreg Roach
30202c018bSGreg Roach
31202c018bSGreg Roach#[CoversClass(CensusColumnFullName::class)]
32202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
333cfcc809SGreg Roachclass CensusColumnFullNameTest extends TestCase
34c1010edaSGreg Roach{
35af7ed6cbSGreg Roach    public function xxxtestFullName(): void
36c1010edaSGreg Roach    {
37*62ff2f18SGreg Roach        $individual = $this->createMock(Individual::class);
380ecdbde6SGreg Roach        $individual->method('getAllNames')->willReturn([['full' => 'Joe Bloggs']]);
390ecdbde6SGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection());
40db7d25eeSGreg Roach
41*62ff2f18SGreg Roach        $census = $this->createMock(CensusInterface::class);
420ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('');
43db7d25eeSGreg Roach
44ef21b467SGreg Roach        $column = new CensusColumnFullName($census, '', '');
45db7d25eeSGreg Roach
465e933c21SGreg Roach        self::assertSame('Joe Bloggs', $column->generate($individual, $individual));
47db7d25eeSGreg Roach    }
48af7ed6cbSGreg Roach
49af7ed6cbSGreg Roach    public function testMarriedName(): void
50af7ed6cbSGreg Roach    {
51af7ed6cbSGreg Roach        $wife_names = [
52af7ed6cbSGreg Roach            ['type' => 'NAME', 'full' => 'Jane Bloggs'],
53af7ed6cbSGreg Roach            ['type' => '_MARNM', 'full' => 'Jane Smith', 'surn' => 'SMITH'],
54af7ed6cbSGreg Roach        ];
55af7ed6cbSGreg Roach
56af7ed6cbSGreg Roach        $husband_names = [
57af7ed6cbSGreg Roach            ['type' => 'NAME', 'full' => 'Joe Smith', 'surn' => 'SMITH'],
58af7ed6cbSGreg Roach        ];
59af7ed6cbSGreg Roach
60af7ed6cbSGreg Roach        $marriage_date = new Date('02 DATE 2019');
61af7ed6cbSGreg Roach
62*62ff2f18SGreg Roach        $marriage = $this->createMock(Fact::class);
63af7ed6cbSGreg Roach        $marriage->method('date')->willReturn($marriage_date);
64af7ed6cbSGreg Roach
65*62ff2f18SGreg Roach        $spouse = $this->createMock(Individual::class);
66af7ed6cbSGreg Roach        $spouse->method('getAllNames')->willReturn($husband_names);
67af7ed6cbSGreg Roach
68*62ff2f18SGreg Roach        $family = $this->createMock(Family::class);
69af7ed6cbSGreg Roach        $family->method('facts')->willReturn(new Collection([$marriage]));
70af7ed6cbSGreg Roach        $family->method('getMarriageDate')->willReturn($marriage_date);
71af7ed6cbSGreg Roach        $family->method('spouse')->willReturn($spouse);
72af7ed6cbSGreg Roach
73*62ff2f18SGreg Roach        $individual = $this->createMock(Individual::class);
74af7ed6cbSGreg Roach        $individual->method('getAllNames')->willReturn($wife_names);
75af7ed6cbSGreg Roach        $individual->method('spouseFamilies')->willReturn(new Collection([$family]));
76af7ed6cbSGreg Roach
77*62ff2f18SGreg Roach        $census = $this->createMock(CensusInterface::class);
78af7ed6cbSGreg Roach        $census->method('censusDate')->willReturn('01 JAN 2020');
79af7ed6cbSGreg Roach
80af7ed6cbSGreg Roach        $column = new CensusColumnFullName($census, '', '');
81af7ed6cbSGreg Roach
82af7ed6cbSGreg Roach        self::assertSame('Jane Smith', $column->generate($individual, $individual));
83af7ed6cbSGreg Roach    }
84db7d25eeSGreg Roach}
85