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/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.php260
9 files changed, 647 insertions, 0 deletions
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/RequestHandlers/UpgradeWizardStepTest.php b/tests/app/Http/RequestHandlers/UpgradeWizardStepTest.php
new file mode 100644
index 0000000000..7636dff2df
--- /dev/null
+++ b/tests/app/Http/RequestHandlers/UpgradeWizardStepTest.php
@@ -0,0 +1,260 @@
+<?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 Exception;
+use Fig\Http\Message\RequestMethodInterface;
+use Fig\Http\Message\StatusCodeInterface;
+use Fisharebest\Webtrees\Auth;
+use Fisharebest\Webtrees\Exceptions\HttpServerErrorException;
+use Fisharebest\Webtrees\Services\GedcomExportService;
+use Fisharebest\Webtrees\Services\TimeoutService;
+use Fisharebest\Webtrees\Services\TreeService;
+use Fisharebest\Webtrees\Services\UpgradeService;
+use Fisharebest\Webtrees\Services\UserService;
+use Fisharebest\Webtrees\TestCase;
+use Illuminate\Support\Collection;
+
+/**
+ * Test UpgradeController class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\RequestHandlers\UpgradeWizardStep
+ */
+class UpgradeWizardStepTest extends TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testIgnoreStepInvalid(): void
+ {
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ new UpgradeService(new TimeoutService())
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Invalid']);
+
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_NO_CONTENT, $response->getStatusCode());
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepCheckOK(): void
+ {
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
+ $mock_upgrade_service->method('latestVersion')->willReturn('999.999.999');
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ $mock_upgrade_service
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepCheckUnavailable(): void
+ {
+ $this->expectException(HttpServerErrorException::class);
+
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
+ $mock_upgrade_service->method('latestVersion')->willReturn('');
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ $mock_upgrade_service
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']);
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepCheckFail(): void
+ {
+ $this->expectException(HttpServerErrorException::class);
+
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
+ $mock_upgrade_service->method('latestVersion')->willReturn('0.0.0');
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ $mock_upgrade_service
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Check']);
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepPrepare(): void
+ {
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ new UpgradeService(new TimeoutService())
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Prepare']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepPending(): void
+ {
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ new UpgradeService(new TimeoutService())
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Pending']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepPendingExist(): void
+ {
+ $this->expectException(HttpServerErrorException::class);
+
+ $tree_service = new TreeService();
+ $tree = $tree_service->create('name', 'title');
+ $user = (new UserService())->create('user', 'name', 'email', 'password');
+
+ Auth::login($user);
+ $tree->createIndividual("0 @@ INDI\n1 NAME Joe Bloggs");
+
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ new UpgradeService(new TimeoutService())
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Pending']);
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepExport(): void
+ {
+ $tree = $this->importTree('demo.ged');
+ $all_trees = Collection::make([$tree->name() => $tree]);
+ $tree_service = $this->createMock(TreeService::class);
+ $tree_service->method('all')->willReturn($all_trees);
+
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ $tree_service,
+ new UpgradeService(new TimeoutService())
+ );
+
+ $request = self::createRequest()->withQueryParams(['step' => 'Export', 'tree' => $tree->name()]);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+
+ // Now overwrite the file we just created
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepDownloadFails(): void
+ {
+ $this->expectException(HttpServerErrorException::class);
+
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
+ $mock_upgrade_service->method('downloadFile')->will(self::throwException(new Exception()));
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ $mock_upgrade_service
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Download']);
+ $handler->handle($request);
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepDownload(): void
+ {
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
+ $mock_upgrade_service->method('downloadFile')->willReturn(123456);
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ $mock_upgrade_service
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Download']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+
+ /**
+ * @return void
+ */
+ public function testStepUnzip(): void
+ {
+ $mock_upgrade_service = $this->createMock(UpgradeService::class);
+ $mock_upgrade_service->method('webtreesZipContents')->willReturn(new Collection());
+ $handler = new UpgradeWizardStep(
+ new GedcomExportService(),
+ new TreeService(),
+ $mock_upgrade_service
+ );
+
+ $request = self::createRequest(RequestMethodInterface::METHOD_POST, ['step' => 'Unzip']);
+ $response = $handler->handle($request);
+
+ self::assertSame(StatusCodeInterface::STATUS_OK, $response->getStatusCode());
+ }
+}