xref: /webtrees/tests/app/Census/CensusColumnMotherBirthPlaceSimpleTest.php (revision 52348eb8c11b06a8488e13475e6561273832716a)
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
18*52348eb8SGreg Roachuse Fisharebest\Webtrees\Place;
19a4500ed5SGreg Roachuse Mockery;
20a4500ed5SGreg Roach
21a4500ed5SGreg Roach/**
22a4500ed5SGreg Roach * Test harness for the class CensusColumnMotherBirthPlaceSimple
23a4500ed5SGreg Roach */
2484e2cf4eSGreg Roachclass CensusColumnMotherBirthPlaceSimpleTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
26a4500ed5SGreg Roach    /**
27a4500ed5SGreg Roach     * Delete mock objects
28*52348eb8SGreg Roach     *
29*52348eb8SGreg Roach     * @return void
30a4500ed5SGreg Roach     */
31c1010edaSGreg Roach    public function tearDown()
32c1010edaSGreg Roach    {
33a4500ed5SGreg Roach        Mockery::close();
34a4500ed5SGreg Roach    }
35a4500ed5SGreg Roach
36a4500ed5SGreg Roach    /**
3716d0b7f7SRico Sonntag     * Get place mock.
3816d0b7f7SRico Sonntag     *
3916d0b7f7SRico Sonntag     * @param string $place Gedcom Place
4016d0b7f7SRico Sonntag     *
41*52348eb8SGreg Roach     * @return Place
4216d0b7f7SRico Sonntag     */
43*52348eb8SGreg Roach    private function getPlaceMock($place): Place
44c1010edaSGreg Roach    {
4516d0b7f7SRico Sonntag        $placeParts = explode(', ', $place);
4616d0b7f7SRico Sonntag
4716d0b7f7SRico Sonntag        $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
4816d0b7f7SRico Sonntag        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
4916d0b7f7SRico Sonntag        $placeMock->shouldReceive('lastPart')->andReturn(end($placeParts));
5016d0b7f7SRico Sonntag
5116d0b7f7SRico Sonntag        return $placeMock;
5216d0b7f7SRico Sonntag    }
5316d0b7f7SRico Sonntag
5416d0b7f7SRico Sonntag    /**
5515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherBirthPlaceSimple
5615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
57*52348eb8SGreg Roach     *
58*52348eb8SGreg Roach     * @return void
59a4500ed5SGreg Roach     */
60c1010edaSGreg Roach    public function testKnownStateAndTown()
61c1010edaSGreg Roach    {
62c314ecc9SGreg Roach        $father = Mockery::mock('Fisharebest\Webtrees\Individual');
6316d0b7f7SRico Sonntag        $father->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('Miami, Florida, United States'));
64a4500ed5SGreg Roach
65c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
66a4500ed5SGreg Roach        $family->shouldReceive('getWife')->andReturn($father);
67a4500ed5SGreg Roach
68c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
69a4500ed5SGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
70a4500ed5SGreg Roach
71c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
72a4500ed5SGreg Roach        $census->shouldReceive('censusPlace')->andReturn('United States');
73a4500ed5SGreg Roach
74a4500ed5SGreg Roach        $column = new CensusColumnMotherBirthPlaceSimple($census, '', '');
75a4500ed5SGreg Roach
76342dcecdSGreg Roach        $this->assertSame('Florida', $column->generate($individual, $individual));
77a4500ed5SGreg Roach    }
78a4500ed5SGreg Roach}
79