. */ 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\CensusColumnReligion * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * @return void */ public function testNoReligion(): void { $individual = $this->createMock(Individual::class); $individual ->expects(self::exactly(2)) ->method('facts') ->withConsecutive([['RELI']], []) ->willReturnOnConsecutiveCalls(new Collection(), new Collection()); $census = $this->createMock(CensusInterface::class); $column = new CensusColumnReligion($census, '', ''); self::assertSame('', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnReligion * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * @return void */ public function testRecordReligion(): void { $individual = $this->createMock(Individual::class); $fact = $this->createMock(Fact::class); $fact->method('value')->willReturn('Jedi'); $individual->method('facts')->with(['RELI'])->willReturn(new Collection([$fact])); $census = $this->createMock(CensusInterface::class); $column = new CensusColumnReligion($census, '', ''); self::assertSame('Jedi', $column->generate($individual, $individual)); } /** * @covers \Fisharebest\Webtrees\Census\CensusColumnReligion * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn * @return void */ public function testEventReligion(): void { $individual = $this->createMock(Individual::class); $fact = $this->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 = $this->createMock(CensusInterface::class); $column = new CensusColumnReligion($census, '', ''); self::assertSame('Jedi', $column->generate($individual, $individual)); } }