diff options
author | Felix De Vliegher <felixdv@php.net> | 2008-10-29 11:43:33 +0000 |
---|---|---|
committer | Felix De Vliegher <felixdv@php.net> | 2008-10-29 11:43:33 +0000 |
commit | ac24f7ecfef0097e038b60f764d7938caaf48ccf (patch) | |
tree | 1eadefe6d80378b08b4c337f6a63bede16191bc5 /ext/sqlite/tests/sqlite_last_error_basic.phpt | |
parent | 436018a0b7fad24e4f03097771c5f38b4d4f8ba5 (diff) | |
download | php-git-ac24f7ecfef0097e038b60f764d7938caaf48ccf.tar.gz |
Various tests for the sqlite ext.
The sqlite session tests are by Mats Lindh <mats at lindh.no>.
Diffstat (limited to 'ext/sqlite/tests/sqlite_last_error_basic.phpt')
-rw-r--r-- | ext/sqlite/tests/sqlite_last_error_basic.phpt | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/ext/sqlite/tests/sqlite_last_error_basic.phpt b/ext/sqlite/tests/sqlite_last_error_basic.phpt new file mode 100644 index 0000000000..f3a7b8320e --- /dev/null +++ b/ext/sqlite/tests/sqlite_last_error_basic.phpt @@ -0,0 +1,48 @@ +--TEST-- +Test sqlite_last_error() function : basic functionality +--SKIPIF-- +<?php if (!extension_loaded("sqlite")) print "skip sqlite extension not loaded"; ?> +--FILE-- +<?php +/* Prototype : int sqlite_last_error(resource db) + * Description: Returns the error code of the last error for a database. + * Source code: ext/sqlite/sqlite.c + * Alias to functions: + */ + +echo "*** Testing sqlite_last_error() : basic functionality ***\n"; + +// set up variables +$query = 'CREATE TAB LE foobar (id INTEGER PRIMARY KEY, name CHAR(255));'; +$query_ok = 'CREATE TABLE foobar (id INTEGER, name CHAR(255));'; + +// procedural +$db = sqlite_open(':memory:'); +var_dump( sqlite_last_error($db) === SQLITE_OK ); +sqlite_exec($db, $query); +var_dump( sqlite_last_error($db) === SQLITE_ERROR ); +sqlite_exec($db, $query_ok); +var_dump( sqlite_last_error($db) === SQLITE_OK ); +sqlite_close($db); + +// oo-style +$db = new SQLiteDatabase(':memory:'); +$db->queryExec($query); +var_dump( $db->lastError() === SQLITE_ERROR ); +$db->queryExec($query_ok); +var_dump( $db->lastError() === SQLITE_OK ); + +?> +===DONE=== +--EXPECTF-- +*** Testing sqlite_last_error() : basic functionality *** +bool(true) + +Warning: sqlite_exec(): near "TAB": syntax error in %s on line %d +bool(true) +bool(true) + +Warning: SQLiteDatabase::queryExec(): near "TAB": syntax error in %s on line %d +bool(true) +bool(true) +===DONE=== |