Beispiel #1
0
 public function testLog()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('mandango_logger');
     $db->log($log = array('foo' => 'bar'));
     $this->assertSame(array_merge(array('database' => 'mandango_logger'), $log), $this->log);
 }
Beispiel #2
0
 public function testLogWithLogDefault()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $mongo->setLogDefault($logDefault = array('connection' => 'default', 'foo' => 'foobar'));
     $mongo->log($log = array('foo' => 'bar'));
     $this->assertSame(array_merge($logDefault, $log), $this->log);
 }
 public function testLog()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('mandango_logger');
     $grid = $db->getGridFS('mandango_logger_grid');
     $cursor = $grid->find();
     $cursor->log($log = array('foo' => 'bar'));
     $this->assertSame(array_merge(array('database' => 'mandango_logger', 'collection' => 'mandango_logger_grid.files', 'gridfs' => 1), $log), $this->log);
 }
Beispiel #4
0
 public function testFind()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('mandango_logger');
     $grid = $db->getGridFS('mandango_logger_grid');
     $cursor = $grid->find();
     $this->assertInstanceOf('\\Mandango\\Logger\\LoggableMongoGridFSCursor', $cursor);
     $cursor = $grid->find($query = array('foo' => 'bar'), $fields = array('foobar' => 1, 'barfoo' => 1));
     $info = $cursor->info();
     $this->assertSame($query, $info['query']);
     $this->assertSame($fields, $info['fields']);
 }