14c219c47SGreg Roach<?php 23976b470SGreg Roach 34c219c47SGreg Roach/** 44c219c47SGreg Roach * webtrees: online genealogy 589f7189bSGreg Roach * Copyright (C) 2021 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 /** 33*82e78027SGreg 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 { 395e933c21SGreg Roach $individual = self::createMock(Individual::class); 40cacefda1SGreg Roach $individual 41109b3e30SGreg Roach ->expects(self::exactly(2)) 42cacefda1SGreg Roach ->method('facts') 43109b3e30SGreg Roach ->withConsecutive([['RELI']], []) 44109b3e30SGreg Roach ->willReturnOnConsecutiveCalls(new Collection(), new Collection()); 454c219c47SGreg Roach 465e933c21SGreg Roach $census = self::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 /** 54*82e78027SGreg 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 { 605e933c21SGreg Roach $individual = self::createMock(Individual::class); 615e933c21SGreg Roach $fact = self::createMock(Fact::class); 62cacefda1SGreg Roach $fact->method('value')->willReturn('Jedi'); 63cacefda1SGreg Roach $individual->method('facts')->with(['RELI'])->willReturn(new Collection([$fact])); 64cacefda1SGreg Roach 655e933c21SGreg Roach $census = self::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 /** 73*82e78027SGreg 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 { 795e933c21SGreg Roach $individual = self::createMock(Individual::class); 805e933c21SGreg Roach $fact = self::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') 85109b3e30SGreg Roach ->withConsecutive( 86109b3e30SGreg Roach [['RELI']], 87109b3e30SGreg Roach [] 88109b3e30SGreg Roach ) 89109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 90109b3e30SGreg Roach new Collection(), 91109b3e30SGreg Roach new Collection([$fact]) 92109b3e30SGreg Roach ); 93cacefda1SGreg Roach 945e933c21SGreg Roach $census = self::createMock(CensusInterface::class); 95cacefda1SGreg Roach 96cacefda1SGreg Roach $column = new CensusColumnReligion($census, '', ''); 97cacefda1SGreg Roach 985e933c21SGreg Roach self::assertSame('Jedi', $column->generate($individual, $individual)); 99cacefda1SGreg Roach } 1004c219c47SGreg Roach} 101