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