197a7ec96SGreg Roach<?php 23976b470SGreg Roach 397a7ec96SGreg Roach/** 497a7ec96SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 697a7ec96SGreg Roach * This program is free software: you can redistribute it and/or modify 797a7ec96SGreg Roach * it under the terms of the GNU General Public License as published by 897a7ec96SGreg Roach * the Free Software Foundation, either version 3 of the License, or 997a7ec96SGreg Roach * (at your option) any later version. 1097a7ec96SGreg Roach * This program is distributed in the hope that it will be useful, 1197a7ec96SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 1297a7ec96SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1397a7ec96SGreg Roach * GNU General Public License for more details. 1497a7ec96SGreg 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/>. 1697a7ec96SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 2097a7ec96SGreg Roachnamespace Fisharebest\Webtrees\Census; 2197a7ec96SGreg Roach 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 233cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 2439ca88baSGreg Roachuse Illuminate\Support\Collection; 25*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 2697a7ec96SGreg Roach 27*202c018bSGreg Roach#[CoversClass(CensusColumnSurnameGivenNames::class)] 28*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 293cfcc809SGreg Roachclass CensusColumnSurnameGivenNamesTest extends TestCase 30c1010edaSGreg Roach{ 319b802b22SGreg Roach public function testOneGivenName(): void 32c1010edaSGreg Roach { 33cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 340ecdbde6SGreg Roach $individual->method('getAllNames')->willReturn([ 35c1010edaSGreg Roach [ 36c1010edaSGreg Roach 'givn' => 'Joe', 37720f8728SGreg Roach 'surname' => 'Sixpack', 38c1010edaSGreg Roach ], 39c1010edaSGreg Roach ]); 400ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 4197a7ec96SGreg Roach 42cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 430ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 4497a7ec96SGreg Roach 4597a7ec96SGreg Roach $column = new CensusColumnSurnameGivenNames($census, '', ''); 4697a7ec96SGreg Roach 475e933c21SGreg Roach self::assertSame('Sixpack, Joe', $column->generate($individual, $individual)); 4897a7ec96SGreg Roach } 4997a7ec96SGreg Roach 509b802b22SGreg Roach public function testMultipleGivenNames(): void 51c1010edaSGreg Roach { 52cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 530ecdbde6SGreg Roach $individual->method('getAllNames')->willReturn([ 54c1010edaSGreg Roach [ 55c1010edaSGreg Roach 'givn' => 'Joe Fred', 56720f8728SGreg Roach 'surname' => 'Sixpack', 57c1010edaSGreg Roach ], 58c1010edaSGreg Roach ]); 590ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 6097a7ec96SGreg Roach 61cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 620ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 6397a7ec96SGreg Roach 6497a7ec96SGreg Roach $column = new CensusColumnSurnameGivenNames($census, '', ''); 6597a7ec96SGreg Roach 665e933c21SGreg Roach self::assertSame('Sixpack, Joe Fred', $column->generate($individual, $individual)); 6797a7ec96SGreg Roach } 6897a7ec96SGreg Roach 699b802b22SGreg Roach public function testNoName(): void 70c1010edaSGreg Roach { 71cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 7213488723SDavid Drury $individual->method('getAllNames')->willReturn([ 7313488723SDavid Drury [ 748fb4e87cSGreg Roach 'givn' => Individual::PRAENOMEN_NESCIO, 758fb4e87cSGreg Roach 'surname' => Individual::NOMEN_NESCIO, 768fb4e87cSGreg Roach ], 7713488723SDavid Drury ]); 780ecdbde6SGreg Roach $individual->method('spouseFamilies')->willReturn(new Collection()); 7997a7ec96SGreg Roach 80cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 810ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 8297a7ec96SGreg Roach 8397a7ec96SGreg Roach $column = new CensusColumnSurnameGivenNames($census, '', ''); 8497a7ec96SGreg Roach 855e933c21SGreg Roach self::assertSame('…, …', $column->generate($individual, $individual)); 8697a7ec96SGreg Roach } 8797a7ec96SGreg Roach} 88