/**
  * @param string $projectId
  * @param array $questionIds
  * @return int Total number of questions removed.
  */
 public static function deleteQuestions($projectId, $questionIds)
 {
     $projectModel = new ProjectModel($projectId);
     $count = 0;
     foreach ($questionIds as $questionId) {
         QuestionModel::remove($projectModel->databaseName(), $questionId);
         $count++;
     }
     return $count;
 }
 public function testCRUD_Works()
 {
     $e = new MongoTestEnvironment();
     $e->clean();
     $textRef = MongoTestEnvironment::mockId();
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     // List
     $list = new QuestionListModel($project, $textRef);
     $list->read();
     $this->assertEqual(0, $list->count);
     // Create
     $question = new QuestionModel($project);
     $question->title = "SomeQuestion";
     $question->description = "SomeQuestion";
     $question->textRef->id = $textRef;
     $id = $question->write();
     $this->assertNotNull($id);
     $this->assertIsA($id, 'string');
     $this->assertEqual($id, $question->id->asString());
     // Read back
     $otherQuestion = new QuestionModel($project, $id);
     $this->assertEqual($id, $otherQuestion->id->asString());
     $this->assertEqual('SomeQuestion', $otherQuestion->title);
     $this->assertEqual($textRef, $otherQuestion->textRef->id);
     // Update
     $otherQuestion->description = 'OtherQuestion';
     $otherQuestion->write();
     // Read back
     $otherQuestion = new QuestionModel($project, $id);
     $this->assertEqual('OtherQuestion', $otherQuestion->description);
     // List
     $list->read();
     $this->assertEqual(1, $list->count);
     // Delete
     QuestionModel::remove($project->databaseName(), $id);
     // List
     $list->read();
     $this->assertEqual(0, $list->count);
 }