summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@gmail.com>2021-04-12 19:03:53 +0100
committerGreg Roach <fisharebest@gmail.com>2021-04-12 19:06:57 +0100
commite3544cb20061a79019e02faf5430dbbf13b2d9aa (patch)
tree646bd98c46e2f5388b2ea9bd697044676a4b6b64 /tests
parent59500b5bcd75f28519c0e0c45715abeaef3a3d80 (diff)
downloadwebtrees-e3544cb20061a79019e02faf5430dbbf13b2d9aa.tar.gz
webtrees-e3544cb20061a79019e02faf5430dbbf13b2d9aa.tar.bz2
webtrees-e3544cb20061a79019e02faf5430dbbf13b2d9aa.zip
Fix: #2442 - turn map-links into modules
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Module/MapLinkBingModuleTest.php71
-rw-r--r--tests/app/Module/MapLinkGoogleModuleTest.php69
-rw-r--r--tests/app/Module/MapLinkOpenStreetMapModuleTest.php69
3 files changed, 209 insertions, 0 deletions
diff --git a/tests/app/Module/MapLinkBingModuleTest.php b/tests/app/Module/MapLinkBingModuleTest.php
new file mode 100644
index 0000000000..51ccfe8551
--- /dev/null
+++ b/tests/app/Module/MapLinkBingModuleTest.php
@@ -0,0 +1,71 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2021 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Module;
+
+use DOMDocument;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * @covers \Fisharebest\Webtrees\Module\MapLinkBingModule
+ * @covers \Fisharebest\Webtrees\Module\MapLinkTrait
+ */
+class MapLinkBingModuleTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testNoCoordinates(): void
+ {
+ $module = new MapLinkBingModule();
+
+ $fact = $this->createMock(Fact::class);
+ $fact->method('latitude')->willReturn(null);
+ $fact->method('longitude')->willReturn(null);
+
+ $html = $module->mapLink($fact);
+
+ $this->assertSame('', $html);
+ }
+
+ /**
+ * Test that the class exists
+ *
+ * @return void
+ */
+ public function testLink(): void
+ {
+ $module = new MapLinkBingModule();
+
+ $record = $this->createMock(Individual::class);
+ $record->method('fullName')->willReturn('FULL NAME');
+
+ $fact = $this->createMock(Fact::class);
+ $fact->method('latitude')->willReturn(54.321);
+ $fact->method('longitude')->willReturn(-1.2345);
+ $fact->method('label')->willReturn('LABEL');
+ $fact->method('record')->willReturn($record);
+
+ $html = $module->mapLink($fact);
+
+ self::assertTrue((new DOMDocument())->loadHTML($html), 'HTML=' . $html);
+ }
+}
diff --git a/tests/app/Module/MapLinkGoogleModuleTest.php b/tests/app/Module/MapLinkGoogleModuleTest.php
new file mode 100644
index 0000000000..8d70cec44c
--- /dev/null
+++ b/tests/app/Module/MapLinkGoogleModuleTest.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2021 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Module;
+
+use DOMDocument;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * @covers \Fisharebest\Webtrees\Module\MapLinkBingModule
+ * @covers \Fisharebest\Webtrees\Module\MapLinkTrait
+ */
+class MapLinkGoogleModuleTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testNoCoordinates(): void
+ {
+ $module = new MapLinkGoogleModule();
+
+ $fact = $this->createMock(Fact::class);
+ $fact->method('latitude')->willReturn(null);
+ $fact->method('longitude')->willReturn(null);
+
+ $html = $module->mapLink($fact);
+
+ $this->assertSame('', $html);
+ }
+
+ /**
+ * @return void
+ */
+ public function testLink(): void
+ {
+ $module = new MapLinkGoogleModule();
+
+ $record = $this->createMock(Individual::class);
+ $record->method('fullName')->willReturn('FULL NAME');
+
+ $fact = $this->createMock(Fact::class);
+ $fact->method('latitude')->willReturn(54.321);
+ $fact->method('longitude')->willReturn(-1.2345);
+ $fact->method('label')->willReturn('LABEL');
+ $fact->method('record')->willReturn($record);
+
+ $html = $module->mapLink($fact);
+
+ self::assertTrue((new DOMDocument())->loadHTML($html), 'HTML=' . $html);
+ }
+}
diff --git a/tests/app/Module/MapLinkOpenStreetMapModuleTest.php b/tests/app/Module/MapLinkOpenStreetMapModuleTest.php
new file mode 100644
index 0000000000..8507538c0c
--- /dev/null
+++ b/tests/app/Module/MapLinkOpenStreetMapModuleTest.php
@@ -0,0 +1,69 @@
+<?php
+
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2021 webtrees development team
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Module;
+
+use DOMDocument;
+use Fisharebest\Webtrees\Fact;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * @covers \Fisharebest\Webtrees\Module\MapLinkOpenStreetMapModule
+ * @covers \Fisharebest\Webtrees\Module\MapLinkTrait
+ */
+class MapLinkOpenStreetMapModuleTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testNoCoordinates(): void
+ {
+ $module = new MapLinkOpenStreetMapModule();
+
+ $fact = $this->createMock(Fact::class);
+ $fact->method('latitude')->willReturn(null);
+ $fact->method('longitude')->willReturn(null);
+
+ $html = $module->mapLink($fact);
+
+ $this->assertSame('', $html);
+ }
+
+ /**
+ * @return void
+ */
+ public function testLink(): void
+ {
+ $module = new MapLinkOpenStreetMapModule();
+
+ $record = $this->createMock(Individual::class);
+ $record->method('fullName')->willReturn('FULL NAME');
+
+ $fact = $this->createMock(Fact::class);
+ $fact->method('latitude')->willReturn(54.321);
+ $fact->method('longitude')->willReturn(-1.2345);
+ $fact->method('label')->willReturn('LABEL');
+ $fact->method('record')->willReturn($record);
+
+ $html = $module->mapLink($fact);
+
+ self::assertTrue((new DOMDocument())->loadHTML($html), 'HTML=' . $html);
+ }
+}