xref: /webtrees/tests/app/Census/CensusColumnMonthIfBornWithinYearTest.php (revision cd94ca6664a143daa60d394f7b9cad6d42ec1b1d)
18e2171feSGreg Roach<?php
23976b470SGreg Roach
38e2171feSGreg Roach/**
48e2171feSGreg Roach * webtrees: online genealogy
589f7189bSGreg Roach * Copyright (C) 2021 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
1589f7189bSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
168e2171feSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
208e2171feSGreg Roachnamespace Fisharebest\Webtrees\Census;
218e2171feSGreg Roach
228e2171feSGreg Roachuse Fisharebest\Webtrees\Date;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
258e2171feSGreg Roach
268e2171feSGreg Roach/**
2771eba385SGreg Roach * Test harness for the class CensusColumnMonthIfBornWithinYear
288e2171feSGreg Roach */
293cfcc809SGreg Roachclass CensusColumnMonthIfBornWithinYearTest extends TestCase
30c1010edaSGreg Roach{
318e2171feSGreg Roach    /**
3215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
3315d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
3452348eb8SGreg Roach     *
3552348eb8SGreg Roach     * @return void
368e2171feSGreg Roach     */
379b802b22SGreg Roach    public function testBornWithinYear(): void
38c1010edaSGreg Roach    {
39*cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
400ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date('01 JAN 1860'));
418e2171feSGreg Roach
42*cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
430ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
448e2171feSGreg Roach
4571eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
468e2171feSGreg Roach
475e933c21SGreg Roach        self::assertSame('Jan', $column->generate($individual, $individual));
488e2171feSGreg Roach    }
498e2171feSGreg Roach
508e2171feSGreg Roach    /**
5115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
5215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
5352348eb8SGreg Roach     *
5452348eb8SGreg Roach     * @return void
558e2171feSGreg Roach     */
569b802b22SGreg Roach    public function testBornOverYearBeforeTheCensus(): void
57c1010edaSGreg Roach    {
58*cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
590ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date('01 JAN 1859'));
608e2171feSGreg Roach
61*cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
620ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
638e2171feSGreg Roach
6471eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
658e2171feSGreg Roach
665e933c21SGreg Roach        self::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
7252348eb8SGreg Roach     *
7352348eb8SGreg Roach     * @return void
748e2171feSGreg Roach     */
759b802b22SGreg Roach    public function testBornAfterTheCensus(): void
76c1010edaSGreg Roach    {
77*cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
780ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date('02 JUN 1860'));
794fc9500eSGreg Roach
80*cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
810ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
824fc9500eSGreg Roach
834fc9500eSGreg Roach
844fc9500eSGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
854fc9500eSGreg Roach
865e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
874fc9500eSGreg Roach    }
884fc9500eSGreg Roach
894fc9500eSGreg Roach
904fc9500eSGreg Roach    /**
9115d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\CensusColumnMonthIfBornWithinYear
9215d603e7SGreg Roach     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
9352348eb8SGreg Roach     *
9452348eb8SGreg Roach     * @return void
954fc9500eSGreg Roach     */
969b802b22SGreg Roach    public function testNoBirth(): void
97c1010edaSGreg Roach    {
98*cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
990ecdbde6SGreg Roach        $individual->method('getBirthDate')->willReturn(new Date(''));
1008e2171feSGreg Roach
101*cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
1020ecdbde6SGreg Roach        $census->method('censusDate')->willReturn('01 JUN 1860');
1038e2171feSGreg Roach
10471eba385SGreg Roach        $column = new CensusColumnMonthIfBornWithinYear($census, '', '');
1058e2171feSGreg Roach
1065e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
1078e2171feSGreg Roach    }
1088e2171feSGreg Roach}
109