Пример #1
0
 /**
  * @return \Zumba\PHPUnit\Extensions\Mongo\Client\Connector
  */
 public function getMongoConnection()
 {
     if (empty($this->connection)) {
         $this->connection = new Connector(new \MongoClient());
         $this->connection->setDb(static::DEFAULT_DATABASE);
     }
     return $this->connection;
 }
Пример #2
0
 public function testGeneralConnection()
 {
     $connection = new Connector(new \MongoClient());
     $connection->setDb('test');
     $this->assertInstanceOf('Zumba\\PHPUnit\\Extensions\\Mongo\\Client\\Connector', $connection);
     $connection->collection('test')->insert(['document' => 'test document']);
     $this->assertCount(1, $connection->collection('test')->find());
     $connection->collection('test')->drop();
 }
Пример #3
0
 /**
  * Creates all collections with data from the fixture.
  *
  * @return \Zumba\PHPUnit\Extensions\Mongo\DataSet\DataSet
  */
 public function buildCollections()
 {
     foreach ($this->fixture as $collection => $data) {
         foreach ($data as $entry) {
             $this->connection->collection($collection)->insert($entry);
         }
     }
     return $this;
 }
Пример #4
0
 public function getMongoConnection()
 {
     $connection = new Connector(Application::get('mongo_client'));
     $connection->setDb(Application::get('config')['mongodb']['db']);
     return $connection;
 }