1f3fa6d90SGreg Roach<?php 2f3fa6d90SGreg Roach 3f3fa6d90SGreg Roach/** 4f3fa6d90SGreg Roach * webtrees: online genealogy 5f3fa6d90SGreg Roach * Copyright (C) 2015 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 15f3fa6d90SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>. 16f3fa6d90SGreg Roach */ 17f3fa6d90SGreg Roachnamespace Fisharebest\Webtrees\Census; 18f3fa6d90SGreg Roach 19f3fa6d90SGreg Roachuse Fisharebest\Webtrees\Individual; 20f3fa6d90SGreg Roachuse Mockery; 21f3fa6d90SGreg Roach 22f3fa6d90SGreg Roach/** 23f3fa6d90SGreg Roach * Test harness for the class CensusColumnSurnameGivenNameInitial 24f3fa6d90SGreg Roach */ 25f3fa6d90SGreg Roachclass CensusColumnSurnameGivenNameInitialTest extends \PHPUnit_Framework_TestCase { 26f3fa6d90SGreg Roach /** 27f3fa6d90SGreg Roach * Delete mock objects 28f3fa6d90SGreg Roach */ 29f3fa6d90SGreg Roach public function tearDown() { 30f3fa6d90SGreg Roach Mockery::close(); 31f3fa6d90SGreg Roach } 32f3fa6d90SGreg Roach 33f3fa6d90SGreg Roach /** 34f3fa6d90SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 35f3fa6d90SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 36f3fa6d90SGreg Roach */ 37f3fa6d90SGreg Roach public function testOneGivenName() { 38*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 39e2052359SGreg Roach $individual->shouldReceive('getAllNames')->andReturn(array(array('givn' => 'Joe', 'surn' => 'Sixpack'))); 40f3fa6d90SGreg Roach 41*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 42f3fa6d90SGreg Roach 43f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 44f3fa6d90SGreg Roach 45f3fa6d90SGreg Roach $this->assertSame('Sixpack, Joe', $column->generate($individual)); 46f3fa6d90SGreg Roach } 47f3fa6d90SGreg Roach 48f3fa6d90SGreg Roach /** 49f3fa6d90SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 50f3fa6d90SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 51f3fa6d90SGreg Roach */ 52f3fa6d90SGreg Roach public function testMultipleGivenNames() { 53*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 54e2052359SGreg Roach $individual->shouldReceive('getAllNames')->andReturn(array(array('givn' => 'Joe Fred', 'surn' => 'Sixpack'))); 55f3fa6d90SGreg Roach 56*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 57f3fa6d90SGreg Roach 58f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 59f3fa6d90SGreg Roach 60f3fa6d90SGreg Roach $this->assertSame('Sixpack, Joe F', $column->generate($individual)); 61f3fa6d90SGreg Roach } 62f3fa6d90SGreg Roach 63f3fa6d90SGreg Roach /** 64f3fa6d90SGreg Roach * @covers Fisharebest\Webtrees\Census\CensusColumnSurnameGivenNameInitial 65f3fa6d90SGreg Roach * @covers Fisharebest\Webtrees\Census\AbstractCensusColumn 66f3fa6d90SGreg Roach */ 67f3fa6d90SGreg Roach public function testNoName() { 68*c314ecc9SGreg Roach $individual = Mockery::mock('Fisharebest\Webtrees\Individual'); 69e2052359SGreg Roach $individual->shouldReceive('getAllNames')->andReturn(array()); 70f3fa6d90SGreg Roach 71*c314ecc9SGreg Roach $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface'); 72f3fa6d90SGreg Roach 73f3fa6d90SGreg Roach $column = new CensusColumnSurnameGivenNameInitial($census, '', ''); 74f3fa6d90SGreg Roach 75f3fa6d90SGreg Roach $this->assertSame('', $column->generate($individual)); 76f3fa6d90SGreg Roach } 77f3fa6d90SGreg Roach} 78