xref: /webtrees/tests/app/Census/CensusColumnBirthPlaceSimpleTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
1a4500ed5SGreg Roach<?php
2a4500ed5SGreg Roach/**
3a4500ed5SGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
5a4500ed5SGreg Roach * This program is free software: you can redistribute it and/or modify
6a4500ed5SGreg Roach * it under the terms of the GNU General Public License as published by
7a4500ed5SGreg Roach * the Free Software Foundation, either version 3 of the License, or
8a4500ed5SGreg Roach * (at your option) any later version.
9a4500ed5SGreg Roach * This program is distributed in the hope that it will be useful,
10a4500ed5SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11a4500ed5SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12a4500ed5SGreg Roach * GNU General Public License for more details.
13a4500ed5SGreg Roach * You should have received a copy of the GNU General Public License
14a4500ed5SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15a4500ed5SGreg Roach */
16a4500ed5SGreg Roachnamespace Fisharebest\Webtrees\Census;
17a4500ed5SGreg Roach
18a4500ed5SGreg Roachuse Mockery;
19a4500ed5SGreg Roach
20a4500ed5SGreg Roach/**
21a4500ed5SGreg Roach * Test harness for the class CensusColumnBirthPlaceSimple
22a4500ed5SGreg Roach */
23*84e2cf4eSGreg Roachclass CensusColumnBirthPlaceSimpleTest extends \Fisharebest\Webtrees\TestCase
24c1010edaSGreg Roach{
25a4500ed5SGreg Roach    /**
26a4500ed5SGreg Roach     * Delete mock objects
27a4500ed5SGreg Roach     */
28c1010edaSGreg Roach    public function tearDown()
29c1010edaSGreg Roach    {
30a4500ed5SGreg Roach        Mockery::close();
31a4500ed5SGreg Roach    }
32a4500ed5SGreg Roach
33a4500ed5SGreg Roach    /**
3416d0b7f7SRico Sonntag     * Get place mock.
3516d0b7f7SRico Sonntag     *
3616d0b7f7SRico Sonntag     * @param string $place Gedcom Place
3716d0b7f7SRico Sonntag     *
3816d0b7f7SRico Sonntag     * @return \Fisharebest\Webtrees\Place
3916d0b7f7SRico Sonntag     */
408f53f488SRico Sonntag    private function getPlaceMock($place): \Fisharebest\Webtrees\Place
41c1010edaSGreg Roach    {
4216d0b7f7SRico Sonntag        $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
4316d0b7f7SRico Sonntag        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
4416d0b7f7SRico Sonntag
4516d0b7f7SRico Sonntag        return $placeMock;
4616d0b7f7SRico Sonntag    }
4716d0b7f7SRico Sonntag
4816d0b7f7SRico Sonntag    /**
4915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
5015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
51a4500ed5SGreg Roach     */
52c1010edaSGreg Roach    public function testForeignCountry()
53c1010edaSGreg Roach    {
54c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
5516d0b7f7SRico Sonntag        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Westminster, London, England'));
56a4500ed5SGreg Roach
57c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
58a4500ed5SGreg Roach        $census->shouldReceive('censusPlace')->andReturn('United States');
59a4500ed5SGreg Roach
60a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
61a4500ed5SGreg Roach
62342dcecdSGreg Roach        $this->assertSame('England', $column->generate($individual, $individual));
63a4500ed5SGreg Roach    }
64a4500ed5SGreg Roach
65a4500ed5SGreg Roach    /**
6615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
6715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
68a4500ed5SGreg Roach     */
69c1010edaSGreg Roach    public function testJustCountry()
70c1010edaSGreg Roach    {
71c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
7216d0b7f7SRico Sonntag        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('United States'));
73a4500ed5SGreg Roach
74c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
75a4500ed5SGreg Roach        $census->shouldReceive('censusPlace')->andReturn('United States');
76a4500ed5SGreg Roach
77a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
78a4500ed5SGreg Roach
79342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
80a4500ed5SGreg Roach    }
81a4500ed5SGreg Roach
82a4500ed5SGreg Roach    /**
8315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
8415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
85a4500ed5SGreg Roach     */
86c1010edaSGreg Roach    public function testKnownState()
87c1010edaSGreg Roach    {
88c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
8916d0b7f7SRico Sonntag        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Maryland, United States'));
90a4500ed5SGreg Roach
91c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
92a4500ed5SGreg Roach        $census->shouldReceive('censusPlace')->andReturn('United States');
93a4500ed5SGreg Roach
94a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
95a4500ed5SGreg Roach
96342dcecdSGreg Roach        $this->assertSame('Maryland', $column->generate($individual, $individual));
97a4500ed5SGreg Roach    }
98a4500ed5SGreg Roach
99a4500ed5SGreg Roach    /**
10015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
10115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
102a4500ed5SGreg Roach     */
103c1010edaSGreg Roach    public function testKnownStateAndTown()
104c1010edaSGreg Roach    {
105c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10616d0b7f7SRico Sonntag        $individual->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Miami, Florida, United States'));
107a4500ed5SGreg Roach
108c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
109a4500ed5SGreg Roach        $census->shouldReceive('censusPlace')->andReturn('United States');
110a4500ed5SGreg Roach
111a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
112a4500ed5SGreg Roach
113342dcecdSGreg Roach        $this->assertSame('Florida', $column->generate($individual, $individual));
114a4500ed5SGreg Roach    }
115a4500ed5SGreg Roach}
116