xref: /webtrees/tests/app/Census/CensusColumnMonthIfBornWithinYearTest.php (revision 342dcecd8628deacd49d86f3247fd77e64bf33c3)
18e2171feSGreg Roach<?php
28e2171feSGreg Roach
38e2171feSGreg Roach/**
48e2171feSGreg Roach * webtrees: online genealogy
51062a142SGreg Roach * Copyright (C) 2018 webtrees development team
68e2171feSGreg Roach * This program is free software: you can redistribute it and/or modify
78e2171feSGreg Roach * it under the terms of the GNU General Public License as published by
88e2171feSGreg Roach * the Free Software Foundation, either version 3 of the License, or
98e2171feSGreg Roach * (at your option) any later version.
108e2171feSGreg Roach * This program is distributed in the hope that it will be useful,
118e2171feSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
128e2171feSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
138e2171feSGreg Roach * GNU General Public License for more details.
148e2171feSGreg Roach * You should have received a copy of the GNU General Public License
158e2171feSGreg Roach * along with this program. If not, see <http://www.gnu.org/licenses/>.
168e2171feSGreg Roach */
178e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census;
188e2171feSGreg Roach
198e2171feSGreg Roachuse Fisharebest\Webtrees\Date;
208e2171feSGreg Roachuse Mockery;
218e2171feSGreg Roach
228e2171feSGreg Roach/**
2371eba385SGreg Roach * Test harness for the class CensusColumnMonthIfBornWithinYear
248e2171feSGreg Roach */
25c1010edaSGreg Roachclass CensusColumnMonthIfBornWithinYearTest extends \PHPUnit\Framework\TestCase
26c1010edaSGreg Roach{
278e2171feSGreg Roach    /**
288e2171feSGreg Roach     * Delete mock objects
298e2171feSGreg Roach     */
30c1010edaSGreg Roach    public function tearDown()
31c1010edaSGreg Roach    {
328e2171feSGreg Roach        Mockery::close();
338e2171feSGreg Roach    }
348e2171feSGreg Roach
358e2171feSGreg Roach    /**
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
3715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
388e2171feSGreg Roach     */
39c1010edaSGreg Roach    public function testBornWithinYear()
40c1010edaSGreg Roach    {
41c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
428e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860'));
438e2171feSGreg Roach
44c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
458e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
468e2171feSGreg Roach
4771eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
488e2171feSGreg Roach
49*342dcecdSGreg Roach        $this->assertSame('Jan', $column->generate($individual, $individual));
508e2171feSGreg Roach    }
518e2171feSGreg Roach
528e2171feSGreg Roach    /**
5315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
5415d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
558e2171feSGreg Roach     */
56c1010edaSGreg Roach    public function testBornOverYearBeforeTheCensus()
57c1010edaSGreg Roach    {
58c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
598e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859'));
608e2171feSGreg Roach
61c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
628e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
638e2171feSGreg Roach
6471eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
658e2171feSGreg Roach
66*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
678e2171feSGreg Roach    }
688e2171feSGreg Roach
698e2171feSGreg Roach    /**
7015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
7115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
728e2171feSGreg Roach     */
73c1010edaSGreg Roach    public function testBornAfterTheCensus()
74c1010edaSGreg Roach    {
754fc9500eSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
764fc9500eSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('02 JUN 1860'));
774fc9500eSGreg Roach
784fc9500eSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
794fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
804fc9500eSGreg Roach
814fc9500eSGreg Roach
824fc9500eSGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
834fc9500eSGreg Roach
84*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
854fc9500eSGreg Roach    }
864fc9500eSGreg Roach
874fc9500eSGreg Roach
884fc9500eSGreg Roach    /**
8915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
9015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
914fc9500eSGreg Roach     */
92c1010edaSGreg Roach    public function testNoBirth()
93c1010edaSGreg Roach    {
94c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
958e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
968e2171feSGreg Roach
97c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
988e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
998e2171feSGreg Roach
10071eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
1018e2171feSGreg Roach
102*342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1038e2171feSGreg Roach    }
1048e2171feSGreg Roach}
105