xref: /webtrees/tests/app/Census/CensusColumnMonthIfBornWithinYearTest.php (revision 52348eb8c11b06a8488e13475e6561273832716a)
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 */
2484e2cf4eSGreg Roachclass CensusColumnMonthIfBornWithinYearTest extends \Fisharebest\Webtrees\TestCase
25c1010edaSGreg Roach{
268e2171feSGreg Roach    /**
278e2171feSGreg Roach     * Delete mock objects
28*52348eb8SGreg Roach     *
29*52348eb8SGreg Roach     * @return void
308e2171feSGreg Roach     */
31c1010edaSGreg Roach    public function tearDown()
32c1010edaSGreg Roach    {
338e2171feSGreg Roach        Mockery::close();
348e2171feSGreg Roach    }
358e2171feSGreg Roach
368e2171feSGreg Roach    /**
3715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
3815d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
39*52348eb8SGreg Roach     *
40*52348eb8SGreg Roach     * @return void
418e2171feSGreg Roach     */
42c1010edaSGreg Roach    public function testBornWithinYear()
43c1010edaSGreg Roach    {
44c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
458e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1860'));
468e2171feSGreg Roach
47c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
488e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
498e2171feSGreg Roach
5071eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
518e2171feSGreg Roach
52342dcecdSGreg Roach        $this->assertSame('Jan', $column->generate($individual, $individual));
538e2171feSGreg Roach    }
548e2171feSGreg Roach
558e2171feSGreg Roach    /**
5615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
5715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
58*52348eb8SGreg Roach     *
59*52348eb8SGreg Roach     * @return void
608e2171feSGreg Roach     */
61c1010edaSGreg Roach    public function testBornOverYearBeforeTheCensus()
62c1010edaSGreg Roach    {
63c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
648e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('01 JAN 1859'));
658e2171feSGreg Roach
66c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
678e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
688e2171feSGreg Roach
6971eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
708e2171feSGreg Roach
71342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
728e2171feSGreg Roach    }
738e2171feSGreg Roach
748e2171feSGreg Roach    /**
7515d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
7615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
77*52348eb8SGreg Roach     *
78*52348eb8SGreg Roach     * @return void
798e2171feSGreg Roach     */
80c1010edaSGreg Roach    public function testBornAfterTheCensus()
81c1010edaSGreg Roach    {
824fc9500eSGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
834fc9500eSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date('02 JUN 1860'));
844fc9500eSGreg Roach
854fc9500eSGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
864fc9500eSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
874fc9500eSGreg Roach
884fc9500eSGreg Roach
894fc9500eSGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
904fc9500eSGreg Roach
91342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
924fc9500eSGreg Roach    }
934fc9500eSGreg Roach
944fc9500eSGreg Roach
954fc9500eSGreg Roach    /**
9615d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
9715d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
98*52348eb8SGreg Roach     *
99*52348eb8SGreg Roach     * @return void
1004fc9500eSGreg Roach     */
101c1010edaSGreg Roach    public function testNoBirth()
102c1010edaSGreg Roach    {
103c314ecc9SGreg Roach        $individual = Mockery::mock('Fisharebest\Webtrees\Individual');
1048e2171feSGreg Roach        $individual->shouldReceive('getBirthDate')->andReturn(new Date(''));
1058e2171feSGreg Roach
106c314ecc9SGreg Roach        $census = Mockery::mock('Fisharebest\Webtrees\Census\CensusInterface');
1078e2171feSGreg Roach        $census->shouldReceive('censusDate')->andReturn('01 JUN 1860');
1088e2171feSGreg Roach
10971eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
1108e2171feSGreg Roach
111342dcecdSGreg Roach        $this->assertSame('', $column->generate($individual, $individual));
1128e2171feSGreg Roach    }
1138e2171feSGreg Roach}
114