예제 #1
0
 public function testConstruct()
 {
     $config = ['class' => '\\Reach\\Connection\\Dummy', 'host' => 'localhost'];
     \Reach\Service\Container::register('connection', $config);
     $connection = \Reach\Service\Container::get('connection');
     $this->assertInstanceOf('\\Reach\\Connection\\Dummy', $connection);
     $connection = new \Reach\Connection\Dummy($config);
     \Reach\Service\Container::set('connection', $connection);
     $this->assertInstanceOf('\\Reach\\Connection\\Dummy', \Reach\Service\Container::get('connection'));
     $this->assertTrue(\Reach\Service\Container::has('connection'));
 }
예제 #2
0
 public function testConnectionOld()
 {
     $config = ['database' => 'reach_testing', 'host' => 'localhost', 'port' => 27017, 'options' => ['connect' => true, 'socketTimeoutMS' => 60000]];
     ConnectionManager::registerConnection($config);
     $connection = ConnectionManager::getConnection();
     $this->assertInstanceOf('\\Reach\\Mongo\\Connection', $connection);
     $this->assertTrue(method_exists($connection, 'getDb'));
     $this->assertInstanceOf('\\MongoDB', $connection->getDb());
     $config2 = ['database' => 'reach_testing2'];
     Container::register('another', $config2, '\\Reach\\Mongo\\Connection');
     $connection2 = Container::get('another');
     $this->assertInstanceOf('\\Reach\\Mongo\\Connection', $connection2);
     $this->assertEquals('reach_testing2', $connection2->getDbName());
     $connection = ConnectionManager::getConnection();
     $this->assertInstanceOf('\\Reach\\Mongo\\Connection', $connection);
     $this->assertEquals('reach_testing', $connection->getDbName());
 }
예제 #3
0
 public static function setUpBeforeClass()
 {
     self::$config = ['database' => 'reach_testing', 'host' => 'localhost', 'port' => 27017, 'options' => ['connect' => true, 'socketTimeoutMS' => 60000]];
     \Reach\Service\Container::register('mongo', self::$config, '\\Reach\\Mongo\\Connection');
     self::$connection = \Reach\Service\Container::getDI()->get('mongo');
     //ConnectionManager::registerConnection(self::$config);
     //self::$connection = ConnectionManager::getConnection();
     if (!self::$phactory) {
         if (!self::$connection->getDb() instanceof \MongoDB) {
             throw new \Exception('Could not connect to MongoDB');
         }
         self::$phactory = new Phactory(self::$connection->getDb());
         self::$phactory->reset();
     }
     //set up Phactory db connection
     self::$phactory->reset();
 }
예제 #4
0
 public static function setUpBeforeClass()
 {
     self::$config = ['class' => '\\Reach\\Sphinx\\Connection', 'host' => 'localhost', 'port' => 9312];
     \Reach\Service\Container::register('sphinx', self::$config);
     self::$connection = \Reach\Service\Container::get('sphinx');
 }