diff options
| author | Greg Roach <fisharebest@webtrees.net> | 2019-01-31 20:54:18 +0000 |
|---|---|---|
| committer | Greg Roach <fisharebest@webtrees.net> | 2019-01-31 20:54:37 +0000 |
| commit | 89db8eda75de707a9722ac32cffa511e018d495e (patch) | |
| tree | 04bcc8af583e05246ae41278980cba724d8457cd /tests/app | |
| parent | e2cbf57a1b80fdeccb7ccc9b79b7aa02707dbde2 (diff) | |
| download | webtrees-89db8eda75de707a9722ac32cffa511e018d495e.tar.gz webtrees-89db8eda75de707a9722ac32cffa511e018d495e.tar.bz2 webtrees-89db8eda75de707a9722ac32cffa511e018d495e.zip | |
Tests
Diffstat (limited to 'tests/app')
| -rw-r--r-- | tests/app/Http/Controllers/Admin/LocationControllerTest.php | 126 | ||||
| -rw-r--r-- | tests/app/Http/Controllers/ModuleControllerTest.php | 7 | ||||
| -rw-r--r-- | tests/app/Services/UserServiceTest.php | 47 | ||||
| -rw-r--r-- | tests/app/UserTest.php | 14 |
4 files changed, 134 insertions, 60 deletions
diff --git a/tests/app/Http/Controllers/Admin/LocationControllerTest.php b/tests/app/Http/Controllers/Admin/LocationControllerTest.php new file mode 100644 index 0000000000..941d7b35dc --- /dev/null +++ b/tests/app/Http/Controllers/Admin/LocationControllerTest.php @@ -0,0 +1,126 @@ +<?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 Fisharebest\Webtrees\Auth; +use Fisharebest\Webtrees\Application; +use Fisharebest\Webtrees\Services\ModuleService; +use Fisharebest\Webtrees\Tree; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; +use const T_REQUIRE; + +/** + * Test the location controller + * + * @covers \Fisharebest\Webtrees\Http\Controllers\Admin\LocationController + */ +class ModuleControllerTest extends \Fisharebest\Webtrees\TestCase +{ + protected static $uses_database = true; + + /** + * @return void + */ + public function testMapData(): void + { + $controller = app()->make(LocationController::class); + $response = app()->dispatch($controller, 'mapData'); + + $this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testMapDataEdit(): void + { + $controller = app()->make(LocationController::class); + $response = app()->dispatch($controller, 'mapDataEdit'); + + $this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testMapDataSave(): void + { + //$controller = app()->make(LocationController::class); + //$response = app()->dispatch($controller, 'mapDataSave'); + + //$this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testMapDataDelete(): void + { + $controller = app()->make(LocationController::class); + $response = app()->dispatch($controller, 'mapDataDelete'); + + $this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testExportLocations(): void + { + $controller = app()->make(LocationController::class); + $response = app()->dispatch($controller, 'exportLocations'); + + $this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testImportLocations(): void + { + $controller = app()->make(LocationController::class); + $response = app()->dispatch($controller, 'importLocations'); + + $this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testImportLocationsAction(): void + { + //$controller = app()->make(LocationController::class); + //$response = app()->dispatch($controller, 'importLocationsAction'); + + //$this->assertInstanceOf(Response::class, $response); + } + + /** + * @return void + */ + public function testImportLocationsFromTree(): void + { + app()->instance(Tree::class, Tree::create('name', 'title')); + + $controller = app()->make(LocationController::class); + $response = app()->dispatch($controller, 'importLocationsFromTree'); + + $this->assertInstanceOf(Response::class, $response); + } +} diff --git a/tests/app/Http/Controllers/ModuleControllerTest.php b/tests/app/Http/Controllers/ModuleControllerTest.php index 2ccea48b03..7cb492d128 100644 --- a/tests/app/Http/Controllers/ModuleControllerTest.php +++ b/tests/app/Http/Controllers/ModuleControllerTest.php @@ -39,11 +39,8 @@ class ModuleControllerTest extends \Fisharebest\Webtrees\TestCase */ public function testMissingModule(): void { - $tree = Tree::create('name', 'title'); - app()->instance(Tree::class, $tree); - - $request = new Request(['route' => 'module']); - app()->instance(Request::class, $request); + app()->instance(Tree::class, Tree::create('name', 'title')); + app()->instance(Request::class, new Request(['route' => 'module'])); $controller = app()->make(ModuleController::class); app()->dispatch($controller, 'action'); diff --git a/tests/app/Services/UserServiceTest.php b/tests/app/Services/UserServiceTest.php index c38528c8ed..b013fbaa60 100644 --- a/tests/app/Services/UserServiceTest.php +++ b/tests/app/Services/UserServiceTest.php @@ -40,38 +40,17 @@ class UserServiceTest extends TestCase } /** - * @covers \Fisharebest\Webtrees\Services\UserService::setUserName - * @covers \Fisharebest\Webtrees\Services\UserService::userName - * @covers \Fisharebest\Webtrees\Services\UserService::setRealName - * @covers \Fisharebest\Webtrees\Services\UserService::realName - * @covers \Fisharebest\Webtrees\Services\UserService::setEmail - * @covers \Fisharebest\Webtrees\Services\UserService::email - * @covers \Fisharebest\Webtrees\Services\UserService::setPassword - * @covers \Fisharebest\Webtrees\Services\UserService::checkPassword + * @covers \Fisharebest\Webtrees\Services\UserService::delete * @return void */ - public function testGettersAndSetters(): void + public function testDelete(): void { $user_service = new UserService(); - $user = $user_service->create('user', 'User', 'user@example.com', 'secret'); - - $this->assertSame(1, $user->id()); - - $this->assertSame('user', $user->userName()); - $user->setUserName('foo'); - $this->assertSame('foo', $user->userName()); - - $this->assertSame('User', $user->realName()); - $user->setRealName('Foo'); - $this->assertSame('Foo', $user->realName()); - - $this->assertSame('user@example.com', $user->email()); - $user->setEmail('foo@example.com'); - $this->assertSame('foo@example.com', $user->email()); + $user = $user_service->create('user', 'User', 'user@example.com', 'secret'); + $user_id = $user->id(); + $user_service->delete($user); - $this->assertTrue($user->checkPassword('secret')); - $user->setPassword('letmein'); - $this->assertTrue($user->checkPassword('letmein')); + $this->assertNull($user_service->find($user_id)); } /** @@ -88,20 +67,6 @@ class UserServiceTest extends TestCase } /** - * @covers \Fisharebest\Webtrees\Services\UserService::delete - * @return void - */ - public function testDelete(): void - { - $user_service = new UserService(); - $user = $user_service->create('user', 'User', 'user@example.com', 'secret'); - $user_id = $user->id(); - $user_service->delete($user); - - $this->assertNull($user_service->find($user_id)); - } - - /** * @covers \Fisharebest\Webtrees\Services\UserService::setPreference * @covers \Fisharebest\Webtrees\Services\UserService::getPreference * @return void diff --git a/tests/app/UserTest.php b/tests/app/UserTest.php index 9a6f9c14db..c4811e798e 100644 --- a/tests/app/UserTest.php +++ b/tests/app/UserTest.php @@ -89,20 +89,6 @@ class UserTest extends TestCase } /** - * @covers \Fisharebest\Webtrees\User::delete - * @return void - */ - public function testDelete(): void - { - $user_service = new UserService(); - $user = $user_service->create('user', 'User', 'user@example.com', 'secret'); - $user_id = $user->id(); - $user_service->delete($user); - - $this->assertNull($user_service->find($user_id)); - } - - /** * @covers \Fisharebest\Webtrees\User::setPreference * @covers \Fisharebest\Webtrees\User::getPreference * @return void |
