xref: /webtrees/tests/app/Census/CensusColumnReligionTest.php (revision 0e2e57bd5c8dad261d043770bf646c2285b4eaca)
1<?php
2
3/**
4 * webtrees: online genealogy
5 * Copyright (C) 2020 webtrees development team
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18declare(strict_types=1);
19
20namespace Fisharebest\Webtrees\Census;
21
22use Fisharebest\Webtrees\Fact;
23use Fisharebest\Webtrees\Individual;
24use Fisharebest\Webtrees\TestCase;
25use Illuminate\Support\Collection;
26
27/**
28 * Test harness for the class CensusColumnReligion
29 */
30class CensusColumnReligionTest extends TestCase
31{
32    /**
33     * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation
34     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
35     * @return void
36     */
37    public function testNoReligion(): void
38    {
39        $individual = self::createMock(Individual::class);
40        $individual
41            ->expects(self::at(0))
42            ->method('facts')
43            ->with(['RELI'])
44            ->willReturn(new Collection());
45        $individual
46            ->expects(self::at(1))
47            ->method('facts')
48            ->with()
49            ->willReturn(new Collection());
50
51        $census = self::createMock(CensusInterface::class);
52
53        $column = new CensusColumnReligion($census, '', '');
54
55        self::assertSame('', $column->generate($individual, $individual));
56    }
57
58    /**
59     * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation
60     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
61     * @return void
62     */
63    public function testRecordReligion(): void
64    {
65        $individual = self::createMock(Individual::class);
66        $fact       = self::createMock(Fact::class);
67        $fact->method('value')->willReturn('Jedi');
68        $individual->method('facts')->with(['RELI'])->willReturn(new Collection([$fact]));
69
70        $census = self::createMock(CensusInterface::class);
71
72        $column = new CensusColumnReligion($census, '', '');
73
74        self::assertSame('Jedi', $column->generate($individual, $individual));
75    }
76
77    /**
78     * @covers \Fisharebest\Webtrees\Census\CensusColumnOccupation
79     * @covers \Fisharebest\Webtrees\Census\AbstractCensusColumn
80     * @return void
81     */
82    public function testEventReligion(): void
83    {
84        $individual = self::createMock(Individual::class);
85        $fact       = self::createMock(Fact::class);
86        $fact->method('attribute')->with('RELI')->willReturn('Jedi');
87        $individual
88            ->expects(self::at(0))
89            ->method('facts')
90            ->with(['RELI'])
91            ->willReturn(new Collection());
92        $individual
93            ->expects(self::at(1))
94            ->method('facts')
95            ->with()
96            ->willReturn(new Collection([$fact]));
97
98        $census = self::createMock(CensusInterface::class);
99
100        $column = new CensusColumnReligion($census, '', '');
101
102        self::assertSame('Jedi', $column->generate($individual, $individual));
103    }
104}
105