xref: /webtrees/tests/app/Census/CensusColumnMotherForeignTest.php (revision 342dcecd8628deacd49d86f3247fd77e64bf33c3)
1a53db70dSGreg Roach<?php
2a53db70dSGreg Roach
3a53db70dSGreg Roach/**
4a53db70dSGreg Roach * webtrees: online genealogy
51062a142SGreg Roach * Copyright (C) 2018 webtrees development team
6a53db70dSGreg Roach * This program is free software: you can redistribute it and/or modify
7a53db70dSGreg Roach * it under the terms of the GNU General Public License as published by
8a53db70dSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9a53db70dSGreg Roach * (at your option) any later version.
10a53db70dSGreg Roach * This program is distributed in the hope that it will be useful,
11a53db70dSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12a53db70dSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13a53db70dSGreg Roach * GNU General Public License for more details.
14a53db70dSGreg Roach * You should have received a copy of the GNU General Public License
15a53db70dSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
16a53db70dSGreg Roach */
17a53db70dSGreg Roachnamespace Fisharebest\Webtrees\Census;
18a53db70dSGreg Roach
19a53db70dSGreg Roachuse Mockery;
20a53db70dSGreg Roach
21a53db70dSGreg Roach/**
22a53db70dSGreg Roach * Test harness for the class CensusColumnMotherForeign
23a53db70dSGreg Roach */
24c1010edaSGreg Roachclass CensusColumnMotherForeignTest extends \PHPUnit\Framework\TestCase
25c1010edaSGreg Roach{
26a53db70dSGreg Roach    /**
27a53db70dSGreg Roach     * Delete mock objects
28a53db70dSGreg Roach     */
29c1010edaSGreg Roach    public function tearDown()
30c1010edaSGreg Roach    {
31a53db70dSGreg Roach        Mockery::close();
32a53db70dSGreg Roach    }
33a53db70dSGreg Roach
34a53db70dSGreg 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     */
41c1010edaSGreg Roach    private function getPlaceMock($place)
42c1010edaSGreg Roach    {
4316d0b7f7SRico Sonntag        $placeMock = Mockery::mock('\Fisharebest\Webtrees\Place');
4416d0b7f7SRico Sonntag        $placeMock->shouldReceive('getGedcomName')->andReturn($place);
4516d0b7f7SRico Sonntag
4616d0b7f7SRico Sonntag        return $placeMock;
4716d0b7f7SRico Sonntag    }
4816d0b7f7SRico Sonntag
4916d0b7f7SRico Sonntag    /**
5015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
5115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
52a53db70dSGreg Roach     */
53c1010edaSGreg Roach    public function testSameCountry()
54c1010edaSGreg Roach    {
55c314ecc9SGreg Roach        $mother = Mockery::mock('Fisharebest\Webtrees\Individual');
5616d0b7f7SRico Sonntag        $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
57a53db70dSGreg Roach
58c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
59a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn($mother);
60a53db70dSGreg Roach
61c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
62a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
63a53db70dSGreg Roach
64c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
65a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
66a53db70dSGreg Roach
67a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
68a53db70dSGreg Roach
69*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
70a53db70dSGreg Roach    }
71a53db70dSGreg Roach
72a53db70dSGreg Roach    /**
7315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
7415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
75a53db70dSGreg Roach     */
76c1010edaSGreg Roach    public function testDifferentCountry()
77c1010edaSGreg Roach    {
78c314ecc9SGreg Roach        $mother = Mockery::mock('Fisharebest\Webtrees\Individual');
7916d0b7f7SRico Sonntag        $mother->shouldReceive('getBirthPlace')->andReturn($this->getPlaceMock('London, England'));
80a53db70dSGreg Roach
81c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
82a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn($mother);
83a53db70dSGreg Roach
84c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
85a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
86a53db70dSGreg Roach
87c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
88a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('Ireland');
89a53db70dSGreg Roach
90a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
91a53db70dSGreg Roach
92*342dcecdSGreg Roach        $this->assertSame('Y', $column->generate($individual, $individual));
93a53db70dSGreg Roach    }
94a53db70dSGreg Roach
95a53db70dSGreg Roach    /**
9615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
9715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
98a53db70dSGreg Roach     */
99c1010edaSGreg Roach    public function testPlaceNoParent()
100c1010edaSGreg Roach    {
101c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
102a53db70dSGreg Roach        $family->shouldReceive('getWife')->andReturn(null);
103a53db70dSGreg Roach
104c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
105a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn($family);
106a53db70dSGreg Roach
107c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
108a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
109a53db70dSGreg Roach
110a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
111a53db70dSGreg Roach
112*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
113a53db70dSGreg Roach    }
114a53db70dSGreg Roach
115a53db70dSGreg Roach    /**
11615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMotherForeign
11715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
118a53db70dSGreg Roach     */
119c1010edaSGreg Roach    public function testPlaceNoParentFamily()
120c1010edaSGreg Roach    {
121c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
122a53db70dSGreg Roach        $individual->shouldReceive('getPrimaryChildFamily')->andReturn(null);
123a53db70dSGreg Roach
124c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
125a53db70dSGreg Roach        $census->shouldReceive('censusPlace')->andReturn('England');
126a53db70dSGreg Roach
127a53db70dSGreg Roach        $column = new CensusColumnMotherForeign($census, '', '');
128a53db70dSGreg Roach
129*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
130a53db70dSGreg Roach    }
131a53db70dSGreg Roach}
132