public function questionTemplate_delete($questionTemplateIds) { return QuestionTemplateCommands::deleteQuestionTemplates($this->projectId, $questionTemplateIds); }
public function testQuestionTemplateCRUD_CRUDOK() { $projectId = self::$environ->makeProject(); // Initial List $result = self::$environ->fixJson(QuestionTemplateCommands::listTemplates($projectId)); $existingCount = $result['count']; // Create $model = array('id' => '', 'title' => 'Template Title', 'description' => 'Nice and clear description'); $id = QuestionTemplateCommands::updateTemplate($projectId, $model); $this->assertNotNull($id); $this->assertEquals(24, strlen($id)); // Create Second $model = array('id' => '', 'title' => 'Template Title 2', 'description' => 'Nice and clear description 2'); $id2 = QuestionTemplateCommands::updateTemplate($projectId, $model); // List $result = self::$environ->fixJson(QuestionTemplateCommands::listTemplates($projectId)); $this->assertEquals($result['count'], $existingCount + 2); // Read $result = self::$environ->fixJson(QuestionTemplateCommands::readTemplate($projectId, $id)); $this->assertNotNull($result['id']); $this->assertEquals('Template Title', $result['title']); $this->assertEquals('Nice and clear description', $result['description']); // Update $result['description'] = 'Muddled description'; $newid = QuestionTemplateCommands::updateTemplate($projectId, $result); $this->assertNotNull($newid); $this->assertEquals($id, $newid); // Verify update actually changed DB $postUpdateResult = self::$environ->fixJson(QuestionTemplateCommands::readTemplate($projectId, $id)); $this->assertNotNull($postUpdateResult['id']); $this->assertEquals($postUpdateResult['description'], 'Muddled description'); // Delete $result = QuestionTemplateCommands::deleteQuestionTemplates($projectId, array($id)); $this->assertTrue($result > 0); QuestionTemplateCommands::deleteQuestionTemplates($projectId, array($id2)); }