14c219c47SGreg Roach<?php 23976b470SGreg Roach 34c219c47SGreg Roach/** 44c219c47SGreg Roach * webtrees: online genealogy 55e933c21SGreg Roach * Copyright (C) 2020 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 154c219c47SGreg Roach * along with this program. If not, see <http://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 /** 33cacefda1SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation 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 41*109b3e30SGreg Roach ->expects(self::exactly(2)) 42cacefda1SGreg Roach ->method('facts') 43*109b3e30SGreg Roach ->withConsecutive([['RELI']], []) 44*109b3e30SGreg 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 /** 54cacefda1SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation 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 /** 73cacefda1SGreg Roach * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation 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 83*109b3e30SGreg Roach ->expects(self::exactly(2)) 84cacefda1SGreg Roach ->method('facts') 85*109b3e30SGreg Roach ->withConsecutive( 86*109b3e30SGreg Roach [['RELI']], 87*109b3e30SGreg Roach [] 88*109b3e30SGreg Roach ) 89*109b3e30SGreg Roach ->willReturnOnConsecutiveCalls( 90*109b3e30SGreg Roach new Collection(), 91*109b3e30SGreg Roach new Collection([$fact]) 92*109b3e30SGreg 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