diff options
Diffstat (limited to 'ext/sqlite3/tests')
74 files changed, 2602 insertions, 0 deletions
diff --git a/ext/sqlite3/tests/bug45798.phpt b/ext/sqlite3/tests/bug45798.phpt new file mode 100644 index 0000000..1beacc4 --- /dev/null +++ b/ext/sqlite3/tests/bug45798.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug #45798 (sqlite3 doesn't notice if variable was bound) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +$db->exec('CREATE TABLE test (time INTEGER, id STRING)'); + +$db->exec("INSERT INTO test (time, id) VALUES (" . time() . ", 'a')"); +$db->exec("INSERT INTO test (time, id) VALUES (" . time() . ", 'b')"); + +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); + +$stmt->bindParam(1, $foo, SQLITE3_TEXT); +$results = $stmt->execute(); + +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} + +$results->finalize(); + +$db->close(); + +print "done"; + +?> +--EXPECT-- +done diff --git a/ext/sqlite3/tests/bug47159.phpt b/ext/sqlite3/tests/bug47159.phpt new file mode 100644 index 0000000..f8ffa28 --- /dev/null +++ b/ext/sqlite3/tests/bug47159.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #45798 (sqlite3 doesn't track unexecuted statements) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +$stmt = $db->prepare("SELECT 1"); + +var_dump($stmt->close()); + +var_dump($db->close()); + +print "done"; + +?> +--EXPECT-- +bool(true) +bool(true) +done diff --git a/ext/sqlite3/tests/bug53463.phpt b/ext/sqlite3/tests/bug53463.phpt new file mode 100644 index 0000000..744a214 --- /dev/null +++ b/ext/sqlite3/tests/bug53463.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #53463 (sqlite3 columnName() segfaults on bad column_number) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); + +$db->exec('CREATE TABLE test (whatever INTEGER)'); +$db->exec('INSERT INTO test (whatever) VALUES (1)'); + +$result = $db->query('SELECT * FROM test'); +while ($row = $result->fetchArray(SQLITE3_NUM)) { + var_dump($result->columnName(0)); // string(8) "whatever" + + // Seems returning false will be most appropriate. + var_dump($result->columnName(3)); // Segmentation fault +} + +$result->finalize(); +$db->close(); + +echo "Done\n"; + +?> +--EXPECT-- +string(8) "whatever" +bool(false) +Done diff --git a/ext/sqlite3/tests/bug63921-32bit.phpt b/ext/sqlite3/tests/bug63921-32bit.phpt new file mode 100644 index 0000000..8c1c6b9 --- /dev/null +++ b/ext/sqlite3/tests/bug63921-32bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API +--SKIPIF-- +<?php +if (!extension_loaded('sqlite3')) die('skip'); +if (PHP_INT_SIZE > 4) die('skip'); // skip for 64bit builds - there is another test for that +?> +--FILE-- +<?php +$num = PHP_INT_MAX; // 32 bits +$conn = new sqlite3(':memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->bindValue(':num', $num, SQLITE3_INTEGER); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchArray(); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(2147483647) +string(10) "2147483647" diff --git a/ext/sqlite3/tests/bug63921-64bit.phpt b/ext/sqlite3/tests/bug63921-64bit.phpt new file mode 100644 index 0000000..8e821fd --- /dev/null +++ b/ext/sqlite3/tests/bug63921-64bit.phpt @@ -0,0 +1,27 @@ +--TEST-- +Bug #63921 sqlite3::bindvalue and relative PHP functions aren't using sqlite3_*_int64 API +--SKIPIF-- +<?php +if (!extension_loaded('sqlite3')) die('skip'); +if (PHP_INT_SIZE < 8) die('skip'); // skip for 32bit builds - there is another test for that +?> +--FILE-- +<?php +$num = 100004313234244; // notice this exceeds 32 bits +$conn = new sqlite3(':memory:'); +$conn->query('CREATE TABLE users (id INTEGER NOT NULL, num INTEGER NOT NULL, PRIMARY KEY(id))'); + +$stmt = $conn->prepare('insert into users (id, num) values (:id, :num)'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->bindValue(':num', $num, SQLITE3_INTEGER); +$stmt->execute(); + +$stmt = $conn->query('SELECT num FROM users'); +$result = $stmt->fetchArray(); + +var_dump($num,$result[0]); + +?> +--EXPECT-- +int(100004313234244) +string(15) "100004313234244" diff --git a/ext/sqlite3/tests/new_db.inc b/ext/sqlite3/tests/new_db.inc new file mode 100644 index 0000000..068d7ba --- /dev/null +++ b/ext/sqlite3/tests/new_db.inc @@ -0,0 +1,5 @@ +<?php + +$db = new SQLite3(':memory:'); + +?> diff --git a/ext/sqlite3/tests/skipif.inc b/ext/sqlite3/tests/skipif.inc new file mode 100644 index 0000000..3427965 --- /dev/null +++ b/ext/sqlite3/tests/skipif.inc @@ -0,0 +1,7 @@ +<?php + +if (!extension_loaded('sqlite3')) { + die("skip"); +} + +?> diff --git a/ext/sqlite3/tests/sqlite3_01_open.phpt b/ext/sqlite3/tests/sqlite3_01_open.phpt new file mode 100644 index 0000000..11c4827 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_01_open.phpt @@ -0,0 +1,18 @@ +--TEST-- +SQLite3::open/close tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +var_dump($db); +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +object(SQLite3)#%d (0) { +} +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_02_create.phpt b/ext/sqlite3/tests/sqlite3_02_create.phpt new file mode 100644 index 0000000..5a1aa71 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_02_create.phpt @@ -0,0 +1,34 @@ +--TEST-- +SQLite3::query CREATE tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "Creating Same Table Again\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "Dropping database\n"; +var_dump($db->exec('DROP TABLE test')); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +Creating Same Table Again + +Warning: SQLite3::exec(): table test already exists in %s on line %d +bool(false) +Dropping database +bool(true) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_02_open.phpt b/ext/sqlite3/tests/sqlite3_02_open.phpt new file mode 100644 index 0000000..f9155e7 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_02_open.phpt @@ -0,0 +1,19 @@ +--TEST-- +SQLite3::open test, testing for function parameters +--CREDITS-- +Felix De Vliegher +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +try { + $db = new SQLite3(); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +?> +--EXPECTF-- +%string|unicode%(60) "SQLite3::__construct() expects at least 1 parameter, 0 given" diff --git a/ext/sqlite3/tests/sqlite3_03_insert.phpt b/ext/sqlite3/tests/sqlite3_03_insert.phpt new file mode 100644 index 0000000..7a9feda --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_03_insert.phpt @@ -0,0 +1,51 @@ +--TEST-- +SQLite3::query INSERT tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_04_update.phpt b/ext/sqlite3/tests/sqlite3_04_update.phpt new file mode 100644 index 0000000..4a84fdd --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_04_update.phpt @@ -0,0 +1,77 @@ +--TEST-- +SQLite3::query UPDATE tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "UPDATING results\n"; +var_dump($db->exec("UPDATE test SET id = 'c' WHERE id = 'a'")); + +echo "Checking results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +UPDATING results +bool(true) +Checking results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "c" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_05_delete.phpt b/ext/sqlite3/tests/sqlite3_05_delete.phpt new file mode 100644 index 0000000..b35e7c1 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_05_delete.phpt @@ -0,0 +1,71 @@ +--TEST-- +SQLite3::query DELETE tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "DELETING a row\n"; +var_dump($db->exec("DELETE FROM test WHERE id = 'a'")); + +echo "Checking results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +DELETING a row +bool(true) +Checking results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt b/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt new file mode 100644 index 0000000..403adbb --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_06_prepared_stmt.phpt @@ -0,0 +1,52 @@ +--TEST-- +SQLite3::prepare Bound Variable test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +$foo = 'c'; +echo "BINDING Parameter\n"; +var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); +$foo = 'a'; +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +BINDING Parameter +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt b/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt new file mode 100644 index 0000000..7a3d950 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_07_prepared_stmt.phpt @@ -0,0 +1,51 @@ +--TEST-- +SQLite3::prepare Bound Value test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +$foo = 'a'; +echo "BINDING Value\n"; +var_dump($stmt->bindValue(1, $foo, SQLITE3_TEXT)); +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +BINDING Value +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_08_udf.phpt b/ext/sqlite3/tests/sqlite3_08_udf.phpt new file mode 100644 index 0000000..d6a326c --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_08_udf.phpt @@ -0,0 +1,57 @@ +--TEST-- +SQLite3::createFunction +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +function my_udf_md5($foo) +{ + return md5($foo); +} + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "CREATING UDF\n"; +var_dump($db->createFunction('my_udf_md5', 'my_udf_md5')); + +echo "SELECTING results\n"; +$results = $db->query("SELECT my_udf_md5(id) FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +CREATING UDF +bool(true) +SELECTING results +array(1) { + [0]=> + string(32) "0cc175b9c0f1b6a831c399e269772661" +} +array(1) { + [0]=> + string(32) "92eb5ffee6ae2fec3ad71c777531578f" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt b/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt new file mode 100644 index 0000000..ccc6a8b --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_09_blob_bound_param.phpt @@ -0,0 +1,61 @@ +--TEST-- +SQLite3::prepare Bound Variable Blob test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +require_once(dirname(__FILE__) . '/stream_test.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (id STRING, data BLOB)')); + +echo "PREPARING insert\n"; +$insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (?, ?)"); + +echo "Opening blob stream\n"; +$foo = fopen('sqliteBlobTest://fooo', 'r'); +var_dump($foo); + +echo "BINDING Parameter\n"; +var_dump($insert_stmt->bindValue(1, 'a', SQLITE3_TEXT)); +var_dump($insert_stmt->bindParam(2, $foo, SQLITE3_BLOB)); +$insert_stmt->execute(); +echo "Closing statement\n"; +var_dump($insert_stmt->close()); + +echo "SELECTING results\n"; +$results = $db->query("SELECT id, quote(data) AS data FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +PREPARING insert +Opening blob stream +resource(%d) of type (stream) +BINDING Parameter +bool(true) +bool(true) +Closing statement +bool(true) +SELECTING results +array(2) { + [0]=> + string(1) "a" + [1]=> + string(23) "X'61626364656667006869'" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt b/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt new file mode 100644 index 0000000..35852ba --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_10_bound_value_name.phpt @@ -0,0 +1,55 @@ +--TEST-- +SQLite3::prepare Bound Value test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = :id ORDER BY id ASC"); +$foo = 'a'; +echo "BINDING Value\n"; +var_dump($stmt->bindValue(':id', $foo, SQLITE3_TEXT)); +echo "BINDING Value Again\n"; +var_dump($stmt->bindValue('id', $foo, SQLITE3_TEXT)); +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +BINDING Value +bool(true) +BINDING Value Again +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_11_numrows.phpt b/ext/sqlite3/tests/sqlite3_11_numrows.phpt new file mode 100644 index 0000000..8e2d428 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_11_numrows.phpt @@ -0,0 +1,46 @@ +--TEST-- +SQLite3::prepare number of rows +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +// Create an instance of the ReflectionMethod class +try { + $method = new ReflectionMethod('sqlite3result', 'numRows'); +} catch (ReflectionException $e) { + die("skip"); +} +?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +echo "Number of rows\n"; +var_dump($results->numRows()); +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +Number of rows +int(2) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt b/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt new file mode 100644 index 0000000..2bfd0af --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_12_unfinalized_stmt_cleanup.phpt @@ -0,0 +1,52 @@ +--TEST-- +SQLite3::query Unfinalized statement tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); + /* Only read one row and break */ + break; +} + +echo "Closing database\n"; +var_dump($db->close()); +echo "Check db was closed\n"; +var_dump($results->numColumns()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +Closing database +bool(true) +Check db was closed + +Warning: SQLite3Result::numColumns(): The SQLite3Result object has not been correctly initialised in %s on line %d +bool(false) +Done diff --git a/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt b/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt new file mode 100644 index 0000000..573d87f --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_13_skip_all_cleanup.phpt @@ -0,0 +1,45 @@ +--TEST-- +SQLite3::query Skip all cleanup +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +Done diff --git a/ext/sqlite3/tests/sqlite3_14_querysingle.phpt b/ext/sqlite3/tests/sqlite3_14_querysingle.phpt new file mode 100644 index 0000000..8cfe089 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_14_querysingle.phpt @@ -0,0 +1,38 @@ +--TEST-- +SQLite3::querySingle tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +var_dump($db->querySingle("SELECT id FROM test WHERE id = 'a'")); +var_dump($db->querySingle("SELECT id, time FROM test WHERE id = 'a'", true)); + +echo "Done" +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +string(1) "a" +array(2) { + ["id"]=> + string(1) "a" + ["time"]=> + int(%d) +} +Done diff --git a/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt b/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt new file mode 100644 index 0000000..6289fac --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_15_open_error-win.phpt @@ -0,0 +1,37 @@ +--TEST-- +SQLite3::open error test +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) != 'WIN' ) { + die('skip windows only test'); +} +require_once(__DIR__ . '/skipif.inc'); +?> +--FILE-- +<?php +$sysroot = exec('echo %systemroot%'); +$icacls = "$sysroot\\System32\\icacls.exe"; +$user = get_current_user(); +$unreadable = __DIR__ . '/unreadable.db'; + +touch($unreadable); +$cmd = $icacls . ' ' . $unreadable . ' /inheritance:r /deny ' . $user . ':(F,M,R,RX,W)'; +exec($cmd); + +try { + $db = new SQLite3($unreadable); +} catch (Exception $e) { + echo $e . "\n"; +} +echo "Done\n"; + +$cmd = $icacls . ' ' . $unreadable . ' /grant ' . $user . ':(F,M,R,RX,W)'; +exec($cmd); +unlink($unreadable); +?> +--EXPECTF-- +exception 'Exception' with message 'Unable to open database: %s' in %ssqlite3_15_open_error-win.php:%d +Stack trace: +#0 %ssqlite3_15_open_error-win.php(%d): SQLite3->__construct('%s') +#1 {main} +Done diff --git a/ext/sqlite3/tests/sqlite3_15_open_error.phpt b/ext/sqlite3/tests/sqlite3_15_open_error.phpt new file mode 100644 index 0000000..fc05b87 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_15_open_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +SQLite3::open error test +--SKIPIF-- +<?php +if(substr(PHP_OS, 0, 3) == 'WIN' ) { + die('skip non windows test'); +} +require_once(__DIR__ . '/skipif.inc'); +if (posix_geteuid() == 0) { + die('SKIP Cannot run test as root.'); +} +?> +--FILE-- +<?php +$unreadable = __DIR__ . '/unreadable.db'; +touch($unreadable); +chmod($unreadable, 0200); +try { + $db = new SQLite3($unreadable); +} catch (Exception $e) { + echo $e . "\n"; +} +echo "Done\n"; +unlink($unreadable); +?> +--EXPECTF-- +exception 'Exception' with message 'Unable to open database: %s' in %ssqlite3_15_open_error.php:%d +Stack trace: +#0 %ssqlite3_15_open_error.php(%d): SQLite3->__construct('%s') +#1 {main} +Done diff --git a/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt b/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt new file mode 100644 index 0000000..de9fdef --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_16_select_no_results.phpt @@ -0,0 +1,32 @@ +--TEST-- +SQLite3::query SELECT with no results +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +SELECTING results +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_17_version.phpt b/ext/sqlite3/tests/sqlite3_17_version.phpt new file mode 100644 index 0000000..4550057 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_17_version.phpt @@ -0,0 +1,16 @@ +--TEST-- +SQLite3::version() +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +print_r(SQLite3::version()); +echo "Done\n"; +?> +--EXPECTF-- +Array +( + [versionString] => %s + [versionNumber] => %d +) +Done diff --git a/ext/sqlite3/tests/sqlite3_18_changes.phpt b/ext/sqlite3/tests/sqlite3_18_changes.phpt new file mode 100644 index 0000000..6802db3 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_18_changes.phpt @@ -0,0 +1,40 @@ +--TEST-- +SQLite3::changes() tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "UPDATE query\n"; +var_dump($db->exec("UPDATE test SET id = 'c'")); + +echo "Rows Updated\n"; +var_dump($db->changes()); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +UPDATE query +bool(true) +Rows Updated +int(2) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_19_columninfo.phpt b/ext/sqlite3/tests/sqlite3_19_columninfo.phpt new file mode 100644 index 0000000..4451bdf --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_19_columninfo.phpt @@ -0,0 +1,45 @@ +--TEST-- +SQLite3 columnType and columnName +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$result = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($row = $result->fetchArray(SQLITE3_NUM)) { + $totalColumns = $result->numColumns(); + for ($i = 0; $i < $totalColumns; $i++) { + echo "Name: " . $result->columnName($i) . " - Type: " . $result->columnType($i) . "\n"; + } +} +$result->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +Name: time - Type: 1 +Name: id - Type: 3 +Name: time - Type: 1 +Name: id - Type: 3 +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_20_error.phpt b/ext/sqlite3/tests/sqlite3_20_error.phpt new file mode 100644 index 0000000..d98644a --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_20_error.phpt @@ -0,0 +1,28 @@ +--TEST-- +SQLite3 error functions +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +echo "SELECTING from invalid table\n"; +$result = $db->query("SELECT * FROM non_existent_table"); +if (!$result) { + echo "Error Code: " . $db->lastErrorCode() . "\n"; + echo "Error Msg: " . $db->lastErrorMsg() . "\n"; +} +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +SELECTING from invalid table + +Warning: SQLite3::query(): Unable to prepare statement: 1, no such table: non_existent_table in %s on line %d +Error Code: 1 +Error Msg: no such table: non_existent_table +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_21_security.phpt b/ext/sqlite3/tests/sqlite3_21_security.phpt new file mode 100644 index 0000000..7e83bb2 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_21_security.phpt @@ -0,0 +1,39 @@ +--TEST-- +SQLite3 open_basedir checks +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--INI-- +open_basedir=. +--FILE-- +<?php +$directory = dirname(__FILE__) . '/'; +$file = uniqid() . '.db'; + +echo "Within test directory\n"; +$db = new SQLite3($directory . $file); +var_dump($db); +var_dump($db->close()); +unlink($directory . $file); + +echo "Above test directory\n"; +try { + $db = new SQLite3('../bad' . $file); +} catch (Exception $e) { + echo $e . "\n"; +} + +echo "Done\n"; +?> +--EXPECTF-- +Within test directory +object(SQLite3)#%d (0) { +} +bool(true) +Above test directory + +Warning: SQLite3::__construct(): open_basedir restriction in effect. File(%s) is not within the allowed path(s): (.) in %ssqlite3_21_security.php on line %d +exception 'Exception' with message 'open_basedir prohibits opening %s' in %ssqlite3_21_security.php:%d +Stack trace: +#0 %ssqlite3_21_security.php(%d): SQLite3->__construct('%s') +#1 {main} +Done diff --git a/ext/sqlite3/tests/sqlite3_22_loadextension.phpt b/ext/sqlite3/tests/sqlite3_22_loadextension.phpt new file mode 100644 index 0000000..091dcd4 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_22_loadextension.phpt @@ -0,0 +1,33 @@ +--TEST-- +SQLite3 load extension +--SKIPIF-- +<?php +require_once(dirname(__FILE__) . '/skipif.inc'); +$r = new ReflectionClass("sqlite3"); +if (!$r->hasMethod("loadExtension")) { + die("skip - sqlite3 doesn't have loadExtension enabled"); +} +?> +--INI-- +open_basedir=. +sqlite3.extension_dir=. +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +$directory = dirname(__FILE__); + +touch($directory . '/myext.txt'); + +var_dump($db->loadExtension('myext.txt')); +var_dump($db->close()); +unlink($directory . '/myext.txt'); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: SQLite3::loadExtension(): Unable to load extension at '.%emyext.txt' in %s on line %d +bool(false) +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_23_escape_string.phpt b/ext/sqlite3/tests/sqlite3_23_escape_string.phpt new file mode 100644 index 0000000..4091ff8 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_23_escape_string.phpt @@ -0,0 +1,51 @@ +--TEST-- +SQLite3::escapeString +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", '" . SQLite3::escapeString("test''%") . "')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$results = $db->query("SELECT * FROM test ORDER BY id ASC"); +while ($result = $results->fetchArray(SQLITE3_NUM)) +{ + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(7) "test''%" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_24_last_insert_rowid.phpt b/ext/sqlite3/tests/sqlite3_24_last_insert_rowid.phpt new file mode 100644 index 0000000..83d0a29 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_24_last_insert_rowid.phpt @@ -0,0 +1,34 @@ +--TEST-- +SQLite3::lastInsertRowID tests +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->lastInsertRowID()); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); +var_dump($db->lastInsertRowID()); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +int(1) +bool(true) +int(2) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt b/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt new file mode 100644 index 0000000..6626ed6 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_25_create_aggregate.phpt @@ -0,0 +1,58 @@ +--TEST-- +SQLite3::createAggregate() test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +function sum_list_step($context, $rows, $string) { + if (empty($context)) + { + $context = array('total' => 0, 'values' => array()); + } + $context['total'] += intval($string); + $context['values'][] = $context['total']; + return $context; +} + +function sum_list_finalize($context) { + return implode(',', $context['values']); +} + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (a INTEGER, b INTEGER)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (a, b) VALUES (1, -1)")); +var_dump($db->exec("INSERT INTO test (a, b) VALUES (2, -2)")); +var_dump($db->exec("INSERT INTO test (a, b) VALUES (3, -3)")); +var_dump($db->exec("INSERT INTO test (a, b) VALUES (4, -4)")); +var_dump($db->exec("INSERT INTO test (a, b) VALUES (4, -4)")); + +$db->createAggregate('S', 'sum_list_step', 'sum_list_finalize', 1); + +print_r($db->querySingle("SELECT S(a), S(b) FROM test", true)); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +Array +( + [S(a)] => 1,3,6,10,14 + [S(b)] => -1,-3,-6,-10,-14 +) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt b/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt new file mode 100644 index 0000000..eda1bd5 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_26_reset_prepared_stmt.phpt @@ -0,0 +1,61 @@ +--TEST-- +SQLite3::reset prepared statement +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +$foo = 'c'; +echo "BINDING Parameter\n"; +var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); +$foo = 'a'; +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} +$stmt->reset(); +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +BINDING Parameter +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt b/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt new file mode 100644 index 0000000..ea7e8bf --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_27_reset_prepared_stmt_result.phpt @@ -0,0 +1,61 @@ +--TEST-- +SQLite3::reset prepared statement results +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +$foo = 'c'; +echo "BINDING Parameter\n"; +var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); +$foo = 'a'; +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} +$results->reset(); +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +BINDING Parameter +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt b/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt new file mode 100644 index 0000000..77a69b3 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_28_clear_bindings.phpt @@ -0,0 +1,65 @@ +--TEST-- +SQLite3_stmt::clear prepared statement results +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +$foo = 'c'; +echo "BINDING Parameter\n"; +var_dump($stmt->bindParam(1, $foo, SQLITE3_TEXT)); +$foo = 'a'; +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} +$stmt->reset(); +$stmt->clear(); +var_dump($stmt->bindValue(1, 'b', SQLITE3_TEXT)); +$results = $stmt->execute(); +while ($result = $results->fetchArray(SQLITE3_NUM)) { + var_dump($result); +} +$results->finalize(); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +BINDING Parameter +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "a" +} +bool(true) +array(2) { + [0]=> + int(%d) + [1]=> + string(1) "b" +} +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_29_createfunction.phpt b/ext/sqlite3/tests/sqlite3_29_createfunction.phpt new file mode 100644 index 0000000..9448b30 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_29_createfunction.phpt @@ -0,0 +1,29 @@ +--TEST-- +SQLite3::createFunction - Basic test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +$func = 'strtoupper'; +var_dump($db->createfunction($func, $func)); +var_dump($db->querySingle('SELECT strtoupper("test")')); + +$func2 = 'strtolower'; +var_dump($db->createfunction($func2, $func2)); +var_dump($db->querySingle('SELECT strtolower("TEST")')); + +var_dump($db->createfunction($func, $func2)); +var_dump($db->querySingle('SELECT strtoupper("tEst")')); + + +?> +--EXPECTF-- +bool(true) +%string|unicode%(4) "TEST" +bool(true) +%string|unicode%(4) "test" +bool(true) +%string|unicode%(4) "test" diff --git a/ext/sqlite3/tests/sqlite3_30_blobopen.phpt b/ext/sqlite3/tests/sqlite3_30_blobopen.phpt new file mode 100644 index 0000000..ed51153 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_30_blobopen.phpt @@ -0,0 +1,50 @@ +--TEST-- +SQLite3::blobOpen stream test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +require_once(dirname(__FILE__) . '/stream_test.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (id STRING, data BLOB)')); + +echo "PREPARING insert\n"; +$insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (?, ?)"); + +echo "BINDING Parameter\n"; +var_dump($insert_stmt->bindValue(1, 'a', SQLITE3_TEXT)); +var_dump($insert_stmt->bindValue(2, 'TEST TEST', SQLITE3_BLOB)); +$insert_stmt->execute(); +echo "Closing statement\n"; +var_dump($insert_stmt->close()); +$stream = $db->openBlob('test', 'data', 1); +var_dump($stream); +echo "Stream Contents\n"; +var_dump(stream_get_contents($stream)); +echo "Closing Stream\n"; +var_dump(fclose($stream)); +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +PREPARING insert +BINDING Parameter +bool(true) +bool(true) +Closing statement +bool(true) +resource(%d) of type (stream) +Stream Contents +string(9) "TEST TEST" +Closing Stream +bool(true) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_31_changes.phpt b/ext/sqlite3/tests/sqlite3_31_changes.phpt new file mode 100644 index 0000000..1667b34 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_31_changes.phpt @@ -0,0 +1,20 @@ +--TEST-- +SQLite3::changes (parameters) tests +--CREDITS-- +Ward Hus +#@PHP TESTFEST 2009 (BELGIUM) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +var_dump($db); +var_dump($db->changes()); +echo "Done\n"; +?> +--EXPECTF-- +object(SQLite3)#1 (0) { +} +int(0) +Done + diff --git a/ext/sqlite3/tests/sqlite3_31_open.phpt b/ext/sqlite3/tests/sqlite3_31_open.phpt new file mode 100644 index 0000000..b30266b --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_31_open.phpt @@ -0,0 +1,22 @@ +--TEST-- +SQLite3::re-initialize object tests +--CREDITS-- +Jelle Lampaert +#Belgian Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +try { + $db = new SQLite3(__DIR__ . '/db1.db'); + $db->open(__DIR__ . '/db1.db'); +} catch (Exception $ex) { + var_dump($ex->getMessage()); +} + +?> +--CLEAN-- +<?php @unlink(__DIR__ . '/db1.db'); ?> +--EXPECTF-- +%string|unicode%(29) "Already initialised DB Object" diff --git a/ext/sqlite3/tests/sqlite3_32_changes.phpt b/ext/sqlite3/tests/sqlite3_32_changes.phpt new file mode 100644 index 0000000..0aad451 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_32_changes.phpt @@ -0,0 +1,17 @@ +--TEST-- +SQLite3::changes empty str tests +--CREDITS-- +Ward Hus +#@ PHP TESTFEST 2009 (BELGIUM) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +//$db = new SQLite3('mysqlitedb.db'); +$db->exec('CREATE TABLE pageView(id INTEGER PRIMARY KEY, page CHAR(256), access INTEGER(10))'); +$db->exec('INSERT INTO pageView (page, access) VALUES (\'test\', \'000000\')'); +echo $db->changes("dummy"); +?> +--EXPECTF-- +Warning: SQLite3::changes() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/sqlite3/tests/sqlite3_32_createAggregate_paramCount.phpt b/ext/sqlite3/tests/sqlite3_32_createAggregate_paramCount.phpt new file mode 100644 index 0000000..8a05c57 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_32_createAggregate_paramCount.phpt @@ -0,0 +1,21 @@ +--TEST-- +SQLite3::createAggregate Test that an error is thrown when no parameters are present +--CREDITS-- +James Cauwelier +# Belgium PHP TestFest +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); + +$db->createAggregate (); + +$db->close(); + +echo "Done" +?> +--EXPECTF-- +Warning: SQLite3::createAggregate() expects at least 3 parameters, 0 given in %s on line %d +Done diff --git a/ext/sqlite3/tests/sqlite3_32_last_insert_rowid_param.phpt b/ext/sqlite3/tests/sqlite3_32_last_insert_rowid_param.phpt new file mode 100644 index 0000000..c696ef9 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_32_last_insert_rowid_param.phpt @@ -0,0 +1,40 @@ +--TEST-- +SQLite3::lastInsertRowID parameter test +--CREDITS-- +Jelle Lampaert +#Belgian Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "Inserting data\n"; +var_dump($db->exec('INSERT INTO test (time, id) VALUES(2, 1)')); + +echo "Request last inserted id\n"; +try { + $db->lastInsertRowID(""); +} catch (Exception $ex) { + var_dump($ex->getMessage()); +} + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done"; +?> +--EXPECTF-- +Creating Table +bool(true) +Inserting data +bool(true) +Request last inserted id + +Warning: SQLite3::lastInsertRowID() expects exactly 0 parameters, %d given in %s on line %d +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_33_createAggregate_notcallable.phpt b/ext/sqlite3/tests/sqlite3_33_createAggregate_notcallable.phpt new file mode 100644 index 0000000..7a1bb28 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_33_createAggregate_notcallable.phpt @@ -0,0 +1,29 @@ +--TEST-- +SQLite3::createAggregate() Test whether a supplied PHP function is valid when using in an aggregate function +--CREDITS-- +James Cauwelier +# Belgium PHP TestFest (2009) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +function aggregate_step ($var) { return $var; } +function aggregate_final ($var) { return $var; } + +$db = new SQLite3(':memory:'); + +$db->createAggregate ('TESTAGGREGATE', 'aggregate_test_step', 'aggregate_final'); +$db->createAggregate ('TESTAGGREGATE2', 'aggregate_step', 'aggregate_test_final'); +var_dump($db->createAggregate ('TESTAGGREGATE3', 'aggregate_step', 'aggregate_final')); + +$db->close(); + +echo "Done" +?> +--EXPECTF-- +Warning: SQLite3::createAggregate(): Not a valid callback function aggregate_test_step in %s on line %d + +Warning: SQLite3::createAggregate(): Not a valid callback function aggregate_test_final in %s on line %d +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_33_load_extension_param.phpt b/ext/sqlite3/tests/sqlite3_33_load_extension_param.phpt new file mode 100644 index 0000000..b7b418c --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_33_load_extension_param.phpt @@ -0,0 +1,23 @@ +--TEST-- +SQLite3::loadExtension with empty extension test +--CREDITS-- +Jelle Lampaert +#Belgian Testfest 2009 +--INI-- +sqlite3.extension_dir=/tmp +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); + +try { + $db->loadExtension(""); +} catch (Extension $ex) { + var_dump($ex->getMessage()); +} + +?> +--EXPECTF-- +Warning: SQLite3::loadExtension(): Empty string as an extension in %s on line %d diff --git a/ext/sqlite3/tests/sqlite3_33_reset.phpt b/ext/sqlite3/tests/sqlite3_33_reset.phpt new file mode 100644 index 0000000..5f513fb --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_33_reset.phpt @@ -0,0 +1,27 @@ +--TEST-- +SQLite3:: reset +--CREDITS-- +Ward Hus & James Cauwelier +#@ PHP TESTFEST 2009 (BELGIUM) +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); + +$db->exec('CREATE TABLE foo (id INTEGER, bar STRING)'); +$db->exec("INSERT INTO foo (id, bar) VALUES (1, 'This is a test')"); + +$stmt = $db->prepare('SELECT bar FROM foo WHERE id=:id'); +$stmt->bindValue(':id', 1, SQLITE3_INTEGER); +$stmt->reset("dummy"); +$stmt->reset(); + +//var_dump($db); +//var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Warning: SQLite3Stmt::reset() expects exactly 0 parameters, 1 given in %s on line %d +Done diff --git a/ext/sqlite3/tests/sqlite3_34_load_extension_ext_dir.phpt b/ext/sqlite3/tests/sqlite3_34_load_extension_ext_dir.phpt new file mode 100644 index 0000000..1d2721b --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_34_load_extension_ext_dir.phpt @@ -0,0 +1,21 @@ +--TEST-- +SQLite3::loadExtension with disabled extensions +--CREDITS-- +Jelle Lampaert +#Belgian Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); + +try { + $db->loadExtension(""); +} catch (Extension $ex) { + var_dump($ex->getMessage()); +} + +?> +--EXPECTF-- +Warning: SQLite3::loadExtension(): SQLite Extension are disabled in %s on line %d diff --git a/ext/sqlite3/tests/sqlite3_35_stmt_readonly.phpt b/ext/sqlite3/tests/sqlite3_35_stmt_readonly.phpt new file mode 100644 index 0000000..0c542a1 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_35_stmt_readonly.phpt @@ -0,0 +1,53 @@ +--TEST-- +SQLite3_stmt::readOnly check +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); +$version = SQLite3::version(); +if ($version['versionNumber'] < 3007004) { + die("skip"); +} +?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); +define('TIMENOW', time()); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'a')")); +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "Checking select statement\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +var_dump($stmt->readOnly()); + +echo "Checking update statement\n"; +$stmt = $db->prepare("UPDATE test SET id = 'c' WHERE id = ?"); +var_dump($stmt->readOnly()); + +echo "Checking delete statement\n"; +$stmt = $db->prepare("DELETE FROM test"); +var_dump($stmt->readOnly()); + +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +Checking select statement +bool(true) +Checking update statement +bool(false) +Checking delete statement +bool(false) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_36_create_collation.phpt b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt new file mode 100644 index 0000000..c4d88c6 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_36_create_collation.phpt @@ -0,0 +1,44 @@ +--TEST-- +Test SQLite3::createCollation() by adding strnatcmp() as an SQL COLLATE sequence +--SKIPIF-- +<?php require_once dirname(__FILE__) . '/skipif.inc'; ?> +--FILE-- +<?php + +require_once dirname(__FILE__) . '/new_db.inc'; + +$db->createCollation('NAT', 'strnatcmp'); + +$db->exec('CREATE TABLE t (s varchar(4))'); + +$stmt = $db->prepare('INSERT INTO t VALUES (?)'); +foreach(array('a1', 'a10', 'a2') as $s){ + $stmt->bindParam(1, $s); + $stmt->execute(); +} + +$defaultSort = $db->query('SELECT s FROM t ORDER BY s'); //memcmp() sort +$naturalSort = $db->query('SELECT s FROM t ORDER BY s COLLATE NAT'); //strnatcmp() sort + +echo "default\n"; +while ($row = $defaultSort->fetchArray()){ + echo $row['s'], "\n"; +} + +echo "natural\n"; +while ($row = $naturalSort->fetchArray()){ + echo $row['s'], "\n"; +} + +$db->close(); + +?> +--EXPECT-- +default +a1 +a10 +a2 +natural +a1 +a2 +a10 diff --git a/ext/sqlite3/tests/sqlite3_close_error.phpt b/ext/sqlite3/tests/sqlite3_close_error.phpt new file mode 100644 index 0000000..d242352 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_close_error.phpt @@ -0,0 +1,21 @@ +--TEST-- +SQLite3::close parameters +--CREDITS-- +Jachim Coudenys +# TestFest 2009 Belgium +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +echo 'Testing SQLite3 close with one parameter' . PHP_EOL; +$db->close('parameter'); + +echo "Done"; +?> +--EXPECTF-- +Testing SQLite3 close with one parameter + +Warning: SQLite3::close() expects exactly 0 parameters, 1 given in %s on line %d +Done diff --git a/ext/sqlite3/tests/sqlite3_close_with_params.phpt b/ext/sqlite3/tests/sqlite3_close_with_params.phpt new file mode 100644 index 0000000..98e0483 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_close_with_params.phpt @@ -0,0 +1,18 @@ +--TEST-- +SQLite3::close test with parameters +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +var_dump($db->close('invalid argument')); +echo "Done\n"; +?> +--EXPECTF-- +Warning: SQLite3::close() expects exactly 0 parameters, 1 given in %s on line %d +NULL +Done diff --git a/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt b/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt new file mode 100644 index 0000000..ebb59eb --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_enable_exceptions.phpt @@ -0,0 +1,36 @@ +--TEST-- +SQLite3::enableExceptions test +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +var_dump($db->enableExceptions(true)); +try{ + $db->query("SELECT * FROM non_existent_table"); +} catch(Exception $e) { + echo $e->getMessage().PHP_EOL; +} +var_dump($db->enableExceptions(false)); +$db->query("SELECT * FROM non_existent_table"); +var_dump($db->enableExceptions("wrong_type","wrong_type")); +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +no such table: non_existent_table +bool(true) + +Warning: SQLite3::query(): no such table: non_existent_table in %s on line %d + +Warning: SQLite3::enableExceptions() expects at most 1 parameter, 2 given in %s on line %d +NULL +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_exec_wrongparams.phpt b/ext/sqlite3/tests/sqlite3_exec_wrongparams.phpt new file mode 100644 index 0000000..c94b521 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_exec_wrongparams.phpt @@ -0,0 +1,16 @@ +--TEST-- +SQLite3::exec test, testing for wrong type parameters +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +$db->exec(array ('a','b','c'), 20090509); + +?> +--EXPECTF-- +Warning: SQLite3::exec() expects exactly 1 parameter, 2 given in %s on line %d diff --git a/ext/sqlite3/tests/sqlite3_lasterrorcode_with_params.phpt b/ext/sqlite3/tests/sqlite3_lasterrorcode_with_params.phpt new file mode 100644 index 0000000..243392b --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_lasterrorcode_with_params.phpt @@ -0,0 +1,18 @@ +--TEST-- +SQLite3::lastErrorCode test with parameters +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +var_dump($db->lastErrorCode('invalid argument')); +echo "Done\n"; +?> +--EXPECTF-- +Warning: SQLite3::lastErrorCode() expects exactly 0 parameters, 1 given in %s on line %d +NULL +Done diff --git a/ext/sqlite3/tests/sqlite3_lasterrormsg_with_params.phpt b/ext/sqlite3/tests/sqlite3_lasterrormsg_with_params.phpt new file mode 100644 index 0000000..c2fa35d --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_lasterrormsg_with_params.phpt @@ -0,0 +1,17 @@ +--TEST-- +SQLite3::lastErrorMsg test with parameters +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +var_dump($db->lastErrorMsg('invalid argument')); +echo "Done\n"; +?> +--EXPECTF-- +Warning: SQLite3::lastErrorMsg() expects exactly 0 parameters, 1 given in %s on line %d +NULL +Done diff --git a/ext/sqlite3/tests/sqlite3_loadextension_with_wrong_param.phpt b/ext/sqlite3/tests/sqlite3_loadextension_with_wrong_param.phpt new file mode 100644 index 0000000..9811f86 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_loadextension_with_wrong_param.phpt @@ -0,0 +1,18 @@ +--TEST-- +SQLite3::loadExtension test with wrong parameter type +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +var_dump($db->loadExtension(array())); +echo "Done\n"; +?> +--EXPECTF-- +Warning: SQLite3::loadExtension() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d +NULL +Done + diff --git a/ext/sqlite3/tests/sqlite3_open_empty_string.phpt b/ext/sqlite3/tests/sqlite3_open_empty_string.phpt new file mode 100644 index 0000000..86868ee --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_open_empty_string.phpt @@ -0,0 +1,19 @@ +--TEST-- +SQLite3::open test with empty string argument via the constructor +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +try{ + $db = new SQLite3(''); +} catch(Exception $e) { + echo $e->getMessage().PHP_EOL; +} +echo "Done\n"; +?> +--EXPECTF-- +Unable to expand filepath +Done diff --git a/ext/sqlite3/tests/sqlite3_openblob_wrongparams.phpt b/ext/sqlite3/tests/sqlite3_openblob_wrongparams.phpt new file mode 100644 index 0000000..439e397 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_openblob_wrongparams.phpt @@ -0,0 +1,79 @@ +--TEST-- +SQLite3::blobOpen test, testing stream with wrong parameter count +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +class SQLite3_Test_Stream +{ + private $position; + public static $string_length = 10; + public static $string = "abcdefg\0hi"; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $this->position = 0; + return true; + } + + public function stream_read($count) + { + $ret = substr(self::$string, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + public function stream_write($data) + { + return 0; + } + + public function stream_stat() + { + return array('size' => self::$string_length); + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return ($this->position >= self::$string_length); + } +} + +$db = new SQLite3(':memory:'); +stream_wrapper_register('sqliteBlobTest', "SQLite3_Test_Stream") or die("Unable to register sqliteBlobTest stream"); +echo "Creating table: " . var_export($db->exec('CREATE TABLE test (id STRING, data BLOB)'),true) . "\n"; + +echo "PREPARING insert\n"; +$insert_stmt = $db->prepare("INSERT INTO test (id, data) VALUES (?, ?)"); + +echo "BINDING Parameters:\n"; +var_dump($insert_stmt->bindValue(1, 'a', SQLITE3_TEXT)); +var_dump($insert_stmt->bindValue(2, 'TEST TEST', SQLITE3_BLOB)); +$insert_stmt->execute(); +echo "Closing statement: " . var_export($insert_stmt->close(), true) . "\n"; + +echo "Open BLOB with wrong parameter count\n"; +$stream = $db->openBlob(); +var_dump($stream); +echo "Done\n"; +?> +--EXPECTF-- +Creating table: true +PREPARING insert +BINDING Parameters: +bool(true) +bool(true) +Closing statement: true +Open BLOB with wrong parameter count + +Warning: SQLite3::openBlob() expects at least 3 parameters, 0 given in %s on line %d +NULL +Done diff --git a/ext/sqlite3/tests/sqlite3_prepare_001.phpt b/ext/sqlite3/tests/sqlite3_prepare_001.phpt new file mode 100644 index 0000000..f9e5fad --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_prepare_001.phpt @@ -0,0 +1,19 @@ +--TEST-- +SQLite3 - memory leak on SQLite3Result and SQLite3Stmt +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +function test(&$x) { + $class = new SQLite3(':memory:'); + $x = $class->prepare('SELECT 1'); +} + +test($foo); + +echo "done\n"; + +?> +--EXPECTF-- +done diff --git a/ext/sqlite3/tests/sqlite3_prepare_faultystmt.phpt b/ext/sqlite3/tests/sqlite3_prepare_faultystmt.phpt new file mode 100644 index 0000000..5cdf322 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_prepare_faultystmt.phpt @@ -0,0 +1,20 @@ +--TEST-- +SQLite3::prepare test, testing for faulty statement +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +$db->exec('CREATE TABLE foo (id INTEGER, bar STRING)'); +$db->exec("INSERT INTO foo (id, bar) VALUES (1, 'This is a test')"); + +$stmt = $db->prepare('SELECT foo FROM bar'); + +var_dump($stmt); +?> +--EXPECTF-- +Warning: SQLite3::prepare(): Unable to prepare statement: 1, no such table: bar in %s on line %d +bool(false) diff --git a/ext/sqlite3/tests/sqlite3_prepare_with_empty_string.phpt b/ext/sqlite3/tests/sqlite3_prepare_with_empty_string.phpt new file mode 100644 index 0000000..dea7d91 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_prepare_with_empty_string.phpt @@ -0,0 +1,16 @@ +--TEST-- +SQLite3::prepare test with empty string argument +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +var_dump($db->prepare('')); +echo "Done\n"; +?> +--EXPECTF-- +bool(false) +Done diff --git a/ext/sqlite3/tests/sqlite3_prepare_wrongparams.phpt b/ext/sqlite3/tests/sqlite3_prepare_wrongparams.phpt new file mode 100644 index 0000000..b7eb564 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_prepare_wrongparams.phpt @@ -0,0 +1,19 @@ +--TEST-- +SQLite3::prepare test, testing for wrong parameters +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +$db->exec('CREATE TABLE foo (id INTEGER, bar STRING)'); +$db->exec("INSERT INTO foo (id, bar) VALUES (1, 'This is a test')"); + +$stmt = $db->prepare(); + +?> +--EXPECTF-- +Warning: SQLite3::prepare() expects exactly 1 parameter, 0 given in %s on line %d diff --git a/ext/sqlite3/tests/sqlite3_prepared_stmt_clear_with_params.phpt b/ext/sqlite3/tests/sqlite3_prepared_stmt_clear_with_params.phpt new file mode 100644 index 0000000..d04fb66 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_prepared_stmt_clear_with_params.phpt @@ -0,0 +1,34 @@ +--TEST-- +SQLite3Stmt::clear test with parameters +--CREDITS-- +Thijs Feryn <thijs@feryn.eu> +#TestFest PHPBelgium 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +define('TIMENOW', time()); +echo "Creating Table\n"; +$db->exec('CREATE TABLE test (time INTEGER, id STRING)'); +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO test (time, id) VALUES (" . TIMENOW . ", 'b')")); + +echo "SELECTING results\n"; +$stmt = $db->prepare("SELECT * FROM test WHERE id = ? ORDER BY id ASC"); +var_dump($stmt->clear('invalid argument')); +echo "Closing database\n"; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +INSERT into table +bool(true) +SELECTING results + +Warning: SQLite3Stmt::clear() expects exactly 0 parameters, 1 given in %s on line %d +NULL +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3_query_error.phpt b/ext/sqlite3/tests/sqlite3_query_error.phpt new file mode 100644 index 0000000..ab7f700 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_query_error.phpt @@ -0,0 +1,32 @@ +--TEST-- +SQLite3::query parameters +--CREDITS-- +Jachim Coudenys +# TestFest 2009 Belgium +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +$db = new SQLite3(':memory:'); +echo 'Testing SQLite3 query without parameters' . PHP_EOL; +$db->query(); + +echo 'Testing SQLite3 query with one array parameter' . PHP_EOL; +$db->query(array()); + +echo 'Testing SQLite3 qeury with empty string parameter' . PHP_EOL; +var_dump($db->query('')); + +echo "Done"; +?> +--EXPECTF-- +Testing SQLite3 query without parameters + +Warning: SQLite3::query() expects exactly 1 parameter, 0 given in %s on line %d +Testing SQLite3 query with one array parameter + +Warning: SQLite3::query() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d +Testing SQLite3 qeury with empty string parameter +bool(false) +Done diff --git a/ext/sqlite3/tests/sqlite3_querysingle_error.phpt b/ext/sqlite3/tests/sqlite3_querysingle_error.phpt new file mode 100644 index 0000000..85889c7 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_querysingle_error.phpt @@ -0,0 +1,31 @@ +--TEST-- +SQLite3::query parameters +--CREDITS-- +Jachim Coudenys +# TestFest 2009 Belgium +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +echo 'Testing SQLite3 querySingle without parameters' . PHP_EOL; +$db->querySingle(); + +echo 'Testing SQLite3 querySingle with one array parameter' . PHP_EOL; +$db->querySingle(array()); + +echo 'Testing SQLite3 qeurySingle with empty string parameter' . PHP_EOL; +var_dump($db->querySingle('')); + +echo "Done"; +?> +--EXPECTF-- +Testing SQLite3 querySingle without parameters + +Warning: SQLite3::querySingle() expects at least 1 parameter, 0 given in %s on line %d +Testing SQLite3 querySingle with one array parameter + +Warning: SQLite3::querySingle() expects parameter 1 to be %binary_string_optional%, array given in %s on line %d +Testing SQLite3 qeurySingle with empty string parameter +bool(false) +Done diff --git a/ext/sqlite3/tests/sqlite3_version_noparam.phpt b/ext/sqlite3/tests/sqlite3_version_noparam.phpt new file mode 100644 index 0000000..19d6ec5 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3_version_noparam.phpt @@ -0,0 +1,16 @@ +--TEST-- +SQLite3::version test, testing for missing function parameters +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +var_dump(SQLite3::version('dummy')); + +?> +--EXPECTF-- +Warning: SQLite3::version() expects exactly 0 parameters, 1 given in %s on line %d +NULL diff --git a/ext/sqlite3/tests/sqlite3result_fetcharray_with_two_params_fails.phpt b/ext/sqlite3/tests/sqlite3result_fetcharray_with_two_params_fails.phpt new file mode 100644 index 0000000..cb49b75 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3result_fetcharray_with_two_params_fails.phpt @@ -0,0 +1,20 @@ +--TEST-- +SQLite3Result::fetchArray() test, testing two params causes a failure +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +$db->exec('CREATE TABLE foo (bar STRING)'); +$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')"); +$db->exec("INSERT INTO foo (bar) VALUES ('This is another test')"); + +$result = $db->query('SELECT bar FROM foo'); +var_dump($result->fetchArray(1,2)); +?> +--EXPECTF-- +Warning: SQLite3Result::fetchArray() expects at most 1 parameter, 2 given in %s on line %d +NULL diff --git a/ext/sqlite3/tests/sqlite3result_numcolumns_error.phpt b/ext/sqlite3/tests/sqlite3result_numcolumns_error.phpt new file mode 100644 index 0000000..5f8306c --- /dev/null +++ b/ext/sqlite3/tests/sqlite3result_numcolumns_error.phpt @@ -0,0 +1,33 @@ +--TEST-- +SQLite3Result::numColumns parameters +--CREDITS-- +Jachim Coudenys +# TestFest 2009 Belgium +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +echo 'Creating Table' . PHP_EOL; +var_dump($db->exec('CREATE TABLE test (time INTEGER, id STRING)')); + +echo 'Inserting data' . PHP_EOL; +var_dump($db->exec('INSERT INTO test (time, id) VALUES(2, 1)')); + +echo 'Fetching number of columns' . PHP_EOL; +$result = $db->query('SELECT id FROM test'); +var_dump($result->numColumns('time')); + +echo 'Done'; + +?> +--EXPECTF-- +Creating Table +bool(true) +Inserting data +bool(true) +Fetching number of columns + +Warning: SQLite3Result::numColumns() expects exactly 0 parameters, 1 given in %s on line %d +NULL +Done diff --git a/ext/sqlite3/tests/sqlite3result_reset_with_params_fails.phpt b/ext/sqlite3/tests/sqlite3result_reset_with_params_fails.phpt new file mode 100644 index 0000000..b397ac6 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3result_reset_with_params_fails.phpt @@ -0,0 +1,19 @@ +--TEST-- +SQLite3Result::reset test, testing an exception is raised when calling reset with parameters +--CREDITS-- +Michelangelo van Dam +# Belgian PHP Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +$db->exec('CREATE TABLE foo (bar STRING)'); +$db->exec("INSERT INTO foo (bar) VALUES ('This is a test')"); +$db->exec("INSERT INTO foo (bar) VALUES ('This is another test')"); + +$result = $db->query('SELECT bar FROM foo'); +$result->reset(1); +?> +--EXPECTF-- +Warning: SQLite3Result::reset() expects exactly 0 parameters, 1 given in %s on line %d diff --git a/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt b/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt new file mode 100644 index 0000000..a4b29e3 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3stmt_paramCount_basic.phpt @@ -0,0 +1,59 @@ +--TEST-- +SQLite3Stmt::paramCount basic test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE foobar (id INTEGER, name STRING, city STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO foobar (id, name, city) VALUES (1, 'john', 'LA')")); +var_dump($db->exec("INSERT INTO foobar (id, name, city) VALUES (2, 'doe', 'SF')")); + + +$queryArray = array( + "SELECT * FROM foobar WHERE id = ? ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = 2 ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = :id AND name = :name ORDER BY id ASC", + "SELECT * FROM foobar WHERE id = 1 AND name = :name ORDER BY id ASC", +); + +echo "SELECTING results\n"; + +foreach($queryArray as $key => $query) { + $stmt = $db->prepare($query); + + echo 'Param count for query ' . ($key + 1) . ":\n"; + var_dump($stmt->paramCount()); + + $result = $stmt->execute(); +} + +echo "Closing database\n"; +$stmt = null; +$result = null; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +Param count for query 1: +int(1) +Param count for query 2: +int(0) +Param count for query 3: +int(2) +Param count for query 4: +int(1) +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3stmt_paramCount_error.phpt b/ext/sqlite3/tests/sqlite3stmt_paramCount_error.phpt new file mode 100644 index 0000000..2aac6c2 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3stmt_paramCount_error.phpt @@ -0,0 +1,46 @@ +--TEST-- +SQLite3Stmt::paramCount error test +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php + +require_once(dirname(__FILE__) . '/new_db.inc'); + +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE foobar (id INTEGER, name STRING, city STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO foobar (id, name, city) VALUES (1, 'john', 'LA')")); +var_dump($db->exec("INSERT INTO foobar (id, name, city) VALUES (2, 'doe', 'SF')")); + + +$query = "SELECT * FROM foobar WHERE id = ? ORDER BY id ASC"; + +echo "SELECTING results\n"; + +$stmt = $db->prepare($query); + +echo "paramCount with wrong number of arguments\n"; +var_dump($stmt->paramCount('foobar')); +$result = $stmt->execute(); +echo "Closing database\n"; +$stmt = null; +$result = null; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +bool(true) +SELECTING results +paramCount with wrong number of arguments + +Warning: SQLite3Stmt::paramCount() expects exactly 0 parameters, 1 given in %s on line %d +NULL +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/sqlite3stmt_reset_params.phpt b/ext/sqlite3/tests/sqlite3stmt_reset_params.phpt new file mode 100644 index 0000000..b0dfc20 --- /dev/null +++ b/ext/sqlite3/tests/sqlite3stmt_reset_params.phpt @@ -0,0 +1,47 @@ +--TEST-- +SQLite3Stmt::reset with parameter test +--CREDITS-- +Jelle Lampaert +#Belgian Testfest 2009 +--SKIPIF-- +<?php require_once(dirname(__FILE__) . '/skipif.inc'); ?> +--FILE-- +<?php +$db = new SQLite3(':memory:'); +echo "Creating Table\n"; +var_dump($db->exec('CREATE TABLE foobar (id INTEGER, name STRING)')); + +echo "INSERT into table\n"; +var_dump($db->exec("INSERT INTO foobar (id, name) VALUES (1, 'john')")); + + +$query = "SELECT name FROM foobar WHERE id = 1"; + +echo "Prepare query\n"; +$stmt = $db->prepare($query); + +echo "Reset query\n"; +try { + $stmt->reset("foo"); +} catch (Exception $ex) { + var_dump($ex->getMessage()); +} + +echo "Closing database\n"; +$stmt = null; +$result = null; +var_dump($db->close()); +echo "Done\n"; +?> +--EXPECTF-- +Creating Table +bool(true) +INSERT into table +bool(true) +Prepare query +Reset query + +Warning: SQLite3Stmt::reset() expects exactly 0 parameters, %d given in %s on line %d +Closing database +bool(true) +Done diff --git a/ext/sqlite3/tests/stream_test.inc b/ext/sqlite3/tests/stream_test.inc new file mode 100644 index 0000000..13fd6f8 --- /dev/null +++ b/ext/sqlite3/tests/stream_test.inc @@ -0,0 +1,45 @@ +<?php + +class SQLite3_Test_Stream +{ + private $position; + public static $string_length = 10; + public static $string = "abcdefg\0hi"; + + public function stream_open($path, $mode, $options, &$opened_path) + { + $this->position = 0; + return true; + } + + public function stream_read($count) + { + $ret = substr(self::$string, $this->position, $count); + $this->position += strlen($ret); + return $ret; + } + + public function stream_write($data) + { + return 0; + } + + public function stream_stat() + { + return array('size' => self::$string_length); + } + + public function stream_tell() + { + return $this->position; + } + + public function stream_eof() + { + return ($this->position >= self::$string_length); + } +} + +stream_wrapper_register('sqliteBlobTest', "SQLite3_Test_Stream") or die("Unable to register sqliteBlobTest stream"); + +?> |