Beispiel #1
0
 public function testSelectDB()
 {
     $mongo = new LoggableMongo();
     $db = $mongo->selectDB('mandango_logger');
     $this->assertInstanceOf('\\Mandango\\Logger\\LoggableMongoDB', $db);
     $this->assertSame('mandango_logger', $db->__toString());
 }
Beispiel #2
0
 public function testGetGridFS()
 {
     $mongo = new LoggableMongo();
     $db = $mongo->selectDB('mandango_logger');
     $grid = $db->getGridFS('mandango_logger_grid');
     $this->assertInstanceOf('\\Mandango\\Logger\\LoggableMongoGridFS', $grid);
     $this->assertSame('mandango_logger_grid.files', $grid->getName());
 }
Beispiel #3
0
 public function testLog()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('mandango_logger');
     $collection = $db->selectCollection('mandango_logger_collection');
     $cursor = $collection->find();
     $cursor->log($log = array('foo' => 'bar'));
     $this->assertSame(array_merge(array('database' => 'mandango_logger', 'collection' => 'mandango_logger_collection'), $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);
 }
 public function testFind()
 {
     $mongo = new LoggableMongo();
     $db = $mongo->selectDB('mandango_logger');
     $collection = $db->selectCollection('mandango_logger_collection');
     $cursor = $collection->find();
     $this->assertInstanceOf('\\Mandango\\Logger\\LoggableMongoCursor', $cursor);
     $cursor = $collection->find($query = array('foo' => 'bar'), $fields = array('foobar' => 1, 'barfoo' => 1));
     $info = $cursor->info();
     $this->assertSame($query, $info['query']);
     $this->assertSame($fields, $info['fields']);
 }
Beispiel #6
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']);
 }