1f3fa6d90SGreg Roach<?php 2f3fa6d90SGreg Roach/** 3f3fa6d90SGreg Roach * webtrees: online genealogy 4*8fcd0d32SGreg 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; 21f3fa6d90SGreg Roachuse Mockery; 22f3fa6d90SGreg Roach 23f3fa6d90SGreg Roach/** 24f3fa6d90SGreg Roach * Test harness for the class CensusColumnSurnameGivenNameInitial 25f3fa6d90SGreg Roach */ 2684e2cf4eSGreg Roachclass CensusColumnSurnameGivenNameInitialTest extends \Fisharebest\Webtrees\TestCase 27c1010edaSGreg Roach{ 28f3fa6d90SGreg Roach /** 29f3fa6d90SGreg Roach * Delete mock objects 3052348eb8SGreg Roach * 3152348eb8SGreg Roach * @return void 32f3fa6d90SGreg Roach */ 33c1010edaSGreg Roach public function tearDown() 34c1010edaSGreg Roach { 35f3fa6d90SGreg Roach Mockery::close(); 36f3fa6d90SGreg Roach } 37f3fa6d90SGreg Roach 38f3fa6d90SGreg Roach /** 3915d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 4015d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 4152348eb8SGreg Roach * 4252348eb8SGreg Roach * @return void 43f3fa6d90SGreg Roach */ 44c1010edaSGreg Roach public function testOneGivenName() 45c1010edaSGreg Roach { 46ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 47c1010edaSGreg Roach $individual->shouldReceive('getAllNames')->andReturn([ 48c1010edaSGreg Roach [ 49c1010edaSGreg Roach 'givn' => 'Joe', 50720f8728SGreg Roach 'surname' => 'Sixpack', 51c1010edaSGreg Roach ], 52c1010edaSGreg Roach ]); 5313abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 54f3fa6d90SGreg Roach 55ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 5609db5ef8SGreg Roach $census->shouldReceive('censusDate')->andReturn(''); 57f3fa6d90SGreg Roach 58f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 59f3fa6d90SGreg Roach 60342dcecdSGreg Roach $this->assertSame('Sixpack, Joe', $column->generate($individual, $individual)); 61f3fa6d90SGreg Roach } 62f3fa6d90SGreg Roach 63f3fa6d90SGreg Roach /** 6415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 6515d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 6652348eb8SGreg Roach * 6752348eb8SGreg Roach * @return void 68f3fa6d90SGreg Roach */ 69c1010edaSGreg Roach public function testMultipleGivenNames() 70c1010edaSGreg Roach { 71ddf438a5SGreg Roach $individual = Mockery::mock(Individual::class); 72c1010edaSGreg Roach $individual->shouldReceive('getAllNames')->andReturn([ 73c1010edaSGreg Roach [ 74c1010edaSGreg Roach 'givn' => 'Joe Fred', 75720f8728SGreg Roach 'surname' => 'Sixpack', 76c1010edaSGreg Roach ], 77c1010edaSGreg Roach ]); 7813abd6f3SGreg Roach $individual->shouldReceive('getSpouseFamilies')->andReturn([]); 79f3fa6d90SGreg Roach 80ddf438a5SGreg Roach $census = Mockery::mock(CensusInterface::class); 8109db5ef8SGreg Roach $census->shouldReceive('censusDate')->andReturn(''); 82f3fa6d90SGreg Roach 83f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 84f3fa6d90SGreg Roach 85342dcecdSGreg Roach $this->assertSame('Sixpack, Joe F', $column->generate($individual, $individual)); 86f3fa6d90SGreg Roach } 87f3fa6d90SGreg Roach} 88