Пример #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);
 }
Пример #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');
 }
Пример #3
0
 /**
  * @covers ::lastInsertId
  */
 public function testLastInsertIdThrowsUnsupportedException()
 {
     $this->setExpectedException(UnsupportedException::class);
     $this->pdo->lastInsertId();
 }
Пример #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);
 }
Пример #5
0
 /**
  * {@inheritDoc}
  */
 public static function getAvailableDrivers()
 {
     return array_merge(parent::getAvailableDrivers(), [static::DRIVER_NAME]);
 }