1f3fa6d90SGreg Roach<?php 23976b470SGreg Roach 3f3fa6d90SGreg Roach/** 4f3fa6d90SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 6f3fa6d90SGreg Roach * This program is free software: you can redistribute it and/or modify 7f3fa6d90SGreg Roach * it under the terms of the GNU General Public License as published by 8f3fa6d90SGreg Roach * the Free Software Foundation, either version 3 of the License, or 9f3fa6d90SGreg Roach * (at your option) any later version. 10f3fa6d90SGreg Roach * This program is distributed in the hope that it will be useful, 11f3fa6d90SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 12f3fa6d90SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13f3fa6d90SGreg Roach * GNU General Public License for more details. 14f3fa6d90SGreg 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/>. 16f3fa6d90SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 20f3fa6d90SGreg Roachnamespace Fisharebest\Webtrees\Census; 21f3fa6d90SGreg Roach 22ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 233cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 2439ca88baSGreg Roachuse Illuminate\Support\Collection; 25*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 26f3fa6d90SGreg Roach 27*202c018bSGreg Roach#[CoversClass(CensusColumnSurnameGivenNameInitial::class)] 28*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 293cfcc809SGreg Roachclass CensusColumnSurnameGivenNameInitialTest 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()); 41f3fa6d90SGreg Roach 42cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 430ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 44f3fa6d90SGreg Roach 45f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 46f3fa6d90SGreg Roach 475e933c21SGreg Roach self::assertSame('Sixpack, Joe', $column->generate($individual, $individual)); 48f3fa6d90SGreg Roach } 49f3fa6d90SGreg 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()); 60f3fa6d90SGreg Roach 61cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 620ecdbde6SGreg Roach $census->method('censusDate')->willReturn(''); 63f3fa6d90SGreg Roach 64f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 65f3fa6d90SGreg Roach 665e933c21SGreg Roach self::assertSame('Sixpack, Joe F', $column->generate($individual, $individual)); 67f3fa6d90SGreg Roach } 68f3fa6d90SGreg Roach} 69