public function setUp()
{
$this->pathToDb = tempnam(sys_get_temp_dir(), 'Sonata_exporter_');
if (!in_array('sqlite', \PDO::getAvailableDrivers())) {
$this->markTestSkipped('the sqlite extension is not available');
}
if (is_file($this->pathToDb)) {
unlink($this->pathToDb);
}
$this->dbh = new \PDO('sqlite:' . $this->pathToDb);
$this->dbh->exec('CREATE TABLE `user` (`id` int(11), `username` varchar(255) NOT NULL, `email` varchar(255) NOT NULL )');
$data = array(array(1, 'john', '[email protected]'), array(2, 'john 2', '[email protected]'), array(3, 'john 3', '[email protected]'));
foreach ($data as $user) {
$query = $this->dbh->prepare('INSERT INTO user (id, username, email) VALUES(?, ?, ?)');
$query->execute($user);
}
}