mirror of
https://github.com/dg/dibi.git
synced 2025-02-23 10:26:21 +01:00
35 lines
823 B
PHP
35 lines
823 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use Tester\Assert;
|
|
|
|
require __DIR__ . '/bootstrap.php';
|
|
|
|
|
|
function buildPdoDriver(?int $errorMode)
|
|
{
|
|
$pdo = new PDO('sqlite::memory:');
|
|
if ($errorMode !== null) {
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, $errorMode);
|
|
}
|
|
new Dibi\Drivers\PdoDriver(['resource' => $pdo]);
|
|
}
|
|
|
|
|
|
// PDO error mode: exception
|
|
Assert::exception(function () {
|
|
buildPdoDriver(PDO::ERRMODE_EXCEPTION);
|
|
}, Dibi\DriverException::class, 'PDO connection in exception or warning error mode is not supported.');
|
|
|
|
|
|
// PDO error mode: warning
|
|
Assert::exception(function () {
|
|
buildPdoDriver(PDO::ERRMODE_WARNING);
|
|
}, Dibi\DriverException::class, 'PDO connection in exception or warning error mode is not supported.');
|
|
|
|
|
|
test('PDO error mode: explicitly set silent', function () {
|
|
buildPdoDriver(PDO::ERRMODE_SILENT);
|
|
});
|