. */ declare(strict_types=1); namespace Fisharebest\Webtrees\Census; use Fisharebest\Webtrees\Fact; use Fisharebest\Webtrees\Individual; use Fisharebest\Webtrees\TestCase; use Illuminate\Support\Collection; /** * Test harness for the class CensusColumnReligion */ class CensusColumnReligionTest extends TestCase { /** * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * @return void */ public function testNoReligion(): void { $individual = self::createMock(Individual::class); $individual ->expects(self::exactly(2)) ->method('facts') ->withConsecutive([['RELI']], []) ->willReturnOnConsecutiveCalls(new Collection(), new Collection()); $census = self::createMock(CensusInterface::class); $column = new CensusColumnReligion($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * @return void */ public function testRecordReligion(): void { $individual = self::createMock(Individual::class); $fact = self::createMock(Fact::class); $fact->method('value')->willReturn('Jedi'); $individual->method('facts')->with(['RELI'])->willReturn(new Collection([$fact])); $census = self::createMock(CensusInterface::class); $column = new CensusColumnReligion($census, '', ''); self::assertSame('Jedi', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * @return void */ public function testEventReligion(): void { $individual = self::createMock(Individual::class); $fact = self::createMock(Fact::class); $fact->method('attribute')->with('RELI')->willReturn('Jedi'); $individual ->expects(self::exactly(2)) ->method('facts') ->withConsecutive( [['RELI']], [] ) ->willReturnOnConsecutiveCalls( new Collection(), new Collection([$fact]) ); $census = self::createMock(CensusInterface::class); $column = new CensusColumnReligion($census, '', ''); self::assertSame('Jedi', $column->generate($individual, $individual)); } }