xref: /webtrees/tests/app/Census/CensusColumnReligionTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
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;
26*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
274c219c47SGreg Roach
28*202c018bSGreg Roach#[CoversClass(CensusColumnReligion::class)]
29*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
303cfcc809SGreg Roachclass CensusColumnReligionTest extends TestCase
31c1010edaSGreg Roach{
32cacefda1SGreg Roach    public function testNoReligion(): void
33c1010edaSGreg Roach    {
34cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
35cacefda1SGreg Roach        $individual
36109b3e30SGreg Roach            ->expects(self::exactly(2))
37cacefda1SGreg Roach            ->method('facts')
389aef375dSGreg Roach            ->with(self::withConsecutive([['RELI'], []]))
39109b3e30SGreg Roach            ->willReturnOnConsecutiveCalls(new Collection(), new Collection());
404c219c47SGreg Roach
41cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
424c219c47SGreg Roach
434c219c47SGreg Roach        $column = new CensusColumnReligion($census, '', '');
444c219c47SGreg Roach
455e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
464c219c47SGreg Roach    }
47cacefda1SGreg Roach
48cacefda1SGreg Roach    public function testRecordReligion(): void
49cacefda1SGreg Roach    {
50cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
51cd94ca66SGreg Roach        $fact       = $this->createMock(Fact::class);
52cacefda1SGreg Roach        $fact->method('value')->willReturn('Jedi');
53cacefda1SGreg Roach        $individual->method('facts')->with(['RELI'])->willReturn(new Collection([$fact]));
54cacefda1SGreg Roach
55cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
56cacefda1SGreg Roach
57cacefda1SGreg Roach        $column = new CensusColumnReligion($census, '', '');
58cacefda1SGreg Roach
595e933c21SGreg Roach        self::assertSame('Jedi', $column->generate($individual, $individual));
60cacefda1SGreg Roach    }
61cacefda1SGreg Roach
62cacefda1SGreg Roach    public function testEventReligion(): void
63cacefda1SGreg Roach    {
64cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
65cd94ca66SGreg Roach        $fact       = $this->createMock(Fact::class);
66cacefda1SGreg Roach        $fact->method('attribute')->with('RELI')->willReturn('Jedi');
67cacefda1SGreg Roach        $individual
68109b3e30SGreg Roach            ->expects(self::exactly(2))
69cacefda1SGreg Roach            ->method('facts')
709aef375dSGreg Roach            ->with(self::withConsecutive([['RELI'], []]))
71109b3e30SGreg Roach            ->willReturnOnConsecutiveCalls(
72109b3e30SGreg Roach                new Collection(),
73109b3e30SGreg Roach                new Collection([$fact])
74109b3e30SGreg Roach            );
75cacefda1SGreg Roach
76cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
77cacefda1SGreg Roach
78cacefda1SGreg Roach        $column = new CensusColumnReligion($census, '', '');
79cacefda1SGreg Roach
805e933c21SGreg Roach        self::assertSame('Jedi', $column->generate($individual, $individual));
81cacefda1SGreg Roach    }
824c219c47SGreg Roach}
83