app = new class() extends ApplicationAbstract { protected string $appName = 'Api'; }; $this->app->dbPool = $GLOBALS['dbpool']; $this->app->orgId = 1; $this->app->appName = 'Backend'; $this->app->accountManager = new AccountManager($GLOBALS['session']); $this->app->appSettings = new CoreSettings($this->app->dbPool->get()); $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->router = new WebRouter(); $this->module = $this->app->moduleManager->get('Media'); } /** * @covers Modules\Media\Controller\ApiController * @group module */ public function testCreateDbEntries() : void { $status = [ [ 'status' => UploadStatus::OK, 'extension' => 'png', 'filename' => 'logo.png', 'name' => 'logo.png', 'path' => 'Modules/tests/Media/Files/', 'size' => 90210, ], [ 'status' => UploadStatus::FAILED_HASHING, 'extension' => 'png', 'filename' => 'logo.png', 'name' => 'logo.png', 'path' => 'Modules/tests/Media/Files/', 'size' => 90210, ], [ 'status' => UploadStatus::OK, 'extension' => 'png', 'filename' => 'logo2.png', 'name' => 'logo2.png', 'path' => 'Modules/tests/Media/Files/', 'size' => 90210, ], ]; $ids = $this->module->createDbEntries($status, 1); self::assertCount(2, $ids); } }