xref: /webtrees/tests/app/Census/CensusColumnBirthPlaceSimpleTest.php (revision 3976b4703df669696105ed6b024b96d433c8fbdb)
1a4500ed5SGreg Roach<?php
2*3976b470SGreg Roach
3a4500ed5SGreg Roach/**
4a4500ed5SGreg Roach * webtrees: online genealogy
58fcd0d32SGreg Roach * Copyright (C) 2019 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 */
17e7f56f2aSGreg Roachdeclare(strict_types=1);
18e7f56f2aSGreg Roach
19a4500ed5SGreg Roachnamespace Fisharebest\Webtrees\Census;
20a4500ed5SGreg Roach
21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
2252348eb8SGreg Roachuse Fisharebest\Webtrees\Place;
23a4500ed5SGreg Roach
24a4500ed5SGreg Roach/**
25a4500ed5SGreg Roach * Test harness for the class CensusColumnBirthPlaceSimple
26a4500ed5SGreg Roach */
2784e2cf4eSGreg Roachclass CensusColumnBirthPlaceSimpleTest extends \Fisharebest\Webtrees\TestCase
28c1010edaSGreg Roach{
29a4500ed5SGreg Roach    /**
3016d0b7f7SRico Sonntag     * Get place mock.
3116d0b7f7SRico Sonntag     *
3216d0b7f7SRico Sonntag     * @param string $place Gedcom Place
3316d0b7f7SRico Sonntag     *
3452348eb8SGreg Roach     * @return Place
3516d0b7f7SRico Sonntag     */
3652348eb8SGreg Roach    private function getPlaceMock($place): Place
37c1010edaSGreg Roach    {
380ecdbde6SGreg Roach        $placeMock = $this->createMock(Place::class);
390ecdbde6SGreg Roach        $placeMock->method('gedcomName')->willReturn($place);
4016d0b7f7SRico Sonntag
4116d0b7f7SRico Sonntag        return $placeMock;
4216d0b7f7SRico Sonntag    }
4316d0b7f7SRico Sonntag
4416d0b7f7SRico Sonntag    /**
4515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
4615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
4752348eb8SGreg Roach     *
4852348eb8SGreg Roach     * @return void
49a4500ed5SGreg Roach     */
509b802b22SGreg Roach    public function testForeignCountry(): void
51c1010edaSGreg Roach    {
520ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
530ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Westminster, London, England'));
54a4500ed5SGreg Roach
550ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
560ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('United States');
57a4500ed5SGreg Roach
58a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
59a4500ed5SGreg Roach
60342dcecdSGreg Roach        $this->assertSame('England', $column->generate($individual, $individual));
61a4500ed5SGreg Roach    }
62a4500ed5SGreg Roach
63a4500ed5SGreg Roach    /**
6415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
6515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6652348eb8SGreg Roach     *
6752348eb8SGreg Roach     * @return void
68a4500ed5SGreg Roach     */
699b802b22SGreg Roach    public function testJustCountry(): void
70c1010edaSGreg Roach    {
710ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
720ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('United States'));
73a4500ed5SGreg Roach
740ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
750ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('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
8552348eb8SGreg Roach     *
8652348eb8SGreg Roach     * @return void
87a4500ed5SGreg Roach     */
889b802b22SGreg Roach    public function testKnownState(): void
89c1010edaSGreg Roach    {
900ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
910ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Maryland, United States'));
92a4500ed5SGreg Roach
930ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
940ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('United States');
95a4500ed5SGreg Roach
96a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
97a4500ed5SGreg Roach
98342dcecdSGreg Roach        $this->assertSame('Maryland', $column->generate($individual, $individual));
99a4500ed5SGreg Roach    }
100a4500ed5SGreg Roach
101a4500ed5SGreg Roach    /**
10215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnBirthPlaceSimple
10315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
10452348eb8SGreg Roach     *
10552348eb8SGreg Roach     * @return void
106a4500ed5SGreg Roach     */
1079b802b22SGreg Roach    public function testKnownStateAndTown(): void
108c1010edaSGreg Roach    {
1090ecdbde6SGreg Roach        $individual = $this->createMock(Individual::class);
1100ecdbde6SGreg Roach        $individual->method('getBirthPlace')->willReturn($this->getPlaceMock('Miami, Florida, United States'));
111a4500ed5SGreg Roach
1120ecdbde6SGreg Roach        $census = $this->createMock(CensusInterface::class);
1130ecdbde6SGreg Roach        $census->method('censusPlace')->willReturn('United States');
114a4500ed5SGreg Roach
115a4500ed5SGreg Roach        $column = new CensusColumnBirthPlaceSimple($census, '', '');
116a4500ed5SGreg Roach
117342dcecdSGreg Roach        $this->assertSame('Florida', $column->generate($individual, $individual));
118a4500ed5SGreg Roach    }
119a4500ed5SGreg Roach}
120