Beispiel #1
0
 public function testGetCollection()
 {
     $m = new MongoClient();
     Connection::setMongoClient($m);
     $collection = Connection::getCollection('test');
     $this->assertInstanceOf("MongoCollection", $collection);
     $this->assertEquals('test', $collection->getName());
 }
Beispiel #2
0
 public function tearDown()
 {
     Connection::getMongoClient()->dropDB('test');
 }
Beispiel #3
0
 public function testHydrationEmbeddedObjects()
 {
     $d = new Document();
     $a = new ArrayObject();
     $a['foo'] = 'bar';
     $d->foo = 'bar';
     $d->arrayObject = $a;
     $d->save();
     $data = Connection::getMongoClient()->test->default->findOne(['_id' => $d->_id]);
     $this->assertEquals('bar', $data["foo"]);
     $this->assertEquals('bar', $data["arrayObject"]["foo"]);
     $this->assertEquals('ArrayObject', $data["arrayObject"]["_class"]);
     $d2 = Document::hydrate($data);
     $this->assertEquals($d, $d2);
 }