Ejemplo n.º 1
0
 public function __construct($credentials = null, $loop = null)
 {
     if (!is_null($credentials)) {
         ConnectionFactory::init($credentials);
     }
     // Use the provided loop, otherwise create one.
     $this->loop = $loop ?: Factory::create();
     $this->initLoop();
     $this->pool = new ConnectionPool();
 }
Ejemplo n.º 2
0
 /**
  * TODO: This test is still todo.
  *
  * @throws \Exception
  */
 public function testParamCounting()
 {
     // Note: Used a comma rather than => so it was failing.
     // param count would detect this sooner.
     // Intentionally bad parameters to ensure check.
     $badParams = [':test', 1];
     // The programmer's intent was:
     // $goodParams = [ ':test' => 1, ]
     $command = new Command('SELECT * FROM simple_table WHERE id = :test', $badParams);
     $connection = ConnectionFactory::createConnection();
     $query = $command->getPreparedQuery($connection);
     // TODO: Here is the bad result, :test should have been 1
     // TODO: GetPreparedQuery should error on param mismatch
     $this->assertStringEqualsIgnoreSpacing('SELECT * FROM simple_table WHERE id = :test', $query);
 }
 /**
  * @expectedException \PHPUnit_Framework_Error_Warning
  */
 public function testBadCredentials()
 {
     ConnectionFactory::init(['localhost', 'bad.username', 'bad.password', 'fake']);
     ConnectionFactory::createConnection();
 }
Ejemplo n.º 4
0
 public function setUp()
 {
     parent::setUp();
     $this->initDatabase();
     ConnectionFactory::init($this->getCredentials());
 }