Example #1
0
 public function testSelectDB()
 {
     $mongo = new LoggableMongo();
     $db = $mongo->selectDB('mongator_logger');
     $this->assertInstanceOf('\\Mongator\\Logger\\LoggableMongoDB', $db);
     $this->assertSame('mongator_logger', $db->__toString());
 }
 public function testGetGridFS()
 {
     $mongo = new LoggableMongo();
     $db = $mongo->selectDB('mongator_logger');
     $grid = $db->getGridFS('mongator_logger_grid');
     $this->assertInstanceOf('\\Mongator\\Logger\\LoggableMongoGridFS', $grid);
     $this->assertSame('mongator_logger_grid.files', $grid->getName());
 }
 public function testLog()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('Mongator_logger');
     $collection = $db->selectCollection('Mongator_logger_collection');
     $cursor = $collection->find();
     $cursor->log($log = array('foo' => 'bar'));
     $this->assertSame(array_merge(array('database' => 'Mongator_logger', 'collection' => 'Mongator_logger_collection'), $log), $this->log);
 }
 public function testLog()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('Mongator_logger');
     $grid = $db->getGridFS('Mongator_logger_grid');
     $cursor = $grid->find();
     $cursor->log($log = array('foo' => 'bar'));
     $this->assertSame(array_merge(array('database' => 'Mongator_logger', 'collection' => 'Mongator_logger_grid.files', 'gridfs' => 1), $log), $this->log);
 }
 public function testFind()
 {
     $mongo = new LoggableMongo();
     $db = $mongo->selectDB('Mongator_logger');
     $collection = $db->selectCollection('Mongator_logger_collection');
     $cursor = $collection->find();
     $this->assertInstanceOf('\\Mongator\\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']);
 }
 public function testFind()
 {
     $mongo = new LoggableMongo();
     $mongo->setLoggerCallable(array($this, 'log'));
     $db = $mongo->selectDB('Mongator_logger');
     $grid = $db->getGridFS('Mongator_logger_grid');
     $cursor = $grid->find();
     $this->assertInstanceOf('\\Mongator\\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']);
 }