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#[CoversClass(CensusColumnFullName::class)] 31202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 323cfcc809SGreg Roachclass CensusColumnFullNameTest extends TestCase 33c1010edaSGreg Roach{ 34af7ed6cbSGreg Roach public function xxxtestFullName(): void 35c1010edaSGreg Roach { 36*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 370ecdbde6SGreg Roach $individual->method('getAllNames')->willReturn([['full' => 'Joe Bloggs']]); 380ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 39db7d25eeSGreg Roach 40*62ff2f18SGreg Roach $census = $this->createMock(CensusInterface::class); 410ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 42db7d25eeSGreg Roach 43ef21b467SGreg Roach $column = new CensusColumnFullName($census, '', ''); 44db7d25eeSGreg Roach 455e933c21SGreg Roach self::assertSame('Joe Bloggs', $column->generate($individual, $individual)); 46db7d25eeSGreg Roach } 47af7ed6cbSGreg Roach 48af7ed6cbSGreg Roach public function testMarriedName(): void 49af7ed6cbSGreg Roach { 50af7ed6cbSGreg Roach $wife_names = [ 51af7ed6cbSGreg Roach ['type' => 'NAME', 'full' => 'Jane Bloggs'], 52af7ed6cbSGreg Roach ['type' => '_MARNM', 'full' => 'Jane Smith', 'surn' => 'SMITH'], 53af7ed6cbSGreg Roach ]; 54af7ed6cbSGreg Roach 55af7ed6cbSGreg Roach $husband_names = [ 56af7ed6cbSGreg Roach ['type' => 'NAME', 'full' => 'Joe Smith', 'surn' => 'SMITH'], 57af7ed6cbSGreg Roach ]; 58af7ed6cbSGreg Roach 59af7ed6cbSGreg Roach $marriage_date = new Date('02 DATE 2019'); 60af7ed6cbSGreg Roach 61*62ff2f18SGreg Roach $marriage = $this->createMock(Fact::class); 62af7ed6cbSGreg Roach $marriage->method('date')->willReturn($marriage_date); 63af7ed6cbSGreg Roach 64*62ff2f18SGreg Roach $spouse = $this->createMock(Individual::class); 65af7ed6cbSGreg Roach $spouse->method('getAllNames')->willReturn($husband_names); 66af7ed6cbSGreg Roach 67*62ff2f18SGreg Roach $family = $this->createMock(Family::class); 68af7ed6cbSGreg Roach $family->method('facts')->willReturn(new Collection([$marriage])); 69af7ed6cbSGreg Roach $family->method('getMarriageDate')->willReturn($marriage_date); 70af7ed6cbSGreg Roach $family->method('spouse')->willReturn($spouse); 71af7ed6cbSGreg Roach 72*62ff2f18SGreg Roach $individual = $this->createMock(Individual::class); 73af7ed6cbSGreg Roach $individual->method('getAllNames')->willReturn($wife_names); 74af7ed6cbSGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 75af7ed6cbSGreg Roach 76*62ff2f18SGreg Roach $census = $this->createMock(CensusInterface::class); 77af7ed6cbSGreg Roach $census->method('censusDate')->willReturn('01 JAN 2020'); 78af7ed6cbSGreg Roach 79af7ed6cbSGreg Roach $column = new CensusColumnFullName($census, '', ''); 80af7ed6cbSGreg Roach 81af7ed6cbSGreg Roach self::assertSame('Jane Smith', $column->generate($individual, $individual)); 82af7ed6cbSGreg Roach } 83db7d25eeSGreg Roach} 84