diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index cab9f5e..ad8944e 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,9 +12,7 @@ If you have a good idea for improvement feel free to create a new issue with all ### Issues -Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the `Project.md` file in the `Docs` repository. - -The issue information can be used to provide additional information such as priority, difficulty and type. For your first issue try to find a issue marked `[d:first]` or `[d:beginner]`. +Feel free to grab any open issue implement it and create a new pull request. Most issues can be found in the code marked with `@todo` or in the [PROJECT.md](https://github.com/Orange-Management/Docs/blob/master/Project/PROJECT.md) file. ### Code Style diff --git a/SearchCommands.php b/SearchCommands.php index e1994d4..0903e46 100644 --- a/SearchCommands.php +++ b/SearchCommands.php @@ -1,66 +1,67 @@ - [ 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, 'permission' => [ 'module' => 'Help', - 'type' => 2, - 'state' => 2, + 'type' => 2, + 'state' => 2, ], ], ], '^:help :user .*$' => [ 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, 'permission' => [ 'module' => 'Help', - 'type' => 2, - 'state' => 2, + 'type' => 2, + 'state' => 2, ], ], ], '^:help :dev .*$' => [ 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, 'permission' => [ 'module' => 'Help', - 'type' => 2, - 'state' => 3, + 'type' => 2, + 'state' => 3, ], ], ], '^:help :module .*$' => [ 0 => [ - 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', - 'verb' => 16, + 'dest' => '\Modules\Help\Controller\SearchController:searchHelp', + 'verb' => 16, 'permission' => [ 'module' => 'Help', - 'type' => 2, - 'state' => 2, + 'type' => 2, + 'state' => 2, ], ], ], '^:goto .*$' => [ 0 => [ - 'dest' => '\Modules\Navigation\Controller\SearchController:searchGoto', - 'verb' => 16, + 'dest' => '\Modules\Navigation\Controller\SearchController:searchGoto', + 'verb' => 16, 'permission' => [ 'module' => 'Navigation', - 'type' => 2, + 'type' => 2, ], ], ], '^:tag .*$' => [ 0 => [ - 'dest' => '\Modules\Tasks\Controller\SearchController:searchTags', - 'verb' => 16, + 'dest' => '\Modules\Tasks\Controller\SearchController:searchTags', + 'verb' => 16, 'permission' => [ 'module' => 'Tasks', - 'type' => 2, + 'type' => 2, ], ], ], -]; \ No newline at end of file +]; diff --git a/tests/Controller/ApiControllerTest.php b/tests/Controller/ApiControllerTest.php new file mode 100644 index 0000000..5742a02 --- /dev/null +++ b/tests/Controller/ApiControllerTest.php @@ -0,0 +1,107 @@ +app = new class() extends ApplicationAbstract + { + protected string $appName = 'Api'; + }; + + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->orgId = 1; + $this->app->accountManager = new AccountManager($GLOBALS['session']); + $this->app->appSettings = new CoreSettings(); + $this->app->moduleManager = new ModuleManager($this->app, __DIR__ . '/../../../../Modules/'); + $this->app->dispatcher = new Dispatcher($this->app); + $this->app->eventManager = new EventManager($this->app->dispatcher); + $this->app->eventManager->importFromFile(__DIR__ . '/../../../../Web/Api/Hooks.php'); + $this->app->sessionManager = new HttpSession(36000); + + $account = new Account(); + TestUtils::setMember($account, 'id', 1); + + $permission = new AccountPermission(); + $permission->setUnit(1); + $permission->setApp('api'); + $permission->setPermission( + PermissionType::READ + | PermissionType::CREATE + | PermissionType::MODIFY + | PermissionType::DELETE + | PermissionType::PERMISSION + ); + + $account->addPermission($permission); + + $this->app->accountManager->add($account); + $this->app->router = new WebRouter(); + + $this->module = $this->app->moduleManager->get('Search'); + + TestUtils::setMember($this->module, 'app', $this->app); + } + + /** + * @covers Modules\Search\Controller\ApiController + * @group module + */ + public function testApiSearch() : void + { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $request->setData('search', ':help file'); + + $this->module->routeSearch($request, $response); + self::assertGreaterThan(0, \count($response->get(''))); + } +}