Exemplo n.º 1
0
 public function testFailedAttemptThenSucceeds()
 {
     $this->factory->expects($this->any())->method('create')->will($this->returnValue($this->pdo));
     $pdoStatement = $this->getMock(\PDOStatement::class);
     $pdoStatement->expects($this->any())->method('execute')->will($this->onConsecutiveCalls($this->throwException(new \PDOException()), $this->returnValue(true)));
     $this->pdo->expects($this->any())->method('prepare')->will($this->returnValue($pdoStatement));
     $this->config->expects($this->any())->method('getMaximumAttempts')->will($this->returnValue(2));
     $this->assertSame($this->pdo, $this->factory->__invoke($this->config));
 }
Exemplo n.º 2
0
Arquivo: Adapter.php Projeto: phlib/db
 /**
  * Set the timezone on the connection.
  *
  * @param string $timezone
  * @return Adapter
  */
 public function setTimezone($timezone)
 {
     if ($this->config->getTimezone() !== $timezone) {
         $this->config->setTimezone($timezone);
         if ($this->connection) {
             $this->query('SET time_zone = ?', array($timezone));
         }
     }
     return $this;
 }
Exemplo n.º 3
0
 /**
  * @expectedException \Phlib\Db\Exception\InvalidArgumentException
  */
 public function testGetDsnWithoutHost()
 {
     $config = new Config([]);
     $config->getDsn();
 }
Exemplo n.º 4
0
 /**
  * @param Config $config
  * @return \PDO
  */
 public function create(Config $config)
 {
     return new \PDO($config->getDsn(), $config->getUsername(), $config->getPassword(), $config->getOptions());
 }