forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--TEST-- | ||
SQLite3::backup test | ||
--SKIPIF-- | ||
<?php require_once(__DIR__ . '/skipif.inc'); ?> | ||
--FILE-- | ||
<?php | ||
|
||
require_once(__DIR__ . '/new_db.inc'); | ||
|
||
echo "Creating table\n"; | ||
$db->exec('CREATE TABLE test (a, b);'); | ||
$db->exec('INSERT INTO test VALUES (42, \'php\');'); | ||
|
||
echo "Checking if table has been created\n"; | ||
var_dump($db->querySingle('SELECT COUNT(*) FROM sqlite_master;')); | ||
|
||
$db2 = new SQLite3(':memory:'); | ||
|
||
echo "Backup to DB2\n"; | ||
var_dump($db->backup($db2)); | ||
|
||
echo "Checking if table has been copied\n"; | ||
var_dump($db2->querySingle('SELECT COUNT(*) FROM sqlite_master;')); | ||
|
||
echo "Checking backup contents\n"; | ||
var_dump($db2->querySingle('SELECT a FROM test;')); | ||
var_dump($db2->querySingle('SELECT b FROM test;')); | ||
|
||
echo "Resetting DB2\n"; | ||
|
||
$db2->close(); | ||
$db2 = new SQLite3(':memory:'); | ||
|
||
echo "Locking DB1\n"; | ||
var_dump($db->exec('BEGIN EXCLUSIVE;')); | ||
|
||
echo "Backup to DB2 (should fail)\n"; | ||
var_dump($db->backup($db2)); | ||
|
||
?> | ||
--EXPECTF-- | ||
Creating table | ||
Checking if table has been created | ||
int(1) | ||
Backup to DB2 | ||
bool(true) | ||
Checking if table has been copied | ||
int(1) | ||
Checking backup contents | ||
int(42) | ||
string(3) "php" | ||
Resetting DB2 | ||
Locking DB1 | ||
bool(true) | ||
Backup to DB2 (should fail) | ||
|
||
Warning: SQLite3::backup(): Backup failed: source database is busy in %s on line %d | ||
bool(false) |