Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/bug66033.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ $pdo->exec("CREATE TABLE IF NOT EXISTS messages (
try {
$pdoStatement = $pdo->query("select * from messages");
} catch (Exception $e) {
var_dump($e->getMessage());
echo $e::class, ': ', $e->getMessage(), "\n";
}
?>
--EXPECT--
string(4) "Blah"
Exception: Blah
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/bug81227.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ var_dump($db->inTransaction());
try {
$db->beginTransaction();
} catch (PDOException $e) {
echo $e->getMessage(), "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

$db->commit();
Expand All @@ -25,6 +25,6 @@ var_dump($db->inTransaction());
--EXPECT--
bool(false)
bool(true)
There is already an active transaction
PDOException: There is already an active transaction
bool(false)
bool(true)
8 changes: 4 additions & 4 deletions ext/pdo_sqlite/tests/bug_44159_sqlite_version.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
try {
var_dump($pdo->setAttribute(PDO::NULL_TO_STRING, NULL));
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
var_dump($pdo->setAttribute(PDO::NULL_TO_STRING, 1));
try {
var_dump($pdo->setAttribute(PDO::NULL_TO_STRING, 'nonsense'));
} catch (\TypeError $e) {
echo $e->getMessage(), \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

@unlink(__DIR__."/foo.db");

?>
--EXPECT--
Attribute value must be of type int for selected attribute, null given
TypeError: Attribute value must be of type int for selected attribute, null given
bool(true)
Attribute value must be of type int for selected attribute, string given
TypeError: Attribute value must be of type int for selected attribute, string given
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/gh14712.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ $db = new PDO('sqlite::memory:');
try {
$db->query("select 1 as queryStringxx")->fetch(PDO::FETCH_LAZY)->documentElement->firstChild->nextElementSibling->textContent = "é";
} catch (Error $e) {
echo $e->getMessage();
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
Attempt to modify property "firstChild" on null
Error: Attempt to modify property "firstChild" on null
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/gh9032.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ $st = $db->prepare('attach database :a AS "db2"');
$st->execute([':a' => ':memory:']);
var_dump($db->exec('create table db2.r (id int)'));
} catch (PDOException $ex) {
echo $ex->getMessage(), PHP_EOL;
echo $ex::class, ': ', $ex->getMessage(), PHP_EOL;
}
?>
--EXPECT--
int(0)
SQLSTATE[HY000]: General error: 23 not authorized
PDOException: SQLSTATE[HY000]: General error: 23 not authorized
12 changes: 6 additions & 6 deletions ext/pdo_sqlite/tests/open_basedir.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ chdir(__DIR__);
try {
$db = new PDO('sqlite:../not_in_open_basedir.sqlite');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
$db = new PDO('sqlite:file:../not_in_open_basedir.sqlite');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}
try {
$db = new PDO('sqlite:file:../not_in_open_basedir.sqlite?mode=ro');
} catch (Exception $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
open_basedir prohibits opening ../not_in_open_basedir.sqlite
open_basedir prohibits opening file:../not_in_open_basedir.sqlite
open_basedir prohibits opening file:../not_in_open_basedir.sqlite?mode=ro
PDOException: open_basedir prohibits opening ../not_in_open_basedir.sqlite
PDOException: open_basedir prohibits opening file:../not_in_open_basedir.sqlite
PDOException: open_basedir prohibits opening file:../not_in_open_basedir.sqlite?mode=ro
2 changes: 1 addition & 1 deletion ext/pdo_sqlite/tests/pdo_sqlite___construct_uri.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ var_dump(file_exists($dbFile));
try {
new PDO("uri:{$dsnFile}");
} catch (Throwable $e) {
echo $e::class, ": ", $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

clearstatcache();
Expand Down
8 changes: 4 additions & 4 deletions ext/pdo_sqlite/tests/pdo_sqlite_createaggregate_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ $pdo = new PDO('sqlite::memory:');
try {
$pdo->sqliteCreateAggregate('foo', 'a', '');
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
$pdo->sqliteCreateAggregate('foo', 'strlen', '');
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
Deprecated: Method PDO::sqliteCreateAggregate() is deprecated since 8.5, use Pdo\Sqlite::createAggregate() instead in %s on line %d
PDO::sqliteCreateAggregate(): Argument #2 ($step) must be a valid callback, function "a" not found or invalid function name
TypeError: PDO::sqliteCreateAggregate(): Argument #2 ($step) must be a valid callback, function "a" not found or invalid function name

Deprecated: Method PDO::sqliteCreateAggregate() is deprecated since 8.5, use Pdo\Sqlite::createAggregate() instead in %s on line %d
PDO::sqliteCreateAggregate(): Argument #3 ($finalize) must be a valid callback, function "" not found or invalid function name
TypeError: PDO::sqliteCreateAggregate(): Argument #3 ($finalize) must be a valid callback, function "" not found or invalid function name
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/pdo_sqlite_createcollation.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $db->sqliteCreateCollation('MYCOLLATEBAD', function($a, $b) { return $a; });
try {
$db->query('SELECT name FROM test_pdo_sqlite_createcollation ORDER BY name COLLATE MYCOLLATEBAD');
} catch (\TypeError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECTF--
Expand All @@ -42,4 +42,4 @@ Deprecated: Method PDO::sqliteCreateCollation() is deprecated since 8.5, use Pdo
2

Deprecated: Method PDO::sqliteCreateCollation() is deprecated since 8.5, use Pdo\Sqlite::createCollation() instead in %s on line %d
PDO::query(): Return value of the collation callback must be of type int, string returned
TypeError: PDO::query(): Return value of the collation callback must be of type int, string returned
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/pdo_sqlite_createfunction_002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ $db = new PDO( 'sqlite::memory:');
try {
$db->sqliteCreateFunction('bar-alias', 'bar');
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECTF--
Deprecated: Method PDO::sqliteCreateFunction() is deprecated since 8.5, use Pdo\Sqlite::createFunction() instead in %s on line %d
PDO::sqliteCreateFunction(): Argument #2 ($callback) must be a valid callback, function "bar" not found or invalid function name
TypeError: PDO::sqliteCreateFunction(): Argument #2 ($callback) must be a valid callback, function "bar" not found or invalid function name
8 changes: 4 additions & 4 deletions ext/pdo_sqlite/tests/subclasses/gh_16131.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pdo_sqlite
try {
new Pdo\Pgsql('sqlite::memory:');
} catch (PDOException $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

class MyPgsql extends Pdo\Pgsql
Expand All @@ -19,10 +19,10 @@ class MyPgsql extends Pdo\Pgsql
try {
new MyPgsql('sqlite::memory:');
} catch (PDOException $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Pdo\Pgsql::__construct() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::__construct() or PDO::__construct() instead
MyPgsql::__construct() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::__construct() or PDO::__construct() instead
PDOException: Pdo\Pgsql::__construct() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::__construct() or PDO::__construct() instead
PDOException: MyPgsql::__construct() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::__construct() or PDO::__construct() instead
Original file line number Diff line number Diff line change
Expand Up @@ -18,32 +18,32 @@ class TrampolineTest {
try {
$db->createFunction(null, [new TrampolineTest(), 'strtoupper']);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createFunction('strtoupper', null);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'], null);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createFunction('strtoupper', [new TrampolineTest(), 'strtoupper'], 1, null);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo 'done!';
?>
--EXPECT--
Pdo\Sqlite::createFunction(): Argument #1 ($function_name) must be of type string, null given
Pdo\Sqlite::createFunction(): Argument #2 ($callback) must be a valid callback, no array or string given
Pdo\Sqlite::createFunction(): Argument #3 ($num_args) must be of type int, null given
Pdo\Sqlite::createFunction(): Argument #4 ($flags) must be of type int, null given
TypeError: Pdo\Sqlite::createFunction(): Argument #1 ($function_name) must be of type string, null given
TypeError: Pdo\Sqlite::createFunction(): Argument #2 ($callback) must be a valid callback, no array or string given
TypeError: Pdo\Sqlite::createFunction(): Argument #3 ($num_args) must be of type int, null given
TypeError: Pdo\Sqlite::createFunction(): Argument #4 ($flags) must be of type int, null given
done!
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ $pdo = new Pdo\Sqlite('sqlite::memory:');
try {
$pdo->createAggregate('foo', 'a', '');
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
try {
$pdo->createAggregate('foo', 'strlen', '');
} catch (\TypeError $e) {
echo $e->getMessage() . \PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

?>
--EXPECT--
Pdo\Sqlite::createAggregate(): Argument #2 ($step) must be a valid callback, function "a" not found or invalid function name
Pdo\Sqlite::createAggregate(): Argument #3 ($finalize) must be a valid callback, function "" not found or invalid function name
TypeError: Pdo\Sqlite::createAggregate(): Argument #2 ($step) must be a valid callback, function "a" not found or invalid function name
TypeError: Pdo\Sqlite::createAggregate(): Argument #3 ($finalize) must be a valid callback, function "" not found or invalid function name
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,46 @@ class TrampolineTest {
try {
$db->createAggregate(null, [new TrampolineTest(), 'step'], null, 1);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createAggregate(null, null, [new TrampolineTest(), 'step'], 1);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createAggregate(null, [new TrampolineTest(), 'step'], [new TrampolineTest(), 'step'], 1);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createAggregate('S', null, [new TrampolineTest(), 'finalize'], 1);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createAggregate('S', [new TrampolineTest(), 'step'], null, 1);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createAggregate('S', [new TrampolineTest(), 'step'], [new TrampolineTest(), 'finalize'], null);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo 'done!';
?>
--EXPECT--
Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
Pdo\Sqlite::createAggregate(): Argument #2 ($step) must be a valid callback, no array or string given
Pdo\Sqlite::createAggregate(): Argument #3 ($finalize) must be a valid callback, no array or string given
Pdo\Sqlite::createAggregate(): Argument #4 ($numArgs) must be of type int, null given
TypeError: Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
TypeError: Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
TypeError: Pdo\Sqlite::createAggregate(): Argument #1 ($name) must be of type string, null given
TypeError: Pdo\Sqlite::createAggregate(): Argument #2 ($step) must be a valid callback, no array or string given
TypeError: Pdo\Sqlite::createAggregate(): Argument #3 ($finalize) must be a valid callback, no array or string given
TypeError: Pdo\Sqlite::createAggregate(): Argument #4 ($numArgs) must be of type int, null given
done!
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ class TrampolineTest {
try {
$db->createCollation(null, [new TrampolineTest(), 'NAT']);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

try {
$db->createCollation('NAT', null);
} catch (Throwable $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

echo 'done!';
?>
--EXPECT--
Pdo\Sqlite::createCollation(): Argument #1 ($name) must be of type string, null given
Pdo\Sqlite::createCollation(): Argument #2 ($callback) must be a valid callback, no array or string given
TypeError: Pdo\Sqlite::createCollation(): Argument #1 ($name) must be of type string, null given
TypeError: Pdo\Sqlite::createCollation(): Argument #2 ($callback) must be a valid callback, no array or string given
done!
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ $db->createCollation('NAT', function($a, $b): string { return $a . $b; });
try {
$db->query("SELECT c FROM test ORDER BY c COLLATE NAT");
} catch (\TypeError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
?>
--EXPECT--
PDO::query(): Return value of the collation callback must be of type int, string returned
TypeError: PDO::query(): Return value of the collation callback must be of type int, string returned
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,25 @@ class Duh {}
try {
$stmts->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, "EXPLAIN");
} catch (\TypeError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

try {
$stmts->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, new Duh());
} catch (\TypeError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

try {
$stmts->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, -1);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

try {
$stmts->setAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT, 256);
} catch (\ValueError $e) {
echo $e->getMessage(), PHP_EOL;
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

var_dump($stmts->getAttribute(Pdo\Sqlite::ATTR_EXPLAIN_STATEMENT) == Pdo\Sqlite::EXPLAIN_MODE_PREPARED);
Expand Down Expand Up @@ -393,8 +393,8 @@ array(2) {
string(13) "second_insert"
}
}
explain mode must be of type int, string given
explain mode must be of type int, Duh given
explain mode must be one of the Pdo\Sqlite::EXPLAIN_MODE_* constants
explain mode must be one of the Pdo\Sqlite::EXPLAIN_MODE_* constants
TypeError: explain mode must be of type int, string given
TypeError: explain mode must be of type int, Duh given
ValueError: explain mode must be one of the Pdo\Sqlite::EXPLAIN_MODE_* constants
ValueError: explain mode must be one of the Pdo\Sqlite::EXPLAIN_MODE_* constants
bool(true)
4 changes: 2 additions & 2 deletions ext/pdo_sqlite/tests/subclasses/pdosqlite_005.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ pdo_sqlite
try {
Pdo\Pgsql::connect('sqlite::memory:');
} catch (PDOException $e) {
echo $e->getMessage() . "\n";
echo $e::class, ': ', $e->getMessage(), "\n";
}

?>
--EXPECT--
Pdo\Pgsql::connect() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::connect() or PDO::connect() instead
PDOException: Pdo\Pgsql::connect() cannot be used for connecting to the "sqlite" driver, either call Pdo\Sqlite::connect() or PDO::connect() instead
Loading
Loading