xref: /webtrees/tests/app/Census/CensusColumnMotherForeignTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
1a53db70dSGreg Roach<?php
2a53db70dSGreg Roach/**
3a53db70dSGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 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 */
16a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census;
17a53db70dSGreg Roach
18a53db70dSGreg Roachuse Mockery;
19a53db70dSGreg Roach
20a53db70dSGreg Roach/**
21a53db70dSGreg Roach * Test harness for the class CensusColumnMotherForeign
22a53db70dSGreg Roach */
23*84e2cf4eSGreg Roachclass CensusColumnMotherForeignTest extends \Fisharebest\Webtrees\TestCase
24c1010edaSGreg Roach{
25a53db70dSGreg Roach    /**
26a53db70dSGreg Roach     * Delete mock objects
27a53db70dSGreg Roach     */
28c1010edaSGreg Roach    public function tearDown()
29c1010edaSGreg Roach    {
30a53db70dSGreg Roach        Mockery::close();
31a53db70dSGreg Roach    }
32a53db70dSGreg Roach
33a53db70dSGreg 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\CensusColumnMotherForeign
5015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
51a53db70dSGreg Roach     */
52c1010edaSGreg Roach    public function testSameCountry()
53c1010edaSGreg Roach    {
54c314ecc9SGreg Roach        $mother = Mockery::mock('Fisharebest\Webtrees\Individual');
5516d0b7f7SRico Sonntag        $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
56a53db70dSGreg Roach
57c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
58a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn($mother);
59a53db70dSGreg Roach
60c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
61a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
62a53db70dSGreg Roach
63c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
64a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
65a53db70dSGreg Roach
66a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
67a53db70dSGreg Roach
68342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
69a53db70dSGreg Roach    }
70a53db70dSGreg Roach
71a53db70dSGreg Roach    /**
7215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
7315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
74a53db70dSGreg Roach     */
75c1010edaSGreg Roach    public function testDifferentCountry()
76c1010edaSGreg Roach    {
77c314ecc9SGreg Roach        $mother = Mockery::mock('Fisharebest\Webtrees\Individual');
7816d0b7f7SRico Sonntag        $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
79a53db70dSGreg Roach
80c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
81a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn($mother);
82a53db70dSGreg Roach
83c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
84a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
85a53db70dSGreg Roach
86c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
87a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('Ireland');
88a53db70dSGreg Roach
89a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
90a53db70dSGreg Roach
91342dcecdSGreg Roach        $this->assertSame('Y', $column->generate($individual, $individual));
92a53db70dSGreg Roach    }
93a53db70dSGreg Roach
94a53db70dSGreg Roach    /**
9515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
9615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
97a53db70dSGreg Roach     */
98c1010edaSGreg Roach    public function testPlaceNoParent()
99c1010edaSGreg Roach    {
100c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
101a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn(null);
102a53db70dSGreg Roach
103c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
104a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
105a53db70dSGreg Roach
106c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
107a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
108a53db70dSGreg Roach
109a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
110a53db70dSGreg Roach
111342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
112a53db70dSGreg Roach    }
113a53db70dSGreg Roach
114a53db70dSGreg Roach    /**
11515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
11615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
117a53db70dSGreg Roach     */
118c1010edaSGreg Roach    public function testPlaceNoParentFamily()
119c1010edaSGreg Roach    {
120c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
121a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null);
122a53db70dSGreg Roach
123c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
124a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
125a53db70dSGreg Roach
126a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
127a53db70dSGreg Roach
128342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
129a53db70dSGreg Roach    }
130a53db70dSGreg Roach}
131