summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGreg Roach <greg@subaqua.co.uk>2021-01-26 11:44:10 +0000
committerGreg Roach <greg@subaqua.co.uk>2021-01-26 13:57:16 +0000
commit4b3ef6caf72914d34581bb4a8d677e615e877a9b (patch)
treef79022245fefb5727eb6b17c78c1189f29b69c15 /tests
parent89f7189b61a494347591c99bdb92afb7d8b66e1b (diff)
downloadwebtrees-4b3ef6caf72914d34581bb4a8d677e615e877a9b.tar.gz
webtrees-4b3ef6caf72914d34581bb4a8d677e615e877a9b.tar.bz2
webtrees-4b3ef6caf72914d34581bb4a8d677e615e877a9b.zip
Convert controller to request handlers
Diffstat (limited to 'tests')
-rw-r--r--tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php84
-rw-r--r--tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php83
-rw-r--r--tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php54
-rw-r--r--tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php51
-rw-r--r--tests/app/Http/RequestHandlers/FixLevel0MediaPageTest.php43
-rw-r--r--tests/app/Http/RequestHandlers/ImportThumbnailsActionTest.php51
-rw-r--r--tests/app/Http/RequestHandlers/ImportThumbnailsDataTest.php49
-rw-r--r--tests/app/Http/RequestHandlers/ImportThumbnailsPageTest.php45
-rw-r--r--tests/app/Http/RequestHandlers/UpgradeWizardConfirmTest.php43
-rw-r--r--tests/app/Http/RequestHandlers/UpgradeWizardPageTest.php51
-rw-r--r--tests/app/Http/RequestHandlers/UpgradeWizardStepTest.php (renamed from tests/app/Http/Controllers/Admin/UpgradeControllerTest.php)102
11 files changed, 420 insertions, 236 deletions
diff --git a/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php b/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php
deleted file mode 100644
index f3be00dafd..0000000000
--- a/tests/app/Http/Controllers/Admin/FixLevel0MediaControllerTest.php
+++ /dev/null
@@ -1,84 +0,0 @@
-<?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\Controllers\Admin;
-
-use Fig\Http\Message\RequestMethodInterface;
-use Fig\Http\Message\StatusCodeInterface;
-use Fisharebest\Webtrees\Services\DatatablesService;
-use Fisharebest\Webtrees\Services\TreeService;
-use Fisharebest\Webtrees\TestCase;
-
-/**
- * Test FixLevel0MediaControllerTest class.
- *
- * @covers \Fisharebest\Webtrees\Http\Controllers\Admin\FixLevel0MediaController
- */
-class FixLevel0MediaControllerTest extends TestCase
-{
- protected static $uses_database = true;
-
- /**
- * @return void
- */
- public function testFixLevel0Media(): void
- {
- $datatables_service = new DatatablesService();
- $tree_service = new TreeService();
- $controller = new FixLevel0MediaController($datatables_service, $tree_service);
- $request = self::createRequest();
- $response = $controller->fixLevel0Media($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-
- /**
- * @return void
- */
- public function testFixLevel0MediaAction(): void
- {
- $tree_service = new TreeService();
- $tree = $tree_service->create('name', 'title');
- $controller = new FixLevel0MediaController(new DatatablesService(), $tree_service);
- $request = self::createRequest(RequestMethodInterface::METHOD_POST, [], [
- 'tree_id' => $tree->id(),
- 'fact_id' => '',
- 'indi_xref' => '',
- 'obje_xref' => '',
- ]);
- $response = $controller->fixLevel0MediaAction($request);
-
- self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode());
- }
-
- /**
- * @return void
- */
- public function testFixLevel0MediaData(): void
- {
- $datatables_service = new DatatablesService();
- $tree_service = new TreeService();
- $tree = $tree_service->create('name', 'title');
- $controller = new FixLevel0MediaController($datatables_service, $tree_service);
- $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['tree_id' => $tree->id()]);
- $response = $controller->fixLevel0MediaData($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-}
diff --git a/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php b/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php
deleted file mode 100644
index 470964ad64..0000000000
--- a/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php
+++ /dev/null
@@ -1,83 +0,0 @@
-<?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\Controllers\Admin;
-
-use Fig\Http\Message\StatusCodeInterface;
-use Fisharebest\Webtrees\Services\PendingChangesService;
-use Fisharebest\Webtrees\Services\SearchService;
-use Fisharebest\Webtrees\Services\TreeService;
-use Fisharebest\Webtrees\TestCase;
-
-/**
- * Test ImportThumbnailsController class.
- *
- * @covers \Fisharebest\Webtrees\Http\Controllers\Admin\ImportThumbnailsController
- */
-class ImportThumbnailsControllerTest extends TestCase
-{
- protected static $uses_database = true;
-
- /**
- * @return void
- */
- public function testWebtrees1Thumbnails(): void
- {
- $tree_service = new TreeService();
- $search_service = new SearchService($tree_service);
- $tree_service = new TreeService();
- $pending_changes_service = new PendingChangesService();
- $controller = new ImportThumbnailsController($pending_changes_service, $search_service, $tree_service);
- $request = self::createRequest();
- $response = $controller->webtrees1Thumbnails($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-
- /**
- * @return void
- */
- public function testWebtrees1ThumbnailsAction(): void
- {
- $tree_service = new TreeService();
- $search_service = new SearchService($tree_service);
- $pending_changes_service = new PendingChangesService();
- $controller = new ImportThumbnailsController($pending_changes_service, $search_service, $tree_service);
- $request = self::createRequest()
- ->withParsedBody(['thumbnail' => 'foo', 'action' => '', 'xref' => [], 'ged' => []]);
- $response = $controller->webtrees1ThumbnailsAction($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-
- /**
- * @return void
- */
- public function testWebtrees1ThumbnailsData(): void
- {
- $tree_service = new TreeService();
- $search_service = new SearchService($tree_service);
- $pending_changes_service = new PendingChangesService();
- $controller = new ImportThumbnailsController($pending_changes_service, $search_service, $tree_service);
- $request = self::createRequest()->withQueryParams(['start' => '0', 'length' => '10', 'search' => ['value' => ''], 'draw' => '1']);
- $response = $controller->webtrees1ThumbnailsData($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-}
diff --git a/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php b/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php
new file mode 100644
index 0000000000..06abcaba78
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/FixLevel0MediaActionTest.php
@@ -0,0 +1,54 @@
+<?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\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test FixLevel0MediaActionTest class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaActionTest
+ */
+class FixLevel0MediaActionTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testFixLevel0MediaAction(): void
+ {
+ $tree_service = new TreeService();
+ $tree = $tree_service->create('name', 'title');
+ $handler = new FixLevel0MediaAction($tree_service);
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, [], [
+ 'tree_id' => $tree->id(),
+ 'fact_id' => '',
+ 'indi_xref' => '',
+ 'obje_xref' => '',
+ ]);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php b/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php
new file mode 100644
index 0000000000..687f778145
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/FixLevel0MediaDataTest.php
@@ -0,0 +1,51 @@
+<?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\Services\DatatablesService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test FixLevel0MediaDataTest class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaDataTest
+ */
+class FixLevel0MediaDataTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testFixLevel0MediaData(): void
+ {
+ $datatables_service = new DatatablesService();
+ $tree_service = new TreeService();
+ $tree = $tree_service->create('name', 'title');
+ $handler = new FixLevel0MediaData($datatables_service, $tree_service);
+ $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['tree_id' => $tree->id()]);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/FixLevel0MediaPageTest.php b/tests/app/Http/RequestHandlers/FixLevel0MediaPageTest.php
new file mode 100644
index 0000000000..a7c48b9170
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/FixLevel0MediaPageTest.php
@@ -0,0 +1,43 @@
+<?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\StatusCodeInterface;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test FixLevel0MediaPageTest class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\FixLevel0MediaPageTest
+ */
+class FixLevel0MediaPageTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testFixLevel0Media(): void
+ {
+ $handler = new FixLevel0MediaPage();
+ $request = self::createRequest();
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/ImportThumbnailsActionTest.php b/tests/app/Http/RequestHandlers/ImportThumbnailsActionTest.php
new file mode 100644
index 0000000000..666830fec1
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/ImportThumbnailsActionTest.php
@@ -0,0 +1,51 @@
+<?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\StatusCodeInterface;
+use Fisharebest\Webtrees\Services\PendingChangesService;
+use Fisharebest\Webtrees\Services\SearchService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test ImportThumbnailsAction class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\ImportThumbnailsAction
+ */
+class ImportThumbnailsActionTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testWebtrees1ThumbnailsAction(): void
+ {
+ $tree_service = new TreeService();
+ $pending_changes_service = new PendingChangesService();
+ $handler = new ImportThumbnailsAction($pending_changes_service, $tree_service);
+ $request = self::createRequest()
+ ->withParsedBody(['thumbnail' => 'foo', 'action' => '', 'xref' => [], 'ged' => []]);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/ImportThumbnailsDataTest.php b/tests/app/Http/RequestHandlers/ImportThumbnailsDataTest.php
new file mode 100644
index 0000000000..909874658d
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/ImportThumbnailsDataTest.php
@@ -0,0 +1,49 @@
+<?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\StatusCodeInterface;
+use Fisharebest\Webtrees\Services\SearchService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test ImportThumbnailsData class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\ImportThumbnailsData
+ */
+class ImportThumbnailsDataTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testWebtrees1ThumbnailsData(): void
+ {
+ $tree_service = new TreeService();
+ $search_service = new SearchService($tree_service);
+ $handler = new ImportThumbnailsData($search_service);
+ $request = self::createRequest()->withQueryParams(['start' => '0', 'length' => '10', 'search' => ['value' => ''], 'draw' => '1']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/ImportThumbnailsPageTest.php b/tests/app/Http/RequestHandlers/ImportThumbnailsPageTest.php
new file mode 100644
index 0000000000..022b86a643
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/ImportThumbnailsPageTest.php
@@ -0,0 +1,45 @@
+<?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\StatusCodeInterface;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test ImportThumbnailsData class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\ImportThumbnailsPage
+ */
+class ImportThumbnailsPageTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testWebtrees1Thumbnails(): void
+ {
+ $handler = new ImportThumbnailsPage();
+ $request = self::createRequest();
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/UpgradeWizardConfirmTest.php b/tests/app/Http/RequestHandlers/UpgradeWizardConfirmTest.php
new file mode 100644
index 0000000000..9b6bd52ca8
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/UpgradeWizardConfirmTest.php
@@ -0,0 +1,43 @@
+<?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\StatusCodeInterface;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test UpgradeController class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\UpgradeWizardConfirm
+ */
+class UpgradeWizardConfirmTest extends TestCase
+{
+ /**
+ * @return void
+ */
+ public function testWizardContinue(): void
+ {
+ $handler = new UpgradeWizardConfirm();
+ $request = self::createRequest();
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_FOUND, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/RequestHandlers/UpgradeWizardPageTest.php b/tests/app/Http/RequestHandlers/UpgradeWizardPageTest.php
new file mode 100644
index 0000000000..6538802ab3
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/UpgradeWizardPageTest.php
@@ -0,0 +1,51 @@
+<?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\StatusCodeInterface;
+use Fisharebest\Webtrees\Services\TimeoutService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\Services\UpgradeService;
+use Fisharebest\Webtrees\TestCase;
+
+/**
+ * Test UpgradeController class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\UpgradeWizardPage
+ */
+class UpgradeWizardPageTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testWizard(): void
+ {
+ $timeout_service = new TimeoutService();
+ $tree_service = new TreeService();
+ $upgrade_service = new UpgradeService($timeout_service);
+ $handler = new UpgradeWizardPage($tree_service, $upgrade_service);
+ $request = self::createRequest();
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}
diff --git a/tests/app/Http/Controllers/Admin/UpgradeControllerTest.php b/tests/app/Http/RequestHandlers/UpgradeWizardStepTest.php
index c6a2f13db4..7636dff2df 100644
--- a/tests/app/Http/Controllers/Admin/UpgradeControllerTest.php
+++ b/tests/app/Http/RequestHandlers/UpgradeWizardStepTest.php
@@ -17,7 +17,7 @@
declare(strict_types=1);
-namespace Fisharebest\Webtrees\Http\Controllers\Admin;
+namespace Fisharebest\Webtrees\Http\RequestHandlers;
use Exception;
use Fig\Http\Message\RequestMethodInterface;
@@ -35,54 +35,18 @@ use Illuminate\Support\Collection;
/**
* Test UpgradeController class.
*
- * @covers \Fisharebest\Webtrees\Http\Controllers\Admin\UpgradeController
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\UpgradeWizardStep
*/
-class UpgradeControllerTest extends TestCase
+class UpgradeWizardStepTest extends TestCase
{
protected static $uses_database = true;
/**
* @return void
*/
- public function testWizard(): void
- {
- $controller = new UpgradeController(
- new GedcomExportService(),
- new TreeService(),
- new UpgradeService(new TimeoutService())
- );
-
- $request = self::createRequest();
- $response = $controller->wizard($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-
- /**
- * @return void
- */
- public function testWizardContinue(): void
- {
- $this->importTree('demo.ged');
-
- $controller = new UpgradeController(
- new GedcomExportService(),
- new TreeService(),
- new UpgradeService(new TimeoutService())
- );
-
- $request = self::createRequest(RequestMethodInterface::METHOD_GET, ['continue' => '1']);
- $response = $controller->wizard($request);
-
- self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
- }
-
- /**
- * @return void
- */
public function testIgnoreStepInvalid(): void
{
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
new UpgradeService(new TimeoutService())
@@ -90,7 +54,7 @@ class UpgradeControllerTest extends TestCase
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Invalid']);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode());
}
@@ -100,16 +64,16 @@ class UpgradeControllerTest extends TestCase
*/
public function testStepCheckOK(): void
{
- $mock_upgrade_service = self::createMock(UpgradeService::class);
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
$mock_upgrade_service->method('latestVersion')->willReturn('999.999.999');
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
$mock_upgrade_service
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
}
@@ -121,16 +85,16 @@ class UpgradeControllerTest extends TestCase
{
$this->expectException(HttpServerErrorException::class);
- $mock_upgrade_service = self::createMock(UpgradeService::class);
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
$mock_upgrade_service->method('latestVersion')->willReturn('');
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
$mock_upgrade_service
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']);
- $controller->step($request);
+ $handler->handle($request);
}
/**
@@ -140,16 +104,16 @@ class UpgradeControllerTest extends TestCase
{
$this->expectException(HttpServerErrorException::class);
- $mock_upgrade_service = self::createMock(UpgradeService::class);
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
$mock_upgrade_service->method('latestVersion')->willReturn('0.0.0');
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
$mock_upgrade_service
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']);
- $controller->step($request);
+ $handler->handle($request);
}
/**
@@ -157,14 +121,14 @@ class UpgradeControllerTest extends TestCase
*/
public function testStepPrepare(): void
{
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
new UpgradeService(new TimeoutService())
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Prepare']);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
}
@@ -174,14 +138,14 @@ class UpgradeControllerTest extends TestCase
*/
public function testStepPending(): void
{
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
new UpgradeService(new TimeoutService())
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Pending']);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
}
@@ -200,14 +164,14 @@ class UpgradeControllerTest extends TestCase
Auth::login($user);
$tree->createIndividual("0 @@ INDI\n1 NAME Joe Bloggs");
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
new UpgradeService(new TimeoutService())
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Pending']);
- $controller->step($request);
+ $handler->handle($request);
}
/**
@@ -217,22 +181,22 @@ class UpgradeControllerTest extends TestCase
{
$tree = $this->importTree('demo.ged');
$all_trees = Collection::make([$tree->name() => $tree]);
- $tree_service = self::createMock(TreeService::class);
+ $tree_service = $this->createMock(TreeService::class);
$tree_service->method('all')->willReturn($all_trees);
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
$tree_service,
new UpgradeService(new TimeoutService())
);
$request = self::createRequest()->withQueryParams(['step' => 'Export', 'tree' => $tree->name()]);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
// Now overwrite the file we just created
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
}
@@ -244,16 +208,16 @@ class UpgradeControllerTest extends TestCase
{
$this->expectException(HttpServerErrorException::class);
- $mock_upgrade_service = self::createMock(UpgradeService::class);
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
$mock_upgrade_service->method('downloadFile')->will(self::throwException(new Exception()));
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
$mock_upgrade_service
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Download']);
- $controller->step($request);
+ $handler->handle($request);
}
/**
@@ -261,16 +225,16 @@ class UpgradeControllerTest extends TestCase
*/
public function testStepDownload(): void
{
- $mock_upgrade_service = self::createMock(UpgradeService::class);
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
$mock_upgrade_service->method('downloadFile')->willReturn(123456);
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
$mock_upgrade_service
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Download']);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
}
@@ -280,16 +244,16 @@ class UpgradeControllerTest extends TestCase
*/
public function testStepUnzip(): void
{
- $mock_upgrade_service = self::createMock(UpgradeService::class);
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
$mock_upgrade_service->method('webtreesZipContents')->willReturn(new Collection());
- $controller = new UpgradeController(
+ $handler = new UpgradeWizardStep(
new GedcomExportService(),
new TreeService(),
$mock_upgrade_service
);
$request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Unzip']);
- $response = $controller->step($request);
+ $response = $handler->handle($request);
self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
}