コード例 #1
0
ファイル: ConnectionTest.php プロジェクト: jimbojsb/hydrant
 public function testGetCollection()
 {
     $m = new MongoClient();
     Connection::setMongoClient($m);
     $collection = Connection::getCollection('test');
     $this->assertInstanceOf("MongoCollection", $collection);
     $this->assertEquals('test', $collection->getName());
 }
コード例 #2
0
ファイル: DocumentTest.php プロジェクト: jimbojsb/hydrant
 public function testDelete()
 {
     $doc1 = new Document();
     $doc1->save();
     $this->assertNotNull(Connection::getCollection('default')->findOne(['_id' => $doc1->_id]));
     $doc1->delete();
     $this->assertNull(Connection::getCollection('default')->findOne(['_id' => $doc1->_id]));
     $doc2 = new Document();
     $doc2->setEmbedded(true);
     try {
         $doc2->delete();
         $this->fail("Should not be able to delete an embedded document");
     } catch (Exception $e) {
     }
 }