xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision 2decada70ae5df289448aadc0d1089d2606545d1)
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 */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
188e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census;
198e2171feSGreg Roach
208e2171feSGreg Roachuse Fisharebest\Webtrees\Date;
218e2171feSGreg Roachuse Mockery;
228e2171feSGreg Roach
238e2171feSGreg Roach/**
248e2171feSGreg Roach * Test harness for the class CensusColumnMonthIfMarriedWithinYear
258e2171feSGreg Roach */
2684e2cf4eSGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase
27c1010edaSGreg Roach{
288e2171feSGreg Roach    /**
298e2171feSGreg Roach     * Delete mock objects
3052348eb8SGreg Roach     *
3152348eb8SGreg Roach     * @return void
328e2171feSGreg Roach     */
33c1010edaSGreg Roach    public function tearDown()
34c1010edaSGreg Roach    {
358e2171feSGreg Roach        Mockery::close();
368e2171feSGreg Roach    }
378e2171feSGreg Roach
388e2171feSGreg Roach    /**
3915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
4015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
4152348eb8SGreg Roach     *
4252348eb8SGreg Roach     * @return void
438e2171feSGreg Roach     */
44c1010edaSGreg Roach    public function testMarriedWithinYear()
45c1010edaSGreg Roach    {
46c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
47*2decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859'));
488e2171feSGreg Roach
49c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
5013abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
518e2171feSGreg Roach
52c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
5313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
548e2171feSGreg Roach
55c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
568e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
578e2171feSGreg Roach
588e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
598e2171feSGreg Roach
60342dcecdSGreg Roach        $this->assertSame('Dec', $column->generate($individual, $individual));
618e2171feSGreg Roach    }
628e2171feSGreg Roach
638e2171feSGreg Roach    /**
6415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
6515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6652348eb8SGreg Roach     *
6752348eb8SGreg Roach     * @return void
688e2171feSGreg Roach     */
69c1010edaSGreg Roach    public function testMarriedOverYearBeforeTheCensus()
70c1010edaSGreg Roach    {
71c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
72*2decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('01 JAN 1859'));
738e2171feSGreg Roach
74c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
7513abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
768e2171feSGreg Roach
77c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
7813abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
798e2171feSGreg Roach
80c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
818e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
828e2171feSGreg Roach
838e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
848e2171feSGreg Roach
85342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
868e2171feSGreg Roach    }
878e2171feSGreg Roach
888e2171feSGreg Roach    /**
8915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
9015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
9152348eb8SGreg Roach     *
9252348eb8SGreg Roach     * @return void
938e2171feSGreg Roach     */
94c1010edaSGreg Roach    public function testMarriedAfterTheCensus()
95c1010edaSGreg Roach    {
964fc9500eSGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
97*2decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('02 JUN 1860'));
984fc9500eSGreg Roach
994fc9500eSGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
10013abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
1014fc9500eSGreg Roach
1024fc9500eSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
10313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1044fc9500eSGreg Roach
1054fc9500eSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1064fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1074fc9500eSGreg Roach
1084fc9500eSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1094fc9500eSGreg Roach
110342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1114fc9500eSGreg Roach    }
1124fc9500eSGreg Roach
1134fc9500eSGreg Roach    /**
11415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
11515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
11652348eb8SGreg Roach     *
11752348eb8SGreg Roach     * @return void
1184fc9500eSGreg Roach     */
119c1010edaSGreg Roach    public function testNoMarriage()
120c1010edaSGreg Roach    {
121c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
12213abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
1238e2171feSGreg Roach
124c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
12513abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1268e2171feSGreg Roach
127c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1288e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1298e2171feSGreg Roach
1308e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1318e2171feSGreg Roach
132342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1338e2171feSGreg Roach    }
1348e2171feSGreg Roach
1358e2171feSGreg Roach    /**
13615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
13715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
13852348eb8SGreg Roach     *
13952348eb8SGreg Roach     * @return void
1408e2171feSGreg Roach     */
141c1010edaSGreg Roach    public function testNoSpouseFamily()
142c1010edaSGreg Roach    {
143c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
14413abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
1458e2171feSGreg Roach
146c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1478e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1488e2171feSGreg Roach
1498e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1508e2171feSGreg Roach
151342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1528e2171feSGreg Roach    }
1538e2171feSGreg Roach}
154