xref: /webtrees/tests/app/Census/CensusColumnMotherForeignTest.php (revision 8fcd0d32e56ee262912bbdb593202cfd1cbc1615)
1a53db70dSGreg Roach<?php
2a53db70dSGreg Roach/**
3a53db70dSGreg Roach * webtrees: online genealogy
4*8fcd0d32SGreg Roach * Copyright (C) 2019 webtrees development team
5a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify
6a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by
7a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or
8a53db70dSGreg Roach * (at your option) any later version.
9a53db70dSGreg Roach * This program is distributed in the hope that it will be useful,
10a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
11a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12a53db70dSGreg Roach * GNU General Public License for more details.
13a53db70dSGreg Roach * You should have received a copy of the GNU General Public License
14a53db70dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
15a53db70dSGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
18a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census;
19a53db70dSGreg Roach
20ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
21ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
2252348eb8SGreg Roachuse Fisharebest\Webtrees\Place;
23a53db70dSGreg Roachuse Mockery;
24a53db70dSGreg Roach
25a53db70dSGreg Roach/**
26a53db70dSGreg Roach * Test harness for the class CensusColumnMotherForeign
27a53db70dSGreg Roach */
2884e2cf4eSGreg Roachclass CensusColumnMotherForeignTest extends \Fisharebest\Webtrees\TestCase
29c1010edaSGreg Roach{
30a53db70dSGreg Roach    /**
31a53db70dSGreg Roach     * Delete mock objects
3252348eb8SGreg Roach     *
3352348eb8SGreg Roach     * @return void
34a53db70dSGreg Roach     */
35c1010edaSGreg Roach    public function tearDown()
36c1010edaSGreg Roach    {
37a53db70dSGreg Roach        Mockery::close();
38a53db70dSGreg Roach    }
39a53db70dSGreg Roach
40a53db70dSGreg Roach    /**
4116d0b7f7SRico Sonntag     * Get place mock.
4216d0b7f7SRico Sonntag     *
4316d0b7f7SRico Sonntag     * @param string $place Gedcom Place
4416d0b7f7SRico Sonntag     *
4552348eb8SGreg Roach     * @return Place
4616d0b7f7SRico Sonntag     */
4752348eb8SGreg Roach    private function getPlaceMock($place): Place
48c1010edaSGreg Roach    {
49ddf438a5SGreg Roach        $placeMock = Mockery::mock(Place::class);
5016d0b7f7SRico Sonntag        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
5116d0b7f7SRico Sonntag
5216d0b7f7SRico Sonntag        return $placeMock;
5316d0b7f7SRico Sonntag    }
5416d0b7f7SRico Sonntag
5516d0b7f7SRico Sonntag    /**
5615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
5715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
5852348eb8SGreg Roach     *
5952348eb8SGreg Roach     * @return void
60a53db70dSGreg Roach     */
61c1010edaSGreg Roach    public function testSameCountry()
62c1010edaSGreg Roach    {
63ddf438a5SGreg Roach        $mother = Mockery::mock(Individual::class);
6416d0b7f7SRico Sonntag        $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
65a53db70dSGreg Roach
66ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
67a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn($mother);
68a53db70dSGreg Roach
69ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
70a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
71a53db70dSGreg Roach
72ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
73a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
74a53db70dSGreg Roach
75a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
76a53db70dSGreg Roach
77342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
78a53db70dSGreg Roach    }
79a53db70dSGreg Roach
80a53db70dSGreg Roach    /**
8115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
8215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
8352348eb8SGreg Roach     *
8452348eb8SGreg Roach     * @return void
85a53db70dSGreg Roach     */
86c1010edaSGreg Roach    public function testDifferentCountry()
87c1010edaSGreg Roach    {
88ddf438a5SGreg Roach        $mother = Mockery::mock(Individual::class);
8916d0b7f7SRico Sonntag        $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
90a53db70dSGreg Roach
91ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
92a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn($mother);
93a53db70dSGreg Roach
94ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
95a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
96a53db70dSGreg Roach
97ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
98a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('Ireland');
99a53db70dSGreg Roach
100a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
101a53db70dSGreg Roach
102342dcecdSGreg Roach        $this->assertSame('Y', $column->generate($individual, $individual));
103a53db70dSGreg Roach    }
104a53db70dSGreg Roach
105a53db70dSGreg Roach    /**
10615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
10715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
10852348eb8SGreg Roach     *
10952348eb8SGreg Roach     * @return void
110a53db70dSGreg Roach     */
111c1010edaSGreg Roach    public function testPlaceNoParent()
112c1010edaSGreg Roach    {
113ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
114a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn(null);
115a53db70dSGreg Roach
116ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
117a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
118a53db70dSGreg Roach
119ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
120a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
121a53db70dSGreg Roach
122a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
123a53db70dSGreg Roach
124342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
125a53db70dSGreg Roach    }
126a53db70dSGreg Roach
127a53db70dSGreg Roach    /**
12815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
12915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
13052348eb8SGreg Roach     *
13152348eb8SGreg Roach     * @return void
132a53db70dSGreg Roach     */
133c1010edaSGreg Roach    public function testPlaceNoParentFamily()
134c1010edaSGreg Roach    {
135ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
136a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null);
137a53db70dSGreg Roach
138ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
139a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
140a53db70dSGreg Roach
141a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
142a53db70dSGreg Roach
143342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
144a53db70dSGreg Roach    }
145a53db70dSGreg Roach}
146