xref: /webtrees/tests/app/Census/CensusColumnBirthPlaceTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2018 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16namespace Fisharebest\Webtrees\Census;
17
18use Mockery;
19
20/**
21 * Test harness for the class CensusColumnBirthPlace
22 */
23class CensusColumnBirthPlaceTest extends \Fisharebest\Webtrees\TestCase
24{
25    /**
26     * Delete mock objects
27     */
28    public function tearDown()
29    {
30        Mockery::close();
31    }
32
33    /**
34     * Get place mock.
35     *
36     * @param string $place Gedcom Place
37     *
38     * @return \Fisharebest\Webtrees\Place
39     */
40    private function getPlaceMock($place): \Fisharebest\Webtrees\Place
41    {
42        $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
43        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
44
45        return $placeMock;
46    }
47
48    /**
49     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace
50     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
51     */
52    public function testPlaceCountry()
53    {
54        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
55        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Westminster, London, England'));
56
57        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
58        $census->shouldReceive('censusPlace')->andReturn('England');
59
60        $column = new CensusColumnBirthPlace($census, '', '');
61
62        $this->assertSame('Westminster, London', $column->generate($individual, $individual));
63    }
64
65    /**
66     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace
67     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
68     */
69    public function testPlaceAndCountry()
70    {
71        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
72        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('England'));
73
74        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
75        $census->shouldReceive('censusPlace')->andReturn('England');
76
77        $column = new CensusColumnBirthPlace($census, '', '');
78
79        $this->assertSame('', $column->generate($individual, $individual));
80    }
81
82    /**
83     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlace
84     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
85     */
86    public function testDifferentCountry()
87    {
88        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
89        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Paris, France'));
90
91        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
92        $census->shouldReceive('censusPlace')->andReturn('England');
93
94        $column = new CensusColumnBirthPlace($census, '', '');
95
96        $this->assertSame('Paris, France', $column->generate($individual, $individual));
97    }
98}
99