summaryrefslogtreecommitdiff
path: root/tests/app/Http/RequestHandlers
diff options
context:
space:
mode:
Diffstat (limited to 'tests/app/Http/RequestHandlers')
-rw-r--r--tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php155
-rw-r--r--tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php143
-rw-r--r--tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php89
-rw-r--r--tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php155
-rw-r--r--tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php151
-rw-r--r--tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php150
-rw-r--r--tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php138
-rw-r--r--tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php155
-rw-r--r--tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php138
-rw-r--r--tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php155
-rw-r--r--tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php161
-rw-r--r--tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php141
-rw-r--r--tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php161
-rw-r--r--tests/app/Http/RequestHandlers/RedirectModulePhpTest.php300
-rw-r--r--tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectNotePhpTest.php138
-rw-r--r--tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php155
-rw-r--r--tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php155
-rw-r--r--tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php89
-rw-r--r--tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php138
-rw-r--r--tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php132
-rw-r--r--tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php138
-rw-r--r--tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php135
-rw-r--r--tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php155
29 files changed, 4219 insertions, 0 deletions
diff --git a/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php b/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php
new file mode 100644
index 0000000000..3347d32629
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectAncestryPhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\AncestorsChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectAncestryPhp
+ */
+class RedirectAncestryPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(AncestorsChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(AncestorsChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectAncestryPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(AncestorsChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectAncestryPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(AncestorsChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(AncestorsChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectAncestryPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php b/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php
new file mode 100644
index 0000000000..ff365cd61d
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectBranchesPhpTest.php
@@ -0,0 +1,143 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\BranchesListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectBranchesPhp
+ */
+class RedirectBranchesPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(BranchesListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(BranchesListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectBranchesPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'surname' => 'XYZ'],
+ [],
+ [],
+ ['base_url' => 'https://www.example.com']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame(
+ 'https://www.example.com/index.php?route=%2F%2FPage%2Ftree1&surname=XYZ',
+ $response->getHeaderLine('Location')
+ );
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(BranchesListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectBranchesPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'surname' => 'XYZ']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(BranchesListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(BranchesListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectBranchesPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'surname' => 'XYZ']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php b/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php
new file mode 100644
index 0000000000..c86a5eb611
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectCalendarPhpTest.php
@@ -0,0 +1,89 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectCalendarPhp
+ */
+class RedirectCalendarPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $handler = new RedirectCalendarPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1'],
+ [],
+ [],
+ ['base_url' => 'https://www.example.com']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame(
+ 'https://www.example.com/index.php?route=%2Ftree1%2Fcalendar%2Fday',
+ $response->getHeaderLine('Location')
+ );
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectCalendarPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php b/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php
new file mode 100644
index 0000000000..1ed1316ab6
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectCompactPhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\CompactTreeChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectCompactPhp
+ */
+class RedirectCompactPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(CompactTreeChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(CompactTreeChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectCompactPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(CompactTreeChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectCompactPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(CompactTreeChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(CompactTreeChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectCompactPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php b/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php
new file mode 100644
index 0000000000..3bf292fe8d
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectDescendancyPhpTest.php
@@ -0,0 +1,151 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\DescendancyChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectDescendencyPhp
+ */
+class RedirectDescendancyPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $descendancy_chart = $this->createStub(DescendancyChartModule::class);
+ $descendancy_chart
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(DescendancyChartModule::class)
+ ->willReturn(new Collection([$descendancy_chart]));
+
+ $handler = new RedirectDescendencyPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(DescendancyChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectDescendencyPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(DescendancyChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(DescendancyChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectDescendencyPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php
new file mode 100644
index 0000000000..98db0358d0
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectFamListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\FamilyListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamListPhp
+ */
+class RedirectFamListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(FamilyListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(FamilyListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectFamListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(FamilyListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectFamListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(FamilyListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(FamilyListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectFamListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php
new file mode 100644
index 0000000000..8770e63517
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectFamilyBookPhpTest.php
@@ -0,0 +1,150 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\FamilyBookChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamilyBookPhp
+ */
+class RedirectFamilyBookPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $Compact_chart = $this->createStub(FamilyBookChartModule::class);
+ $Compact_chart
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(FamilyBookChartModule::class)
+ ->willReturn(new Collection([$Compact_chart]));
+
+ $handler = new RedirectFamilyBookPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1', 'rootid' => 'X123']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(FamilyBookChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+ $handler = new RedirectFamilyBookPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(FamilyBookChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(FamilyBookChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectFamilyBookPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php
new file mode 100644
index 0000000000..38a17b0897
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectFamilyPhpTest.php
@@ -0,0 +1,138 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\FamilyFactory;
+use Fisharebest\Webtrees\Family;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectFamilyPhp
+ */
+class RedirectFamilyPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $family = $this->createStub(Family::class);
+ $family
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $family_factory = $this->createStub(FamilyFactory::class);
+ $family_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($family);
+
+ Registry::familyFactory($family_factory);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'famid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'famid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['famid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php b/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php
new file mode 100644
index 0000000000..611d228191
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectFanChartPhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\FanChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectFanChartPhp
+ */
+class RedirectFanChartPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(FanChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(FanChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectFanChartPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(FanChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectFanChartPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(FanChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(FanChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectFanChartPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php b/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php
new file mode 100644
index 0000000000..b053631e07
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectGedRecordPhpTest.php
@@ -0,0 +1,138 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\GedcomRecordFactory;
+use Fisharebest\Webtrees\GedcomRecord;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectGedRecordPhp
+ */
+class RedirectGedRecordPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $gedcom_record = $this->createStub(GedcomRecord::class);
+ $gedcom_record
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $gedcom_record_factory = $this->createStub(GedcomRecordFactory::class);
+ $gedcom_record_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($gedcom_record);
+
+ Registry::gedcomRecordFactory($gedcom_record_factory);
+
+ $handler = new RedirectGedRecordPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectGedRecordPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectGedRecordPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['pid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectGedRecordPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php b/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php
new file mode 100644
index 0000000000..2ae1178b68
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectHourGlassPhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\HourglassChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectHourGlassPhp
+ */
+class RedirectHourGlassPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(HourglassChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(HourglassChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectHourGlassPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(HourglassChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectHourGlassPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(HourglassChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(HourglassChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectHourGlassPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php
new file mode 100644
index 0000000000..8f4567ac5f
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectIndiListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\IndividualListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectIndiListPhp
+ */
+class RedirectIndiListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(IndividualListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(IndividualListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectIndiListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(IndividualListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectIndiListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(IndividualListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(IndividualListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectIndiListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php b/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php
new file mode 100644
index 0000000000..a146a2691d
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectIndividualPhpTest.php
@@ -0,0 +1,161 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectIndividualPhp
+ */
+class RedirectIndividualPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+ $individual
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $handler = new RedirectIndividualPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectIndividualPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectIndividualPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['pid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php b/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php
new file mode 100644
index 0000000000..242bd4d471
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectLifeSpanPhpTest.php
@@ -0,0 +1,141 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\LifespansChartModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectLifeSpanPhp
+ */
+class RedirectLifeSpanPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(LifespansChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(LifespansChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectLifeSpanPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(LifespansChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectLifeSpanPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(LifespansChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(LifespansChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectLifeSpanPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php
new file mode 100644
index 0000000000..4192e541df
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectMediaListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\MediaListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectMediaListPhp
+ */
+class RedirectMediaListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(MediaListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(MediaListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectMediaListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(MediaListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectMediaListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(MediaListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(MediaListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectMediaListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php b/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php
new file mode 100644
index 0000000000..8e292f7402
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectMediaViewerPhpTest.php
@@ -0,0 +1,161 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\MediaFactory;
+use Fisharebest\Webtrees\Media;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectMediaViewerPhp
+ */
+class RedirectMediaViewerPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $media = $this->createStub(Media::class);
+ $media
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $media_factory = $this->createStub(MediaFactory::class);
+ $media_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($media);
+
+ Registry::mediaFactory($media_factory);
+
+ $handler = new RedirectMediaViewerPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'mid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectMediaViewerPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'mid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectMediaViewerPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'mid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['mid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectFamilyPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php b/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php
new file mode 100644
index 0000000000..8f7d416a49
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectModulePhpTest.php
@@ -0,0 +1,300 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\InteractiveTreeModule;
+use Fisharebest\Webtrees\Module\PedigreeMapModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectModulePhp
+ */
+class RedirectModulePhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirectPedigreeMap(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(PedigreeMapModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(PedigreeMapModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectModulePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['mod' => 'googlemap', 'mod_action' => 'pedigree_map', 'ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testRedirectInteractiveTree(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(InteractiveTreeModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(InteractiveTreeModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectModulePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['mod' => 'tree', 'mod_action' => 'treeview', 'ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectModulePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchIndividual(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn(null);
+
+ Registry::individualFactory($individual_factory);
+ $module_service = $this->createStub(ModuleService::class);
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $handler = new RedirectModulePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testPedigreeMapModuleDisabled(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(PedigreeMapModule::class)
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectModulePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['mod' => 'googlemap', 'mod_action' => 'pedigree_map', 'ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testInteractiveTreeModuleDisabled(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(InteractiveTreeModule::class)
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectModulePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['mod' => 'tree', 'mod_action' => 'treeview', 'ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php
new file mode 100644
index 0000000000..1e3c3f7142
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectNoteListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\NoteListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectNoteListPhp
+ */
+class RedirectNoteListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(NoteListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(NoteListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectNoteListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(NoteListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectNoteListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(NoteListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(NoteListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectNoteListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php b/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php
new file mode 100644
index 0000000000..eecb970234
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectNotePhpTest.php
@@ -0,0 +1,138 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\NoteFactory;
+use Fisharebest\Webtrees\Note;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectNotePhp
+ */
+class RedirectNotePhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $note = $this->createStub(Note::class);
+ $note
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $note_factory = $this->createStub(NoteFactory::class);
+ $note_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($note);
+
+ Registry::noteFactory($note_factory);
+
+ $handler = new RedirectNotePhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'nid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectNotePhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'nid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectNotePhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['nid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectNotePhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php b/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php
new file mode 100644
index 0000000000..703dd3c140
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectPedigreePhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\PedigreeChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectPedigreePhp
+ */
+class RedirectPedigreePhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(PedigreeChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(PedigreeChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectPedigreePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(PedigreeChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectPedigreePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(PedigreeChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(PedigreeChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectPedigreePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rootid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php
new file mode 100644
index 0000000000..359c4c96e2
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectPlaceListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\PlaceHierarchyListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectPlaceListPhp
+ */
+class RedirectPlaceListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(PlaceHierarchyListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(PlaceHierarchyListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectPlaceListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(PlaceHierarchyListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectPlaceListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(PlaceHierarchyListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(PlaceHierarchyListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectPlaceListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php b/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php
new file mode 100644
index 0000000000..6b360b9587
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectRelationshipPhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\RelationshipsChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectRelationshipPhp
+ */
+class RedirectRelationshipPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(RelationshipsChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(RelationshipsChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectRelationshipPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid1' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(RelationshipsChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectRelationshipPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid1' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(RelationshipsChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(RelationshipsChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectRelationshipPhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pid1' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php
new file mode 100644
index 0000000000..3d742257b7
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectRepoListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\RepositoryListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectRepoListPhp
+ */
+class RedirectRepoListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(RepositoryListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(RepositoryListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectRepoListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(RepositoryListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectRepoListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(RepositoryListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(RepositoryListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectRepoListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php b/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php
new file mode 100644
index 0000000000..b1764489ec
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectReportEnginePhpTest.php
@@ -0,0 +1,89 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectReportEnginePhp
+ */
+class RedirectReportEnginePhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $handler = new RedirectReportEnginePhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'action' => 'run'],
+ [],
+ [],
+ ['base_url' => 'https://www.example.com']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame(
+ 'https://www.example.com/index.php?route=%2Ftree1%2Freport-run%2F&ged=tree1&action=run',
+ $response->getHeaderLine('Location')
+ );
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectReportEnginePhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php b/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php
new file mode 100644
index 0000000000..ffd78f801c
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectRepositoryPhpTest.php
@@ -0,0 +1,138 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\RepositoryFactory;
+use Fisharebest\Webtrees\Repository;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectRepositoryPhp
+ */
+class RedirectRepositoryPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $repository = $this->createStub(Repository::class);
+ $repository
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $repository_factory = $this->createStub(RepositoryFactory::class);
+ $repository_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($repository);
+
+ Registry::repositoryFactory($repository_factory);
+
+ $handler = new RedirectRepositoryPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectRepositoryPhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'rid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectRepositoryPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['rid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectRepositoryPhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php b/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php
new file mode 100644
index 0000000000..67d3435bb7
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectSourceListPhpTest.php
@@ -0,0 +1,132 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Module\SourceListModule;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectSourceListPhp
+ */
+class RedirectSourceListPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(SourceListModule::class);
+ $module
+ ->expects(self::once())
+ ->method('listUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(SourceListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectSourceListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(SourceListModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectSourceListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(SourceListModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(SourceListModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectSourceListPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php b/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php
new file mode 100644
index 0000000000..6e3a0811de
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectSourcePhpTest.php
@@ -0,0 +1,138 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\SourceFactory;
+use Fisharebest\Webtrees\Source;
+use Fisharebest\Webtrees\Http\Exceptions\HttpBadRequestException;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectSourcePhp
+ */
+class RedirectSourcePhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $source = $this->createStub(Source::class);
+ $source
+ ->method('url')
+ ->willReturn('https://www.example.com');
+
+ $source_factory = $this->createStub(SourceFactory::class);
+ $source_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($source);
+
+ Registry::sourceFactory($source_factory);
+
+ $handler = new RedirectSourcePhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'sid' => 'X123']
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchRecord(): void
+ {
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectSourcePhp($tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'sid' => 'X123']
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingTreeParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectSourcePhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['sid' => 'X123']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testMissingXrefParameter(): void
+ {
+ $tree_service = $this->createStub(TreeService::class);
+
+ $handler = new RedirectSourcePhp($tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpBadRequestException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php b/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php
new file mode 100644
index 0000000000..12d2b689c7
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectStatisticsPhpTest.php
@@ -0,0 +1,135 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\StatisticsChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectStatisticsPhp
+ */
+class RedirectStatisticsPhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $module = $this->createStub(StatisticsChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(StatisticsChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectStatisticsPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(StatisticsChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectStatisticsPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(StatisticsChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(StatisticsChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectStatisticsPhp($module_service, $tree_service);
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['ged' => 'tree1']);
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php b/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php
new file mode 100644
index 0000000000..47d6ae9f87
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/RedirectTimeLinePhpTest.php
@@ -0,0 +1,155 @@
+<?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\Http\RequestHandlers;
+
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Factories\IndividualFactory;
+use Fisharebest\Webtrees\Http\Exceptions\HttpNotFoundException;
+use Fisharebest\Webtrees\Individual;
+use Fisharebest\Webtrees\Module\TimelineChartModule;
+use Fisharebest\Webtrees\Registry;
+use Fisharebest\Webtrees\Services\ModuleService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+use Fisharebest\Webtrees\Tree;
+use Illuminate\Support\Collection;
+
+/**
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\RedirectTimeLinePhp
+ */
+class RedirectTimeLinePhpTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testRedirect(): void
+ {
+ $tree = $this->createStub(Tree::class);
+ $tree
+ ->method('name')
+ ->willReturn('tree1');
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection(['tree1' => $tree]));
+
+ $individual = $this->createStub(Individual::class);
+
+ $individual_factory = $this->createStub(IndividualFactory::class);
+ $individual_factory
+ ->expects(self::once())
+ ->method('make')
+ ->with('X123', $tree)
+ ->willReturn($individual);
+
+ Registry::individualFactory($individual_factory);
+
+ $module = $this->createStub(TimelineChartModule::class);
+ $module
+ ->expects(self::once())
+ ->method('chartUrl')
+ ->willReturn('https://www.example.com');
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(TimelineChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $handler = new RedirectTimeLinePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pids' => ['X123']]
+ );
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_MOVED_PERMANENTLY, $response->getStatusCode());
+ self::assertSame('https://www.example.com', $response->getHeaderLine('Location'));
+ }
+
+ /**
+ * @return void
+ */
+ public function testModuleDisabled(): void
+ {
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())->method('findByInterface')
+ ->with(TimelineChartModule::class)
+ ->willReturn(new Collection());
+
+ $tree = $this->createStub(Tree::class);
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([$tree]));
+
+ $handler = new RedirectTimeLinePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pids' => ['X123']]
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testNoSuchTree(): void
+ {
+ $module = $this->createStub(TimelineChartModule::class);
+
+ $module_service = $this->createStub(ModuleService::class);
+ $module_service
+ ->expects(self::once())
+ ->method('findByInterface')
+ ->with(TimelineChartModule::class)
+ ->willReturn(new Collection([$module]));
+
+ $tree_service = $this->createStub(TreeService::class);
+ $tree_service
+ ->expects(self::once())
+ ->method('all')
+ ->willReturn(new Collection([]));
+
+ $handler = new RedirectTimeLinePhp($module_service, $tree_service);
+
+ $request = self::createRequest(
+ RequestMethodInterface::METHOD_GET,
+ ['ged' => 'tree1', 'pids' => ['X123']]
+ );
+
+ $this->expectException(HttpNotFoundException::class);
+
+ $handler->handle($request);
+ }
+}