xref: /webtrees/tests/app/Module/MapLinkBingTest.php (revision 202c018b592d5a516e4a465dc6dc515f3be37399)
1c9c6f2ecSGreg Roach<?php
2c9c6f2ecSGreg Roach
3c9c6f2ecSGreg Roach/**
4c9c6f2ecSGreg Roach * webtrees: online genealogy
5d11be702SGreg Roach * Copyright (C) 2023 webtrees development team
6c9c6f2ecSGreg Roach * This program is free software: you can redistribute it and/or modify
7c9c6f2ecSGreg Roach * it under the terms of the GNU General Public License as published by
8c9c6f2ecSGreg Roach * the Free Software Foundation, either version 3 of the License, or
9c9c6f2ecSGreg Roach * (at your option) any later version.
10c9c6f2ecSGreg Roach * This program is distributed in the hope that it will be useful,
11c9c6f2ecSGreg Roach * but WITHOUT ANY WARRANTY; without even the implied warranty of
12c9c6f2ecSGreg Roach * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13c9c6f2ecSGreg Roach * GNU General Public License for more details.
14c9c6f2ecSGreg Roach * You should have received a copy of the GNU General Public License
15c9c6f2ecSGreg Roach * along with this program. If not, see <https://www.gnu.org/licenses/>.
16c9c6f2ecSGreg Roach */
17c9c6f2ecSGreg Roach
18c9c6f2ecSGreg Roachdeclare(strict_types=1);
19c9c6f2ecSGreg Roach
20c9c6f2ecSGreg Roachnamespace Fisharebest\Webtrees\Module;
21c9c6f2ecSGreg Roach
22c9c6f2ecSGreg Roachuse DOMDocument;
23c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Fact;
24c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\Individual;
25c9c6f2ecSGreg Roachuse Fisharebest\Webtrees\TestCase;
26*202c018bSGreg Roachuse PHPUnit\Framework\Attributes\CoversClass;
27c9c6f2ecSGreg Roach
28*202c018bSGreg Roach#[CoversClass(MapLinkBing::class)]
29*202c018bSGreg Roach#[CoversClass(ModuleMapLinkTrait::class)]
30c9c6f2ecSGreg Roachclass MapLinkBingTest extends TestCase
31c9c6f2ecSGreg Roach{
32c9c6f2ecSGreg Roach    public function testNoCoordinates(): void
33c9c6f2ecSGreg Roach    {
34c9c6f2ecSGreg Roach        $module = new MapLinkBing();
35c9c6f2ecSGreg Roach
36c9c6f2ecSGreg Roach        $fact = $this->createMock(Fact::class);
37c9c6f2ecSGreg Roach        $fact->method('latitude')->willReturn(null);
38c9c6f2ecSGreg Roach        $fact->method('longitude')->willReturn(null);
39c9c6f2ecSGreg Roach
40c9c6f2ecSGreg Roach        $html = $module->mapLink($fact);
41c9c6f2ecSGreg Roach
42f01ab4acSGreg Roach        static::assertSame('', $html);
43c9c6f2ecSGreg Roach    }
44c9c6f2ecSGreg Roach
45c9c6f2ecSGreg Roach    /**
46c9c6f2ecSGreg Roach     * Test that the class exists
47c9c6f2ecSGreg Roach     */
48c9c6f2ecSGreg Roach    public function testLink(): void
49c9c6f2ecSGreg Roach    {
50c9c6f2ecSGreg Roach        $module = new MapLinkBing();
51c9c6f2ecSGreg Roach
52c9c6f2ecSGreg Roach        $record = $this->createMock(Individual::class);
53c9c6f2ecSGreg Roach        $record->method('fullName')->willReturn('FULL NAME');
54c9c6f2ecSGreg Roach
55c9c6f2ecSGreg Roach        $fact = $this->createMock(Fact::class);
56c9c6f2ecSGreg Roach        $fact->method('latitude')->willReturn(54.321);
57c9c6f2ecSGreg Roach        $fact->method('longitude')->willReturn(-1.2345);
58c9c6f2ecSGreg Roach        $fact->method('label')->willReturn('LABEL');
59c9c6f2ecSGreg Roach        $fact->method('record')->willReturn($record);
60c9c6f2ecSGreg Roach
61c9c6f2ecSGreg Roach        $html = $module->mapLink($fact);
62c9c6f2ecSGreg Roach
63c9c6f2ecSGreg Roach        self::assertTrue((new DOMDocument())->loadHTML($html), 'HTML=' . $html);
64c9c6f2ecSGreg Roach    }
65c9c6f2ecSGreg Roach}
66