diff --git a/tests/Controller/Api/ApiControllerMediaTrait.php b/tests/Controller/Api/ApiControllerMediaTrait.php index 117ca29..671f16b 100755 --- a/tests/Controller/Api/ApiControllerMediaTrait.php +++ b/tests/Controller/Api/ApiControllerMediaTrait.php @@ -615,4 +615,14 @@ trait ApiControllerMediaTrait $this->module->apiMediaExport($request, $response); self::assertEquals(MimeType::M_BIN, $response->header->get('Content-Type')[0]); } + + public function testInvalidapiMediaUpdate() : void + { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $this->module->apiMediaUpdate($request, $response); + self::assertEquals(RequestStatusCode::R_400, $response->header->status); + } } diff --git a/tests/Controller/Api/testFile2.txt b/tests/Controller/Api/testFile2.txt index 55afc44..42e7f80 100755 --- a/tests/Controller/Api/testFile2.txt +++ b/tests/Controller/Api/testFile2.txt @@ -1 +1,99 @@ -Media/Collection Test 2 \ No newline at end of file +app = new class() extends ApplicationAbstract + { + protected string $appName = 'Api'; + protected int $appId = 1; + }; + + $this->app->dbPool = $GLOBALS['dbpool']; + $this->app->unitId = 1; + $this->app->appName = 'Api'; + $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->l11nManager = new L11nManager(); + $this->app->eventManager->importFromFile(__DIR__ . '/../../../Web/Api/Hooks.php'); + + $this->app->router = new WebRouter(); + + $account = new Account(); + TestUtils::setMember($account, 'id', 1); + + $permission = new AccountPermission(); + $permission->unit = 1; + $permission->app = 1; + $permission->setPermission( + PermissionType::READ + | PermissionType::CREATE + | PermissionType::MODIFY + | PermissionType::DELETE + | PermissionType::PERMISSION + ); + + $account->addPermission($permission); + + $this->app->accountManager->add($account); + + $this->module = $this->app->moduleManager->get('Media'); + } + + use ApiControllerMediaTrait; + use ApiControllerCollectionTrait; + } + + public function testInvalidapiMediaTypeL11nCreate() : void + { + $response = new HttpResponse(); + $request = new HttpRequest(new HttpUri('')); + + $request->header->account = 1; + $this->module->apiMediaTypeL11nCreate($request, $response); + self::assertEquals(RequestStatusCode::R_400, $response->header->status); + } +}