1f3fa6d90SGreg Roach<?php 2f3fa6d90SGreg Roach/** 3f3fa6d90SGreg Roach * webtrees: online genealogy 48fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team 5f3fa6d90SGreg Roach * This program is free software: you can redistribute it and/or modify 6f3fa6d90SGreg Roach * it under the terms of the GNU General Public License as published by 7f3fa6d90SGreg Roach * the Free Software Foundation, either version 3 of the License, or 8f3fa6d90SGreg Roach * (at your option) any later version. 9f3fa6d90SGreg Roach * This program is distributed in the hope that it will be useful, 10f3fa6d90SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 11f3fa6d90SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12f3fa6d90SGreg Roach * GNU General Public License for more details. 13f3fa6d90SGreg Roach * You should have received a copy of the GNU General Public License 14f3fa6d90SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 15f3fa6d90SGreg Roach */ 16e7f56f2aSGreg Roachdeclare(strict_types=1); 17e7f56f2aSGreg Roach 18f3fa6d90SGreg Roachnamespace Fisharebest\Webtrees\Census; 19f3fa6d90SGreg Roach 20ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 21*39ca88baSGreg Roachuse Illuminate\Support\Collection; 22f3fa6d90SGreg Roachuse Mockery; 23f3fa6d90SGreg Roach 24f3fa6d90SGreg Roach/** 25f3fa6d90SGreg Roach * Test harness for the class CensusColumnSurnameGivenNameInitial 26f3fa6d90SGreg Roach */ 2784e2cf4eSGreg Roachclass CensusColumnSurnameGivenNameInitialTest extends \Fisharebest\Webtrees\TestCase 28c1010edaSGreg Roach{ 29f3fa6d90SGreg Roach /** 30f3fa6d90SGreg Roach * Delete mock objects 3152348eb8SGreg Roach * 3252348eb8SGreg Roach * @return void 33f3fa6d90SGreg Roach */ 34c1010edaSGreg Roach public function tearDown() 35c1010edaSGreg Roach { 36f3fa6d90SGreg Roach Mockery::close(); 37f3fa6d90SGreg Roach } 38f3fa6d90SGreg Roach 39f3fa6d90SGreg Roach /** 4015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 4115d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 4252348eb8SGreg Roach * 4352348eb8SGreg Roach * @return void 44f3fa6d90SGreg Roach */ 459b802b22SGreg Roach public function testOneGivenName(): void 46c1010edaSGreg Roach { 47ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 48c1010edaSGreg Roach $individual->shouldReceive('getAllNames')->andReturn([ 49c1010edaSGreg Roach [ 50c1010edaSGreg Roach 'givn' => 'Joe', 51720f8728SGreg Roach 'surname' => 'Sixpack', 52c1010edaSGreg Roach ], 53c1010edaSGreg Roach ]); 54*39ca88baSGreg Roach $individual->shouldReceive('spouseFamilies')->andReturn(new Collection()); 55f3fa6d90SGreg Roach 56ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 5709db5ef8SGreg Roach $census->shouldReceive('censusDate')->andReturn(''); 58f3fa6d90SGreg Roach 59f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 60f3fa6d90SGreg Roach 61342dcecdSGreg Roach $this->assertSame('Sixpack, Joe', $column->generate($individual, $individual)); 62f3fa6d90SGreg Roach } 63f3fa6d90SGreg Roach 64f3fa6d90SGreg Roach /** 6515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 6615d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 6752348eb8SGreg Roach * 6852348eb8SGreg Roach * @return void 69f3fa6d90SGreg Roach */ 709b802b22SGreg Roach public function testMultipleGivenNames(): void 71c1010edaSGreg Roach { 72ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 73c1010edaSGreg Roach $individual->shouldReceive('getAllNames')->andReturn([ 74c1010edaSGreg Roach [ 75c1010edaSGreg Roach 'givn' => 'Joe Fred', 76720f8728SGreg Roach 'surname' => 'Sixpack', 77c1010edaSGreg Roach ], 78c1010edaSGreg Roach ]); 79*39ca88baSGreg Roach $individual->shouldReceive('spouseFamilies')->andReturn(new Collection()); 80f3fa6d90SGreg Roach 81ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 8209db5ef8SGreg Roach $census->shouldReceive('censusDate')->andReturn(''); 83f3fa6d90SGreg Roach 84f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 85f3fa6d90SGreg Roach 86342dcecdSGreg Roach $this->assertSame('Sixpack, Joe F', $column->generate($individual, $individual)); 87f3fa6d90SGreg Roach } 88f3fa6d90SGreg Roach} 89