xref: /webtrees/tests/app/Census/CensusColumnMonthIfMarriedWithinYearTest.php (revision ddf438a50ef4ca889f688fe1c566ddf89d256ed1)
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;
21*ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact;
22*ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
23*ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
248e2171feSGreg Roachuse Mockery;
258e2171feSGreg Roach
268e2171feSGreg Roach/**
278e2171feSGreg Roach * Test harness for the class CensusColumnMonthIfMarriedWithinYear
288e2171feSGreg Roach */
2984e2cf4eSGreg Roachclass CensusColumnMonthIfMarriedWithinYearTest extends \Fisharebest\Webtrees\TestCase
30c1010edaSGreg Roach{
318e2171feSGreg Roach    /**
328e2171feSGreg Roach     * Delete mock objects
3352348eb8SGreg Roach     *
3452348eb8SGreg Roach     * @return void
358e2171feSGreg Roach     */
36c1010edaSGreg Roach    public function tearDown()
37c1010edaSGreg Roach    {
388e2171feSGreg Roach        Mockery::close();
398e2171feSGreg Roach    }
408e2171feSGreg Roach
418e2171feSGreg Roach    /**
4215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
4315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
4452348eb8SGreg Roach     *
4552348eb8SGreg Roach     * @return void
468e2171feSGreg Roach     */
47c1010edaSGreg Roach    public function testMarriedWithinYear()
48c1010edaSGreg Roach    {
49*ddf438a5SGreg Roach        $fact = Mockery::mock(Fact::class);
502decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859'));
518e2171feSGreg Roach
52*ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
538d0ebef0SGreg Roach        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
548e2171feSGreg Roach
55*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
5613abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
578e2171feSGreg Roach
58*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
598e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
608e2171feSGreg Roach
618e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
628e2171feSGreg Roach
63342dcecdSGreg Roach        $this->assertSame('Dec', $column->generate($individual, $individual));
648e2171feSGreg Roach    }
658e2171feSGreg Roach
668e2171feSGreg Roach    /**
6715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
6815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
6952348eb8SGreg Roach     *
7052348eb8SGreg Roach     * @return void
718e2171feSGreg Roach     */
72c1010edaSGreg Roach    public function testMarriedOverYearBeforeTheCensus()
73c1010edaSGreg Roach    {
74*ddf438a5SGreg Roach        $fact = Mockery::mock(Fact::class);
752decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('01 JAN 1859'));
768e2171feSGreg Roach
77*ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
788d0ebef0SGreg Roach        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
798e2171feSGreg Roach
80*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
8113abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
828e2171feSGreg Roach
83*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
848e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
858e2171feSGreg Roach
868e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
878e2171feSGreg Roach
88342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
898e2171feSGreg Roach    }
908e2171feSGreg Roach
918e2171feSGreg Roach    /**
9215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
9315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
9452348eb8SGreg Roach     *
9552348eb8SGreg Roach     * @return void
968e2171feSGreg Roach     */
97c1010edaSGreg Roach    public function testMarriedAfterTheCensus()
98c1010edaSGreg Roach    {
99*ddf438a5SGreg Roach        $fact = Mockery::mock(Fact::class);
1002decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('02 JUN 1860'));
1014fc9500eSGreg Roach
102*ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
1038d0ebef0SGreg Roach        $family->shouldReceive('facts')->with(['MARR'])->andReturn([$fact]);
1044fc9500eSGreg Roach
105*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
10613abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1074fc9500eSGreg Roach
108*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
1094fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1104fc9500eSGreg Roach
1114fc9500eSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1124fc9500eSGreg Roach
113342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1144fc9500eSGreg Roach    }
1154fc9500eSGreg Roach
1164fc9500eSGreg Roach    /**
11715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
11815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
11952348eb8SGreg Roach     *
12052348eb8SGreg Roach     * @return void
1214fc9500eSGreg Roach     */
122c1010edaSGreg Roach    public function testNoMarriage()
123c1010edaSGreg Roach    {
124*ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
1258d0ebef0SGreg Roach        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
1268e2171feSGreg Roach
127*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
12813abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
1298e2171feSGreg Roach
130*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
1318e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1328e2171feSGreg Roach
1338e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1348e2171feSGreg Roach
135342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1368e2171feSGreg Roach    }
1378e2171feSGreg Roach
1388e2171feSGreg Roach    /**
13915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfMarriedWithinYear
14015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
14152348eb8SGreg Roach     *
14252348eb8SGreg Roach     * @return void
1438e2171feSGreg Roach     */
144c1010edaSGreg Roach    public function testNoSpouseFamily()
145c1010edaSGreg Roach    {
146*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
14713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
1488e2171feSGreg Roach
149*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
1508e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1518e2171feSGreg Roach
1528e2171feSGreg Roach        $column = new CensusColumnMonthIfMarriedWithinYear($census, '', '');
1538e2171feSGreg Roach
154342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1558e2171feSGreg Roach    }
1568e2171feSGreg Roach}
157