xref: /webtrees/tests/app/Census/CensusColumnMarriedWithinYearTest.php (revision 52348eb8c11b06a8488e13475e6561273832716a)
18e2171feSGreg Roach<?php
28e2171feSGreg Roach/**
38e2171feSGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
58e2171feSGreg Roach * This program is free software: you can redistribute it and/or modify
68e2171feSGreg Roach * it under the terms of the GNU General Public License as published by
78e2171feSGreg Roach * the Free Software Foundation, either version 3 of the License, or
88e2171feSGreg Roach * (at your option) any later version.
98e2171feSGreg Roach * This program is distributed in the hope that it will be useful,
108e2171feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
118e2171feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
128e2171feSGreg Roach * GNU General Public License for more details.
138e2171feSGreg Roach * You should have received a copy of the GNU General Public License
148e2171feSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
158e2171feSGreg Roach */
168e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census;
178e2171feSGreg Roach
188e2171feSGreg Roachuse Fisharebest\Webtrees\Date;
198e2171feSGreg Roachuse Mockery;
208e2171feSGreg Roach
218e2171feSGreg Roach/**
228e2171feSGreg Roach * Test harness for the class CensusColumnMarriedWithinYear
238e2171feSGreg Roach */
2484e2cf4eSGreg Roachclass CensusColumnMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
268e2171feSGreg Roach    /**
278e2171feSGreg Roach     * Delete mock objects
28*52348eb8SGreg Roach     *
29*52348eb8SGreg Roach     * @return void
308e2171feSGreg Roach     */
31c1010edaSGreg Roach    public function tearDown()
32c1010edaSGreg Roach    {
338e2171feSGreg Roach        Mockery::close();
348e2171feSGreg Roach    }
358e2171feSGreg Roach
368e2171feSGreg Roach    /**
3715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
3815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
39*52348eb8SGreg Roach     *
40*52348eb8SGreg Roach     * @return void
418e2171feSGreg Roach     */
42c1010edaSGreg Roach    public function testMarriedWithinYear()
43c1010edaSGreg Roach    {
44c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
458e2171feSGreg Roach        $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
468e2171feSGreg Roach
47c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
4813abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
498e2171feSGreg Roach
50c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
5113abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
528e2171feSGreg Roach
53c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
548e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
558e2171feSGreg Roach
568e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
578e2171feSGreg Roach
58342dcecdSGreg Roach        $this->assertSame('Y', $column->generate($individual, $individual));
598e2171feSGreg Roach    }
608e2171feSGreg Roach
618e2171feSGreg Roach    /**
6215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
6315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
64*52348eb8SGreg Roach     *
65*52348eb8SGreg Roach     * @return void
668e2171feSGreg Roach     */
67c1010edaSGreg Roach    public function testMarriedOverYearBeforeTheCensus()
68c1010edaSGreg Roach    {
69c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
708e2171feSGreg Roach        $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859'));
718e2171feSGreg Roach
72c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
7313abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
748e2171feSGreg Roach
75c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
7613abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
778e2171feSGreg Roach
78c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
798e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
808e2171feSGreg Roach
818e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
828e2171feSGreg Roach
83342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
848e2171feSGreg Roach    }
858e2171feSGreg Roach
868e2171feSGreg Roach    /**
8715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
8815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
89*52348eb8SGreg Roach     *
90*52348eb8SGreg Roach     * @return void
918e2171feSGreg Roach     */
92c1010edaSGreg Roach    public function testMarriedAfterTheCensus()
93c1010edaSGreg Roach    {
944fc9500eSGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
954fc9500eSGreg Roach        $fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860'));
964fc9500eSGreg Roach
974fc9500eSGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
9813abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
994fc9500eSGreg Roach
1004fc9500eSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10113abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1024fc9500eSGreg Roach
1034fc9500eSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1044fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1054fc9500eSGreg Roach
1064fc9500eSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
1074fc9500eSGreg Roach
108342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1094fc9500eSGreg Roach    }
1104fc9500eSGreg Roach
1114fc9500eSGreg Roach    /**
11215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
11315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
114*52348eb8SGreg Roach     *
115*52348eb8SGreg Roach     * @return void
1164fc9500eSGreg Roach     */
117c1010edaSGreg Roach    public function testNoMarriage()
118c1010edaSGreg Roach    {
119c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
12013abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
1218e2171feSGreg Roach
122c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
12313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1248e2171feSGreg Roach
125c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1268e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1278e2171feSGreg Roach
1288e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
1298e2171feSGreg Roach
130342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1318e2171feSGreg Roach    }
1328e2171feSGreg Roach
1338e2171feSGreg Roach    /**
13415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMarriedWithinYear
13515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
136*52348eb8SGreg Roach     *
137*52348eb8SGreg Roach     * @return void
1388e2171feSGreg Roach     */
139c1010edaSGreg Roach    public function testNoSpouseFamily()
140c1010edaSGreg Roach    {
141c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
14213abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
1438e2171feSGreg Roach
144c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1458e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1468e2171feSGreg Roach
1478e2171feSGreg Roach        $column = new CensusColumnMarriedWithinYear($census, '', '');
1488e2171feSGreg Roach
149342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1508e2171feSGreg Roach    }
1518e2171feSGreg Roach}
152