14c219c47SGreg Roach<?php 23976b470SGreg Roach 34c219c47SGreg Roach/** 44c219c47SGreg Roach * webtrees: online genealogy 5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team 64c219c47SGreg Roach * This program is free software: you can redistribute it and/or modify 74c219c47SGreg Roach * it under the terms of the GNU General Public License as published by 84c219c47SGreg Roach * the Free Software Foundation, either version 3 of the License, or 94c219c47SGreg Roach * (at your option) any later version. 104c219c47SGreg Roach * This program is distributed in the hope that it will be useful, 114c219c47SGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of 124c219c47SGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 134c219c47SGreg Roach * GNU General Public License for more details. 144c219c47SGreg 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/>. 164c219c47SGreg Roach */ 17fcfa147eSGreg Roach 18e7f56f2aSGreg Roachdeclare(strict_types=1); 19e7f56f2aSGreg Roach 204c219c47SGreg Roachnamespace Fisharebest\Webtrees\Census; 214c219c47SGreg Roach 22cacefda1SGreg Roachuse Fisharebest\Webtrees\Fact; 23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual; 243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase; 25cacefda1SGreg Roachuse Illuminate\Support\Collection; 264c219c47SGreg Roach 274c219c47SGreg Roach/** 284c219c47SGreg Roach * Test harness for the class CensusColumnReligion 294c219c47SGreg Roach */ 303cfcc809SGreg Roachclass CensusColumnReligionTest extends TestCase 31c1010edaSGreg Roach{ 324c219c47SGreg Roach /** 3382e78027SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnReligion 3415d603e7SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 3552348eb8SGreg Roach * @return void 364c219c47SGreg Roach */ 37cacefda1SGreg Roach public function testNoReligion(): void 38c1010edaSGreg Roach { 39cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 40cacefda1SGreg Roach $individual 41109b3e30SGreg Roach ->expects(self::exactly(2)) 42cacefda1SGreg Roach ->method('facts') 43*9aef375dSGreg Roach ->with(self::withConsecutive([['RELI'], []])) 44109b3e30SGreg Roach ->willReturnOnConsecutiveCalls(new Collection(), new Collection()); 454c219c47SGreg Roach 46cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 474c219c47SGreg Roach 484c219c47SGreg Roach $column = new CensusColumnReligion($census, '', ''); 494c219c47SGreg Roach 505e933c21SGreg Roach self::assertSame('', $column->generate($individual, $individual)); 514c219c47SGreg Roach } 52cacefda1SGreg Roach 53cacefda1SGreg Roach /** 5482e78027SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnReligion 55cacefda1SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 56cacefda1SGreg Roach * @return void 57cacefda1SGreg Roach */ 58cacefda1SGreg Roach public function testRecordReligion(): void 59cacefda1SGreg Roach { 60cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 61cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 62cacefda1SGreg Roach $fact->method('value')->willReturn('Jedi'); 63cacefda1SGreg Roach $individual->method('facts')->with(['RELI'])->willReturn(new Collection([$fact])); 64cacefda1SGreg Roach 65cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 66cacefda1SGreg Roach 67cacefda1SGreg Roach $column = new CensusColumnReligion($census, '', ''); 68cacefda1SGreg Roach 695e933c21SGreg Roach self::assertSame('Jedi', $column->generate($individual, $individual)); 70cacefda1SGreg Roach } 71cacefda1SGreg Roach 72cacefda1SGreg Roach /** 7382e78027SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnReligion 74cacefda1SGreg Roach * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn 75cacefda1SGreg Roach * @return void 76cacefda1SGreg Roach */ 77cacefda1SGreg Roach public function testEventReligion(): void 78cacefda1SGreg Roach { 79cd94ca66SGreg Roach $individual = $this->createMock(Individual::class); 80cd94ca66SGreg Roach $fact = $this->createMock(Fact::class); 81cacefda1SGreg Roach $fact->method('attribute')->with('RELI')->willReturn('Jedi'); 82cacefda1SGreg Roach $individual 83109b3e30SGreg Roach ->expects(self::exactly(2)) 84cacefda1SGreg Roach ->method('facts') 85*9aef375dSGreg Roach ->with(self::withConsecutive([['RELI'], []])) 86109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 87109b3e30SGreg Roach new Collection(), 88109b3e30SGreg Roach new Collection([$fact]) 89109b3e30SGreg Roach ); 90cacefda1SGreg Roach 91cd94ca66SGreg Roach $census = $this->createMock(CensusInterface::class); 92cacefda1SGreg Roach 93cacefda1SGreg Roach $column = new CensusColumnReligion($census, '', ''); 94cacefda1SGreg Roach 955e933c21SGreg Roach self::assertSame('Jedi', $column->generate($individual, $individual)); 96cacefda1SGreg Roach } 974c219c47SGreg Roach} 98