예제 #1
0
 function testDisconnect()
 {
     $this->assertTrue(ActiveMongo::isConnected());
     ActiveMongo::Disconnect();
     $this->assertFalse(ActiveMongo::isConnected());
 }
예제 #2
0
 /**
  *  @depends testInit
  */
 function testCacheSimple()
 {
     $c = new CacheableModel();
     $c->prop = 'bar';
     $c->save();
     $id = $c->getID();
     $c->reset();
     $c->where('_id', $id);
     $c->doQuery();
     $this->assertFalse($c->servedFromCache());
     /* Disconnect to test the cache works properly */
     ActiveMongo::disconnect();
     $this->assertFalse(ActiveMongo::isConnected());
     $d = new CacheableModel();
     $d->where('_id', $id);
     $d->doQuery();
     $this->assertFalse(ActiveMongo::isConnected());
     $this->assertTrue($d->servedFromCache());
     $this->assertEquals($c->prop, $d->prop);
     /* non-cached query, to see if it is reconnected to mongodb */
     $d = new CacheableModel();
     $d->where('_id', 'foobar');
     $d->doQuery();
     $this->assertFalse($d->servedFromCache());
     $this->assertTrue(ActiveMongo::isConnected());
     return $id;
 }