summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/Http/Controllers/Admin/UsersController.php (renamed from app/Http/Controllers/AdminUsersController.php)7
-rw-r--r--routes/web.php16
-rw-r--r--tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php27
-rw-r--r--tests/app/Http/Controllers/Admin/UsersControllerTest.php118
4 files changed, 130 insertions, 38 deletions
diff --git a/app/Http/Controllers/AdminUsersController.php b/app/Http/Controllers/Admin/UsersController.php
index 5dbcf69a1e..5abd5ad710 100644
--- a/app/Http/Controllers/AdminUsersController.php
+++ b/app/Http/Controllers/Admin/UsersController.php
@@ -15,7 +15,7 @@
*/
declare(strict_types=1);
-namespace Fisharebest\Webtrees\Http\Controllers;
+namespace Fisharebest\Webtrees\Http\Controllers\Admin;
use Fisharebest\Webtrees\Auth;
use Fisharebest\Webtrees\Contracts\UserInterface;
@@ -45,13 +45,10 @@ use const WT_BASE_URL;
/**
* Controller for user administration.
*/
-class AdminUsersController extends AbstractBaseController
+class UsersController extends AbstractAdminController
{
private const SECONDS_PER_DAY = 24 * 60 * 60;
- /** @var string */
- protected $layout = 'layouts/administration';
-
/**
* @var ModuleService
*/
diff --git a/routes/web.php b/routes/web.php
index 24b10bd9e9..0f83529a9d 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -68,6 +68,14 @@ if (Auth::isAdmin()) {
'POST:locations-import-from-tree' => 'Admin\\LocationController@importLocationsFromTree',
'GET:map-provider' => 'Admin\\MapProviderController@mapProviderEdit',
'POST:map-provider' => 'Admin\\MapProviderController@mapProviderSave',
+ 'GET:admin-users' => 'AdminUsersController@index',
+ 'GET:admin-users-data' => 'AdminUsersController@data',
+ 'GET:admin-users-create' => 'AdminUsersController@create',
+ 'POST:admin-users-create' => 'AdminUsersController@save',
+ 'GET:admin-users-edit' => 'AdminUsersController@edit',
+ 'POST:admin-users-edit' => 'AdminUsersController@update',
+ 'GET:admin-users-cleanup' => 'AdminUsersController@cleanup',
+ 'POST:admin-users-cleanup' => 'AdminUsersController@cleanupAction',
'GET:admin-media' => 'AdminMediaController@index',
'GET:admin-media-data' => 'AdminMediaController@data',
'POST:admin-media-delete' => 'AdminMediaController@delete',
@@ -109,14 +117,6 @@ if (Auth::isAdmin()) {
'GET:admin-trees-merge' => 'AdminTreesController@merge',
'POST:admin-trees-merge' => 'AdminTreesController@mergeAction',
'GET:admin-trees-unconnected' => 'AdminTreesController@unconnected',
- 'GET:admin-users' => 'AdminUsersController@index',
- 'GET:admin-users-data' => 'AdminUsersController@data',
- 'GET:admin-users-create' => 'AdminUsersController@create',
- 'POST:admin-users-create' => 'AdminUsersController@save',
- 'GET:admin-users-edit' => 'AdminUsersController@edit',
- 'POST:admin-users-edit' => 'AdminUsersController@update',
- 'GET:admin-users-cleanup' => 'AdminUsersController@cleanup',
- 'POST:admin-users-cleanup' => 'AdminUsersController@cleanupAction',
'GET:tree-page-default-edit' => 'HomePageController@treePageDefaultEdit',
'POST:tree-page-default-update' => 'HomePageController@treePageDefaultUpdate',
'GET:user-page-default-edit' => 'HomePageController@userPageDefaultEdit',
diff --git a/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php b/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php
index f955182e2f..ee019b622d 100644
--- a/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php
+++ b/tests/app/Http/Controllers/Admin/ImportThumbnailsControllerTest.php
@@ -31,34 +31,11 @@ class ImportThumbnailsControllerTest extends \Fisharebest\Webtrees\TestCase
/**
* @return void
*/
- public function testWebtrees1Thumbnails(): void
+ public function testIndex(): void
{
$controller = app()->make(ImportThumbnailsController::class);
- $response = app()->dispatch($controller, 'webtrees1Thumbnails');
+ $response = app()->dispatch($controller, 'index');
$this->assertInstanceOf(Response::class, $response);
}
-
- /**
- * @return void
- */
- public function testWebtrees1ThumbnailsAction(): void
- {
- $controller = app()->make(ImportThumbnailsController::class);
- $response = app()->dispatch($controller, 'webtrees1ThumbnailsAction');
-
- $this->assertInstanceOf(Response::class, $response);
- }
-
- /**
- * @return void
- */
- public function testWebtrees1ThumbnailsData(): void
- {
- // Can't test this yet - the query uses MySQL-specific functions
- //$controller = app()->make(ImportThumbnailsController::class);
- //$response = app()->dispatch($controller, 'webtrees1ThumbnailsData');
-
- //$this->assertInstanceOf(Response::class, $response);
- }
}
diff --git a/tests/app/Http/Controllers/Admin/UsersControllerTest.php b/tests/app/Http/Controllers/Admin/UsersControllerTest.php
new file mode 100644
index 0000000000..59545f5112
--- /dev/null
+++ b/tests/app/Http/Controllers/Admin/UsersControllerTest.php
@@ -0,0 +1,118 @@
+<?php
+/**
+ * webtrees: online genealogy
+ * Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
+ */
+declare(strict_types=1);
+
+namespace Fisharebest\Webtrees\Http\Controllers\Admin;
+
+use Symfony\Component\HttpFoundation\Response;
+
+/**
+ * Test UsersController class.
+ *
+ * @covers \Fisharebest\Webtrees\Http\Controllers\Admin\UsersController
+ */
+class UsersControllerTest extends \Fisharebest\Webtrees\TestCase
+{
+ protected static $uses_database = true;
+
+ /**
+ * @return void
+ */
+ public function testIndex(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'index');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testData(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'data');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testCreate(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'create');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testSave(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'save');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testEdit(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'edit');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testUpdate(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'update');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testCleanup(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'cleanup');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+
+ /**
+ * @return void
+ */
+ public function testCleanupAction(): void
+ {
+ $controller = app()->make(UsersController::class);
+ $response = app()->dispatch($controller, 'cleanupAction');
+
+ $this->assertInstanceOf(Response::class, $response);
+ }
+}