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