xref: /webtrees/tests/app/Census/CensusColumnAgeMarriedTest.php (revision ddf438a50ef4ca889f688fe1c566ddf89d256ed1)
181d1be7aSGreg Roach<?php
281d1be7aSGreg Roach/**
381d1be7aSGreg Roach * webtrees: online genealogy
41062a142SGreg Roach * Copyright (C) 2018 webtrees development team
581d1be7aSGreg Roach * This program is free software: you can redistribute it and/or modify
681d1be7aSGreg Roach * it under the terms of the GNU General Public License as published by
781d1be7aSGreg Roach * the Free Software Foundation, either version 3 of the License, or
881d1be7aSGreg Roach * (at your option) any later version.
981d1be7aSGreg Roach * This program is distributed in the hope that it will be useful,
1081d1be7aSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
1181d1be7aSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1281d1be7aSGreg Roach * GNU General Public License for more details.
1381d1be7aSGreg Roach * You should have received a copy of the GNU General Public License
1481d1be7aSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
1581d1be7aSGreg Roach */
16e7f56f2aSGreg Roachdeclare(strict_types=1);
17e7f56f2aSGreg Roach
1881d1be7aSGreg Roachnamespace Fisharebest\Webtrees\Census;
1981d1be7aSGreg Roach
2081d1be7aSGreg Roachuse Fisharebest\Webtrees\Date;
21*ddf438a5SGreg Roachuse Fisharebest\Webtrees\Fact;
22*ddf438a5SGreg Roachuse Fisharebest\Webtrees\Family;
23*ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
2481d1be7aSGreg Roachuse Mockery;
2581d1be7aSGreg Roach
2681d1be7aSGreg Roach/**
2781d1be7aSGreg Roach * Test harness for the class CensusColumnAgeMarried
2881d1be7aSGreg Roach */
2984e2cf4eSGreg Roachclass CensusColumnAgeMarriedTest extends \Fisharebest\Webtrees\TestCase
30c1010edaSGreg Roach{
3181d1be7aSGreg Roach    /**
3281d1be7aSGreg Roach     * Delete mock objects
3352348eb8SGreg Roach     *
3452348eb8SGreg Roach     * @return void
3581d1be7aSGreg Roach     */
36c1010edaSGreg Roach    public function tearDown()
37c1010edaSGreg Roach    {
3881d1be7aSGreg Roach        Mockery::close();
3981d1be7aSGreg Roach    }
4081d1be7aSGreg Roach
4181d1be7aSGreg Roach    /**
4215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
4315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
4452348eb8SGreg Roach     *
4552348eb8SGreg Roach     * @return void
4681d1be7aSGreg Roach     */
47c1010edaSGreg Roach    public function testAgeMarried()
48c1010edaSGreg Roach    {
49*ddf438a5SGreg Roach        $fact = Mockery::mock(Fact::class);
502decada7SGreg Roach        $fact->shouldReceive('date')->andReturn(new Date('01 DEC 1859'));
5181d1be7aSGreg Roach
52*ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
538d0ebef0SGreg Roach        $family->shouldReceive('facts')->with(['MARR'], true)->andReturn([$fact]);
5481d1be7aSGreg Roach
55*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
5681d1be7aSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
5713abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
5881d1be7aSGreg Roach
59*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
6081d1be7aSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
6181d1be7aSGreg Roach
6281d1be7aSGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
6381d1be7aSGreg Roach
64220febf9SGreg Roach        $this->assertSame('19', $column->generate($individual, $individual));
6581d1be7aSGreg Roach    }
6681d1be7aSGreg Roach
6781d1be7aSGreg Roach    /**
6815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
6915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
7052348eb8SGreg Roach     *
7152348eb8SGreg Roach     * @return void
7281d1be7aSGreg Roach     */
73c1010edaSGreg Roach    public function testNoBirthDate()
74c1010edaSGreg Roach    {
75*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
763e983931SGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
773e983931SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
783e983931SGreg Roach
79*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
803e983931SGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
813e983931SGreg Roach
823e983931SGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
833e983931SGreg Roach
84342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
8581d1be7aSGreg Roach    }
8681d1be7aSGreg Roach
8781d1be7aSGreg Roach    /**
8815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
8915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
9052348eb8SGreg Roach     *
9152348eb8SGreg Roach     * @return void
9281d1be7aSGreg Roach     */
93c1010edaSGreg Roach    public function testNoMarriage()
94c1010edaSGreg Roach    {
95*ddf438a5SGreg Roach        $family = Mockery::mock(Family::class);
968d0ebef0SGreg Roach        $family->shouldReceive('facts')->with(['MARR'])->andReturn([]);
9781d1be7aSGreg Roach
98*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
9981d1be7aSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
10013abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([$family]);
10181d1be7aSGreg Roach
102*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
10381d1be7aSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
10481d1be7aSGreg Roach
10581d1be7aSGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
10681d1be7aSGreg Roach
107342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
10881d1be7aSGreg Roach    }
10981d1be7aSGreg Roach
11081d1be7aSGreg Roach    /**
11115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnAgeMarried
11215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
11352348eb8SGreg Roach     *
11452348eb8SGreg Roach     * @return void
11581d1be7aSGreg Roach     */
116c1010edaSGreg Roach    public function testNoSpouseFamily()
117c1010edaSGreg Roach    {
118*ddf438a5SGreg Roach        $individual = Mockery::mock(Individual::class);
11981d1be7aSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('15 MAR 1840'));
12013abd6f3SGreg Roach        $individual->shouldReceive('getSpouseFamilies')->andReturn([]);
12181d1be7aSGreg Roach
122*ddf438a5SGreg Roach        $census = Mockery::mock(CensusInterface::class);
12381d1be7aSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
12481d1be7aSGreg Roach
12581d1be7aSGreg Roach        $column = new CensusColumnAgeMarried($census, '', '');
12681d1be7aSGreg Roach
127342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
12881d1be7aSGreg Roach    }
12981d1be7aSGreg Roach}
130