/**
  * @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()
 {
     $environ = new MongoTestEnvironment();
     $environ->clean();
     $textRef = MongoTestEnvironment::mockId();
     $project = $environ->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     // List
     $list = new QuestionListModel($project, $textRef);
     $list->read();
     $this->assertEquals(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->assertInternalType('string', $id);
     $this->assertEquals($question->id->asString(), $id);
     // Read back
     $otherQuestion = new QuestionModel($project, $id);
     $this->assertEquals($id, $otherQuestion->id->asString());
     $this->assertEquals('SomeQuestion', $otherQuestion->title);
     $this->assertEquals($textRef, $otherQuestion->textRef->id);
     // Update
     $otherQuestion->description = 'OtherQuestion';
     $otherQuestion->write();
     // Read back
     $otherQuestion = new QuestionModel($project, $id);
     $this->assertEquals('OtherQuestion', $otherQuestion->description);
     // List
     $list->read();
     $this->assertEquals(1, $list->count);
     // Delete
     QuestionModel::remove($project->databaseName(), $id);
     // List
     $list->read();
     $this->assertEquals(0, $list->count);
 }