public function testCRUD_Works()
 {
     $e = new MongoTestEnvironment();
     $e->clean();
     $project = $e->createProject(SF_TESTPROJECT, SF_TESTPROJECTCODE);
     // List
     $list = new TextListModel($project);
     $list->read();
     $this->assertEqual(0, $list->count);
     // Create
     $text = new TextModel($project);
     $text->title = "Some Text";
     $usx = MongoTestEnvironment::usxSample();
     $text->content = $usx;
     $id = $text->write();
     $this->assertNotNull($id);
     $this->assertIsA($id, 'string');
     $this->assertEqual($id, $text->id->asString());
     // Read back
     $otherText = new TextModel($project, $id);
     $this->assertEqual($id, $otherText->id->asString());
     $this->assertEqual('Some Text', $otherText->title);
     $this->assertEqual($usx, $otherText->content);
     // Update
     $otherText->title = 'Other Text';
     $otherText->write();
     // Read back
     $otherText = new TextModel($project, $id);
     $this->assertEqual('Other Text', $otherText->title);
     // List
     $list->read();
     $this->assertEqual(1, $list->count);
     // Delete
     TextModel::remove($project->databaseName(), $id);
     // List
     $list->read();
     $this->assertEqual(0, $list->count);
 }
 /**
  * @param string $projectId
  * @param array $textIds
  * @return int Total number of texts removed.
  */
 public static function deleteTexts($projectId, $textIds)
 {
     $projectModel = new ProjectModel($projectId);
     $count = 0;
     foreach ($textIds as $textId) {
         TextModel::remove($projectModel->databaseName(), $textId);
         $count++;
     }
     return $count;
 }