xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision 84e2cf4e2b1803b300330f631d304db1a3c443dd)
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 CensusColumnMonthIfMarriedWithinYear
238e2171feSGreg Roach */
24*84e2cf4eSGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
268e2171feSGreg Roach    /**
278e2171feSGreg Roach     * Delete mock objects
288e2171feSGreg Roach     */
29c1010edaSGreg Roach    public function tearDown()
30c1010edaSGreg Roach    {
318e2171feSGreg Roach        Mockery::close();
328e2171feSGreg Roach    }
338e2171feSGreg Roach
348e2171feSGreg Roach    /**
3515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
378e2171feSGreg Roach     */
38c1010edaSGreg Roach    public function testMarriedWithinYear()
39c1010edaSGreg Roach    {
40c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
418e2171feSGreg Roach        $fact->shouldReceive('getDate')->andReturn(new Date('01 DEC 1859'));
428e2171feSGreg Roach
43c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
4413abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
458e2171feSGreg Roach
46c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
4713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
488e2171feSGreg Roach
49c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
508e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
518e2171feSGreg Roach
528e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
538e2171feSGreg Roach
54342dcecdSGreg Roach        $this->assertSame('Dec', $column->generate($individual, $individual));
558e2171feSGreg Roach    }
568e2171feSGreg Roach
578e2171feSGreg Roach    /**
5815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
5915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
608e2171feSGreg Roach     */
61c1010edaSGreg Roach    public function testMarriedOverYearBeforeTheCensus()
62c1010edaSGreg Roach    {
63c314ecc9SGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
648e2171feSGreg Roach        $fact->shouldReceive('getDate')->andReturn(new Date('01 JAN 1859'));
658e2171feSGreg Roach
66c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
6713abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
688e2171feSGreg Roach
69c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
7013abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
718e2171feSGreg Roach
72c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
738e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
748e2171feSGreg Roach
758e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
768e2171feSGreg Roach
77342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
788e2171feSGreg Roach    }
798e2171feSGreg Roach
808e2171feSGreg Roach    /**
8115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
8215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
838e2171feSGreg Roach     */
84c1010edaSGreg Roach    public function testMarriedAfterTheCensus()
85c1010edaSGreg Roach    {
864fc9500eSGreg Roach        $fact = Mockery::mock('Fisharebest\Webtrees\Fact');
874fc9500eSGreg Roach        $fact->shouldReceive('getDate')->andReturn(new Date('02 JUN 1860'));
884fc9500eSGreg Roach
894fc9500eSGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
9013abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([$fact]);
914fc9500eSGreg Roach
924fc9500eSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
9313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
944fc9500eSGreg Roach
954fc9500eSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
964fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
974fc9500eSGreg Roach
984fc9500eSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
994fc9500eSGreg Roach
100342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1014fc9500eSGreg Roach    }
1024fc9500eSGreg Roach
1034fc9500eSGreg Roach    /**
10415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
10515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
1064fc9500eSGreg Roach     */
107c1010edaSGreg Roach    public function testNoMarriage()
108c1010edaSGreg Roach    {
109c314ecc9SGreg Roach        $family = Mockery::mock('Fisharebest\Webtrees\Family');
11013abd6f3SGreg Roach        $family->shouldReceive('getFacts')->with('MARR')->andReturn([]);
1118e2171feSGreg Roach
112c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
11313abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1148e2171feSGreg Roach
115c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1168e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1178e2171feSGreg Roach
1188e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1198e2171feSGreg Roach
120342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1218e2171feSGreg Roach    }
1228e2171feSGreg Roach
1238e2171feSGreg Roach    /**
12415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
12515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
1268e2171feSGreg Roach     */
127c1010edaSGreg Roach    public function testNoSpouseFamily()
128c1010edaSGreg Roach    {
129c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
13013abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
1318e2171feSGreg Roach
132c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1338e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1348e2171feSGreg Roach
1358e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1368e2171feSGreg Roach
137342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1388e2171feSGreg Roach    }
1398e2171feSGreg Roach}
140