18e2171feSGreg Roach<?php 23976b470SGreg Roach 38e2171feSGreg Roach/** 48e2171feSGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 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; 25*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass; 268e2171feSGreg Roach 27*202c018bSGreg Roach#[CoversClass(CensusColumnMonthIfBornWithinYear::class)] 28*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)] 293cfcc809SGreg Roachclass CensusColumnMonthIfBornWithinYearTest extends TestCase 30c1010edaSGreg Roach{ 319b802b22SGreg Roach public function testBornWithinYear(): void 32c1010edaSGreg Roach { 33cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 340ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('01 JAN 1860')); 358e2171feSGreg Roach 36cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 370ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 388e2171feSGreg Roach 3971eba385SGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 408e2171feSGreg Roach 415e933c21SGreg Roach self::assertSame('Jan', $column->generate($individual, $individual)); 428e2171feSGreg Roach } 438e2171feSGreg Roach 449b802b22SGreg Roach public function testBornOverYearBeforeTheCensus(): void 45c1010edaSGreg Roach { 46cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 470ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('01 JAN 1859')); 488e2171feSGreg Roach 49cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 500ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 518e2171feSGreg Roach 5271eba385SGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 538e2171feSGreg Roach 545e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 558e2171feSGreg Roach } 568e2171feSGreg Roach 579b802b22SGreg Roach public function testBornAfterTheCensus(): void 58c1010edaSGreg Roach { 59cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 600ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('02 JUN 1860')); 614fc9500eSGreg Roach 62cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 630ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 644fc9500eSGreg Roach 654fc9500eSGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 664fc9500eSGreg Roach 675e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 684fc9500eSGreg Roach } 694fc9500eSGreg Roach 709b802b22SGreg Roach public function testNoBirth(): void 71c1010edaSGreg Roach { 72cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 730ecdbde6SGreg Roach $individual->method('getBirthDate')->willReturn(new Date('')); 748e2171feSGreg Roach 75cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 760ecdbde6SGreg Roach $census->method('censusDate')->willReturn('01 JUN 1860'); 778e2171feSGreg Roach 7871eba385SGreg Roach $column = new CensusColumnMonthIfBornWithinYear($census, '', ''); 798e2171feSGreg Roach 805e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 818e2171feSGreg Roach } 828e2171feSGreg Roach} 83