1db7d25eeSGreg Roach<?php 23976b470SGreg Roach 3db7d25eeSGreg Roach/** 4db7d25eeSGreg Roach * webtrees: online genealogy 5*d11be702SGreg 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; 28db7d25eeSGreg Roach 29db7d25eeSGreg Roach/** 30db7d25eeSGreg Roach * Test harness for the class CensusColumnFullName 31db7d25eeSGreg Roach */ 323cfcc809SGreg Roachclass CensusColumnFullNameTest extends TestCase 33c1010edaSGreg Roach{ 34db7d25eeSGreg Roach /** 3515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFullName 3615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3752348eb8SGreg Roach * 3852348eb8SGreg Roach * @return void 39db7d25eeSGreg Roach */ 40af7ed6cbSGreg Roach public function xxxtestFullName(): void 41c1010edaSGreg Roach { 42ede12dd7SGreg Roach $individual = $this->createStub(Individual::class); 430ecdbde6SGreg Roach $individual->method('getAllNames')->willReturn([['full' => 'Joe Bloggs']]); 440ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 45db7d25eeSGreg Roach 46ede12dd7SGreg Roach $census = $this->createStub(CensusInterface::class); 470ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 48db7d25eeSGreg Roach 49ef21b467SGreg Roach $column = new CensusColumnFullName($census, '', ''); 50db7d25eeSGreg Roach 515e933c21SGreg Roach self::assertSame('Joe Bloggs', $column->generate($individual, $individual)); 52db7d25eeSGreg Roach } 53af7ed6cbSGreg Roach 54af7ed6cbSGreg Roach /** 55af7ed6cbSGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnFullName 56af7ed6cbSGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 57af7ed6cbSGreg Roach * 58af7ed6cbSGreg Roach * @return void 59af7ed6cbSGreg Roach */ 60af7ed6cbSGreg Roach public function testMarriedName(): void 61af7ed6cbSGreg Roach { 62af7ed6cbSGreg Roach $wife_names = [ 63af7ed6cbSGreg Roach ['type' => 'NAME', 'full' => 'Jane Bloggs'], 64af7ed6cbSGreg Roach ['type' => '_MARNM', 'full' => 'Jane Smith', 'surn' => 'SMITH'], 65af7ed6cbSGreg Roach ]; 66af7ed6cbSGreg Roach 67af7ed6cbSGreg Roach $husband_names = [ 68af7ed6cbSGreg Roach ['type' => 'NAME', 'full' => 'Joe Smith', 'surn' => 'SMITH'], 69af7ed6cbSGreg Roach ]; 70af7ed6cbSGreg Roach 71af7ed6cbSGreg Roach $marriage_date = new Date('02 DATE 2019'); 72af7ed6cbSGreg Roach 73ede12dd7SGreg Roach $marriage = $this->createStub(Fact::class); 74af7ed6cbSGreg Roach $marriage->method('date')->willReturn($marriage_date); 75af7ed6cbSGreg Roach 76ede12dd7SGreg Roach $spouse = $this->createStub(Individual::class); 77af7ed6cbSGreg Roach $spouse->method('getAllNames')->willReturn($husband_names); 78af7ed6cbSGreg Roach 79ede12dd7SGreg Roach $family = $this->createStub(Family::class); 80af7ed6cbSGreg Roach $family->method('facts')->willReturn(new Collection([$marriage])); 81af7ed6cbSGreg Roach $family->method('getMarriageDate')->willReturn($marriage_date); 82af7ed6cbSGreg Roach $family->method('spouse')->willReturn($spouse); 83af7ed6cbSGreg Roach 84ede12dd7SGreg Roach $individual = $this->createStub(Individual::class); 85af7ed6cbSGreg Roach $individual->method('getAllNames')->willReturn($wife_names); 86af7ed6cbSGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection([$family])); 87af7ed6cbSGreg Roach 88ede12dd7SGreg Roach $census = $this->createStub(CensusInterface::class); 89af7ed6cbSGreg Roach $census->method('censusDate')->willReturn('01 JAN 2020'); 90af7ed6cbSGreg Roach 91af7ed6cbSGreg Roach $column = new CensusColumnFullName($census, '', ''); 92af7ed6cbSGreg Roach 93af7ed6cbSGreg Roach self::assertSame('Jane Smith', $column->generate($individual, $individual)); 94af7ed6cbSGreg Roach } 95db7d25eeSGreg Roach} 96