xref: /webtrees/tests/app/Census/CensusColumnMotherBirthPlaceSimpleTest.php (revision c1010eda29c0909ed4d5d463f32d32bfefdd4dfe)
1a4500ed5SGreg Roach<?php
2a4500ed5SGreg Roach
3a4500ed5SGreg Roach/**
4a4500ed5SGreg Roach * webtrees: online genealogy
51062a142SGreg Roach * Copyright (C) 2018 webtrees development team
6a4500ed5SGreg Roach * This program is free software: you can redistribute it and/or modify
7a4500ed5SGreg Roach * it under the terms of the GNU General Public License as published by
8a4500ed5SGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a4500ed5SGreg Roach * (at your option) any later version.
10a4500ed5SGreg Roach * This program is distributed in the hope that it will be useful,
11a4500ed5SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a4500ed5SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a4500ed5SGreg Roach * GNU General Public License for more details.
14a4500ed5SGreg Roach * You should have received a copy of the GNU General Public License
15a4500ed5SGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16a4500ed5SGreg Roach */
17a4500ed5SGreg Roachnamespace Fisharebest\Webtrees\Census;
18a4500ed5SGreg Roach
19a4500ed5SGreg Roachuse Mockery;
20a4500ed5SGreg Roach
21a4500ed5SGreg Roach/**
22a4500ed5SGreg Roach * Test harness for the class CensusColumnMotherBirthPlaceSimple
23a4500ed5SGreg Roach */
24*c1010edaSGreg Roachclass CensusColumnMotherBirthPlaceSimpleTest extends \PHPUnit\Framework\TestCase
25*c1010edaSGreg Roach{
26a4500ed5SGreg Roach    /**
27a4500ed5SGreg Roach     * Delete mock objects
28a4500ed5SGreg Roach     */
29*c1010edaSGreg Roach    public function tearDown()
30*c1010edaSGreg Roach    {
31a4500ed5SGreg Roach        Mockery::close();
32a4500ed5SGreg Roach    }
33a4500ed5SGreg Roach
34a4500ed5SGreg Roach    /**
3516d0b7f7SRico Sonntag     * Get place mock.
3616d0b7f7SRico Sonntag     *
3716d0b7f7SRico Sonntag     * @param string $place Gedcom Place
3816d0b7f7SRico Sonntag     *
3916d0b7f7SRico Sonntag     * @return \Fisharebest\Webtrees\Place
4016d0b7f7SRico Sonntag     */
41*c1010edaSGreg Roach    private function getPlaceMock($place)
42*c1010edaSGreg Roach    {
4316d0b7f7SRico Sonntag        $placeParts = explode(', ', $place);
4416d0b7f7SRico Sonntag
4516d0b7f7SRico Sonntag        $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
4616d0b7f7SRico Sonntag        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
4716d0b7f7SRico Sonntag        $placeMock->shouldReceive('lastPart')->andReturn(end($placeParts));
4816d0b7f7SRico Sonntag
4916d0b7f7SRico Sonntag        return $placeMock;
5016d0b7f7SRico Sonntag    }
5116d0b7f7SRico Sonntag
5216d0b7f7SRico Sonntag    /**
5315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlaceSimple
5415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
55a4500ed5SGreg Roach     */
56*c1010edaSGreg Roach    public function testKnownStateAndTown()
57*c1010edaSGreg Roach    {
58c314ecc9SGreg Roach        $father = Mockery::mock('Fisharebest\Webtrees\Individual');
5916d0b7f7SRico Sonntag        $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Miami, Florida, United States'));
60a4500ed5SGreg Roach
61c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
62a4500ed5SGreg Roach        $family->shouldReceive('getWife')->andReturn($father);
63a4500ed5SGreg Roach
64c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
65a4500ed5SGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
66a4500ed5SGreg Roach
67c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
68a4500ed5SGreg Roach        $census->shouldReceive('censusPlace')->andReturn('United States');
69a4500ed5SGreg Roach
70a4500ed5SGreg Roach        $column = new CensusColumnMotherBirthPlaceSimple($census, '', '');
71a4500ed5SGreg Roach
72a4500ed5SGreg Roach        $this->assertSame('Florida', $column->generate($individual));
73a4500ed5SGreg Roach    }
74a4500ed5SGreg Roach}
75