xref: /webtrees/tests/app/Census/CensusColumnOccupationTest.php (revision 5a8afed46297e8105e3e5a33ce37e6a8e88bc79d)
1db7d25eeSGreg Roach<?php
23976b470SGreg Roach
3db7d25eeSGreg Roach/**
4db7d25eeSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6db7d25eeSGreg Roach * This program is free software: you can redistribute it and/or modify
7db7d25eeSGreg Roach * it under the terms of the GNU General Public License as published by
8db7d25eeSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9db7d25eeSGreg Roach * (at your option) any later version.
10db7d25eeSGreg Roach * This program is distributed in the hope that it will be useful,
11db7d25eeSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12db7d25eeSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13db7d25eeSGreg Roach * GNU General Public License for more details.
14db7d25eeSGreg 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/>.
16db7d25eeSGreg Roach */
17fcfa147eSGreg Roach
18e7f56f2aSGreg Roachdeclare(strict_types=1);
19e7f56f2aSGreg Roach
20db7d25eeSGreg Roachnamespace Fisharebest\Webtrees\Census;
21db7d25eeSGreg Roach
220ecdbde6SGreg Roachuse Fisharebest\Webtrees\Fact;
23ddf438a5SGreg Roachuse Fisharebest\Webtrees\Individual;
243cfcc809SGreg Roachuse Fisharebest\Webtrees\TestCase;
2539ca88baSGreg Roachuse Illuminate\Support\Collection;
26*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
27db7d25eeSGreg Roach
28*202c018bSGreg Roach#[CoversClass(CensusColumnOccupation::class)]
29*202c018bSGreg Roach#[CoversClass(AbstractCensusColumn::class)]
303cfcc809SGreg Roachclass CensusColumnOccupationTest extends TestCase
31c1010edaSGreg Roach{
329b802b22SGreg Roach    public function testNoOccupation(): void
33c1010edaSGreg Roach    {
34cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
350ecdbde6SGreg Roach        $individual->method('facts')->with(['OCCU'])->willReturn(new Collection());
36db7d25eeSGreg Roach
37cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
38db7d25eeSGreg Roach
39ef21b467SGreg Roach        $column = new CensusColumnOccupation($census, '', '');
40db7d25eeSGreg Roach
415e933c21SGreg Roach        self::assertSame('', $column->generate($individual, $individual));
42db7d25eeSGreg Roach    }
43db7d25eeSGreg Roach
449b802b22SGreg Roach    public function testOccupation(): void
45c1010edaSGreg Roach    {
46cd94ca66SGreg Roach        $fact = $this->createMock(Fact::class);
470ecdbde6SGreg Roach        $fact->method('value')->willReturn('Farmer');
48db7d25eeSGreg Roach
49cd94ca66SGreg Roach        $individual = $this->createMock(Individual::class);
500ecdbde6SGreg Roach        $individual->method('facts')->with(['OCCU'])->willReturn(new Collection([$fact]));
51db7d25eeSGreg Roach
52cd94ca66SGreg Roach        $census = $this->createMock(CensusInterface::class);
53db7d25eeSGreg Roach
54ef21b467SGreg Roach        $column = new CensusColumnOccupation($census, '', '');
55db7d25eeSGreg Roach
565e933c21SGreg Roach        self::assertSame('Farmer', $column->generate($individual, $individual));
57db7d25eeSGreg Roach    }
58db7d25eeSGreg Roach}
59