Ejemplo n.º 1
0
 /**
  * @dataProvider fetchAllStyleProvider
  * @covers ::fetchAll
  *
  * @param string $fetchStyle
  * @param array  $expected
  */
 public function testFetchAll($fetchStyle, array $expected)
 {
     $this->callbackReturnValue = $this->getPopulatedCollection();
     $this->pdo->expects($this->any())->method('getAttribute')->with(PDO::ATTR_DEFAULT_FETCH_MODE)->will($this->returnValue(PDO::FETCH_BOTH));
     $result = $this->statement->fetchAll($fetchStyle);
     $this->assertEquals($expected, $result);
 }
Ejemplo n.º 2
0
 protected function insertRow($id, $name)
 {
     $this->pdo->exec(sprintf("INSERT INTO test_table (id, name) VALUES (%d, '%s')", $id, $name));
     $this->pdo->query('refresh table test_table');
 }
Ejemplo n.º 3
0
 /**
  * @covers ::lastInsertId
  */
 public function testLastInsertIdThrowsUnsupportedException()
 {
     $this->setExpectedException(UnsupportedException::class);
     $this->pdo->lastInsertId();
 }
Ejemplo n.º 4
0
 /**
  * @param string $dsn
  * @param string $user
  * @param string $password
  * @param array $options
  */
 public function __construct($dsn, $user = null, $password = null, array $options = null)
 {
     parent::__construct($dsn, $user, $password, $options);
     $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 }
Ejemplo n.º 5
0
 /**
  * {@inheritDoc}
  */
 public static function getAvailableDrivers()
 {
     return array_merge(parent::getAvailableDrivers(), [static::DRIVER_NAME]);
 }