dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; } public function testCreate(): void { $relationParameters = RelationParameters::fromArray([ RelationParameters::EXPORT_TEMPLATES_WORK => true, RelationParameters::DATABASE => 'db', RelationParameters::EXPORT_TEMPLATES => 'table', ]); (new ReflectionProperty(Relation::class, 'cache'))->setValue(null, $relationParameters); $config = Config::getInstance(); $config->selectedServer['user'] = 'user'; $response = new ResponseRenderer(); $template = new Template($config); $request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com/') ->withParsedBody([ 'exportType' => 'raw', 'templateName' => 'name', 'templateData' => 'data', 'template_id' => null, ]); (new CreateController( $response, $template, new TemplateModel($this->dbi), new Relation($this->dbi), $config, ))($request); $templates = [ ExportTemplate::fromArray([ 'id' => 1, 'username' => 'user1', 'exportType' => 'raw', 'name' => 'name1', 'data' => 'data1', ]), ExportTemplate::fromArray([ 'id' => 2, 'username' => 'user2', 'exportType' => 'raw', 'name' => 'name2', 'data' => 'data2', ]), ]; $options = $template->render('export/template_options', [ 'templates' => $templates, 'selected_template' => null, ]); self::assertTrue($response->hasSuccessState()); self::assertSame(['data' => $options], $response->getJSONResult()); } }