xref: /webtrees/tests/app/Census/CensusColumnSurnameTest.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
1a53db70dSGreg Roach<?php
2a53db70dSGreg Roach/**
3a53db70dSGreg Roach * webtrees: online genealogy
4*8fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
5a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify
6a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by
7a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or
8a53db70dSGreg Roach * (at your option) any later version.
9a53db70dSGreg Roach * This program is distributed in the hope that it will be useful,
10a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12a53db70dSGreg Roach * GNU General Public License for more details.
13a53db70dSGreg Roach * You should have received a copy of the GNU General Public License
14a53db70dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15a53db70dSGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
18a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census;
19a53db70dSGreg Roach
20ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
21a53db70dSGreg Roachuse Mockery;
22a53db70dSGreg Roach
23a53db70dSGreg Roach/**
24a53db70dSGreg Roach * Test harness for the class CensusColumnSurname
25a53db70dSGreg Roach */
2684e2cf4eSGreg Roachclass CensusColumnSurnameTest extends \Fisharebest\Webtrees\TestCase
27c1010edaSGreg Roach{
28a53db70dSGreg Roach    /**
29a53db70dSGreg Roach     * Delete mock objects
3052348eb8SGreg Roach     *
3152348eb8SGreg Roach     * @return void
32a53db70dSGreg Roach     */
33c1010edaSGreg Roach    public function tearDown()
34c1010edaSGreg Roach    {
35a53db70dSGreg Roach        Mockery::close();
36a53db70dSGreg Roach    }
37a53db70dSGreg Roach
38a53db70dSGreg Roach    /**
3915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnSurname
4015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
4152348eb8SGreg Roach     *
4252348eb8SGreg Roach     * @return void
43a53db70dSGreg Roach     */
44c1010edaSGreg Roach    public function testSurname()
45c1010edaSGreg Roach    {
46ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
4713abd6f3SGreg Roach        $individual->shouldReceive('getAllNames')->andReturn([['surname' => 'Bloggs']]);
48a53db70dSGreg Roach
49ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
50a53db70dSGreg Roach
51a53db70dSGreg Roach        $column = new CensusColumnSurname($census, '', '');
52a53db70dSGreg Roach
53342dcecdSGreg Roach        $this->assertSame('Bloggs', $column->generate($individual, $individual));
54a53db70dSGreg Roach    }
55a53db70dSGreg Roach
56a53db70dSGreg Roach    /**
5715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnSurname
5815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
5952348eb8SGreg Roach     *
6052348eb8SGreg Roach     * @return void
61a53db70dSGreg Roach     */
62c1010edaSGreg Roach    public function testNoName()
63c1010edaSGreg Roach    {
64ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
6513abd6f3SGreg Roach        $individual->shouldReceive('getAllNames')->andReturn([]);
66a53db70dSGreg Roach
67ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
68a53db70dSGreg Roach
69a53db70dSGreg Roach        $column = new CensusColumnSurname($census, '', '');
70a53db70dSGreg Roach
71342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
72a53db70dSGreg Roach    }
73a53db70dSGreg Roach}
74