xref: /webtrees/tests/app/Census/CensusColumnMonthIfBornWithinYearTest.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/**
2271eba385SGreg Roach * Test harness for the class CensusColumnMonthIfBornWithinYear
238e2171feSGreg Roach */
24*84e2cf4eSGreg Roachclass CensusColumnMonthIfBornWithinYearTest 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\CensusColumnMonthIfBornWithinYear
3615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
378e2171feSGreg Roach     */
38c1010edaSGreg Roach    public function testBornWithinYear()
39c1010edaSGreg Roach    {
40c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
418e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860'));
428e2171feSGreg Roach
43c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
448e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
458e2171feSGreg Roach
4671eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
478e2171feSGreg Roach
48342dcecdSGreg Roach        $this->assertSame('Jan', $column->generate($individual, $individual));
498e2171feSGreg Roach    }
508e2171feSGreg Roach
518e2171feSGreg Roach    /**
5215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
5315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
548e2171feSGreg Roach     */
55c1010edaSGreg Roach    public function testBornOverYearBeforeTheCensus()
56c1010edaSGreg Roach    {
57c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
588e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859'));
598e2171feSGreg Roach
60c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
618e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
628e2171feSGreg Roach
6371eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
648e2171feSGreg Roach
65342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
668e2171feSGreg Roach    }
678e2171feSGreg Roach
688e2171feSGreg Roach    /**
6915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
7015d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
718e2171feSGreg Roach     */
72c1010edaSGreg Roach    public function testBornAfterTheCensus()
73c1010edaSGreg Roach    {
744fc9500eSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
754fc9500eSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('02 JUN 1860'));
764fc9500eSGreg Roach
774fc9500eSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
784fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
794fc9500eSGreg Roach
804fc9500eSGreg Roach
814fc9500eSGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
824fc9500eSGreg Roach
83342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
844fc9500eSGreg Roach    }
854fc9500eSGreg Roach
864fc9500eSGreg Roach
874fc9500eSGreg Roach    /**
8815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
8915d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
904fc9500eSGreg Roach     */
91c1010edaSGreg Roach    public function testNoBirth()
92c1010edaSGreg Roach    {
93c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
948e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
958e2171feSGreg Roach
96c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
978e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
988e2171feSGreg Roach
9971eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
1008e2171feSGreg Roach
101342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1028e2171feSGreg Roach    }
1038e2171feSGreg Roach}
104