mirror of
https://github.com/php/php-src.git
synced 2025-01-27 14:13:41 +08:00
- New tests (testfest BelgiumUG)
This commit is contained in:
parent
24c8b4fb78
commit
23ee8e9013
19
ext/sqlite3/tests/sqlite3_02_open.phpt
Normal file
19
ext/sqlite3/tests/sqlite3_02_open.phpt
Normal file
@ -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"
|
20
ext/sqlite3/tests/sqlite3_31_changes.phpt
Normal file
20
ext/sqlite3/tests/sqlite3_31_changes.phpt
Normal file
@ -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
|
||||
|
20
ext/sqlite3/tests/sqlite3_31_open.phpt
Normal file
20
ext/sqlite3/tests/sqlite3_31_open.phpt
Normal file
@ -0,0 +1,20 @@
|
||||
--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('db1.db');
|
||||
$db->open('db1.db');
|
||||
} catch (Exception $ex) {
|
||||
var_dump($ex->getMessage());
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
%string|unicode%(29) "Already initialised DB Object"
|
17
ext/sqlite3/tests/sqlite3_32_changes.phpt
Normal file
17
ext/sqlite3/tests/sqlite3_32_changes.phpt
Normal file
@ -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
|
21
ext/sqlite3/tests/sqlite3_32_createAggregate_paramCount.phpt
Normal file
21
ext/sqlite3/tests/sqlite3_32_createAggregate_paramCount.phpt
Normal file
@ -0,0 +1,21 @@
|
||||
--TEST--
|
||||
SQLite3::createAggregate Test that an error is thrown when no parameters are present
|
||||
--CREDIT--
|
||||
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
|
40
ext/sqlite3/tests/sqlite3_32_last_insert_rowid_param.phpt
Normal file
40
ext/sqlite3/tests/sqlite3_32_last_insert_rowid_param.phpt
Normal file
@ -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
|
@ -0,0 +1,29 @@
|
||||
--TEST--
|
||||
SQLite3::createAggregate() Test whether a supplied PHP function is valid when using in an aggregate function
|
||||
--CREDIT--
|
||||
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
|
23
ext/sqlite3/tests/sqlite3_33_load_extension_param.phpt
Normal file
23
ext/sqlite3/tests/sqlite3_33_load_extension_param.phpt
Normal file
@ -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
|
27
ext/sqlite3/tests/sqlite3_33_reset.phpt
Normal file
27
ext/sqlite3/tests/sqlite3_33_reset.phpt
Normal file
@ -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
|
21
ext/sqlite3/tests/sqlite3_34_load_extension_ext_dir.phpt
Normal file
21
ext/sqlite3/tests/sqlite3_34_load_extension_ext_dir.phpt
Normal file
@ -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
|
21
ext/sqlite3/tests/sqlite3_close_error.phpt
Normal file
21
ext/sqlite3/tests/sqlite3_close_error.phpt
Normal file
@ -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
|
18
ext/sqlite3/tests/sqlite3_close_with_params.phpt
Normal file
18
ext/sqlite3/tests/sqlite3_close_with_params.phpt
Normal file
@ -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
|
36
ext/sqlite3/tests/sqlite3_enable_exceptions.phpt
Normal file
36
ext/sqlite3/tests/sqlite3_enable_exceptions.phpt
Normal file
@ -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--
|
||||
NULL
|
||||
no such table: non_existent_table
|
||||
NULL
|
||||
|
||||
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
|
16
ext/sqlite3/tests/sqlite3_exec_wrongparams.phpt
Normal file
16
ext/sqlite3/tests/sqlite3_exec_wrongparams.phpt
Normal file
@ -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
|
18
ext/sqlite3/tests/sqlite3_lasterrorcode_with_params.phpt
Normal file
18
ext/sqlite3/tests/sqlite3_lasterrorcode_with_params.phpt
Normal file
@ -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
|
17
ext/sqlite3/tests/sqlite3_lasterrormsg_with_params.phpt
Normal file
17
ext/sqlite3/tests/sqlite3_lasterrormsg_with_params.phpt
Normal file
@ -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
|
@ -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
|
||||
|
17
ext/sqlite3/tests/sqlite3_open_empty_string.phpt
Normal file
17
ext/sqlite3/tests/sqlite3_open_empty_string.phpt
Normal file
@ -0,0 +1,17 @@
|
||||
--TEST--
|
||||
SQLite3::open test with empty string argument via the constructor
|
||||
--CREDITS--
|
||||
Thijs Feryn <thijs@feryn.eu>
|
||||
#TestFest PHPBelgium 2009
|
||||
--FILE--
|
||||
<?php
|
||||
try{
|
||||
$db = new SQLite3('');
|
||||
} catch(Exception $e) {
|
||||
echo $e->getMessage().PHP_EOL;
|
||||
}
|
||||
echo "Done\n";
|
||||
?>
|
||||
--EXPECTF--
|
||||
Unable to expand filepath
|
||||
Done
|
79
ext/sqlite3/tests/sqlite3_openblob_wrongparams.phpt
Normal file
79
ext/sqlite3/tests/sqlite3_openblob_wrongparams.phpt
Normal file
@ -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
|
20
ext/sqlite3/tests/sqlite3_prepare_faultystmt.phpt
Normal file
20
ext/sqlite3/tests/sqlite3_prepare_faultystmt.phpt
Normal file
@ -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)
|
16
ext/sqlite3/tests/sqlite3_prepare_with_empty_string.phpt
Normal file
16
ext/sqlite3/tests/sqlite3_prepare_with_empty_string.phpt
Normal file
@ -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
|
19
ext/sqlite3/tests/sqlite3_prepare_wrongparams.phpt
Normal file
19
ext/sqlite3/tests/sqlite3_prepare_wrongparams.phpt
Normal file
@ -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
|
@ -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
|
32
ext/sqlite3/tests/sqlite3_query_error.phpt
Normal file
32
ext/sqlite3/tests/sqlite3_query_error.phpt
Normal file
@ -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
|
31
ext/sqlite3/tests/sqlite3_querysingle_error.phpt
Normal file
31
ext/sqlite3/tests/sqlite3_querysingle_error.phpt
Normal file
@ -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
|
16
ext/sqlite3/tests/sqlite3_version_noparam.phpt
Normal file
16
ext/sqlite3/tests/sqlite3_version_noparam.phpt
Normal file
@ -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
|
@ -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
|
33
ext/sqlite3/tests/sqlite3result_numcolumns_error.phpt
Normal file
33
ext/sqlite3/tests/sqlite3result_numcolumns_error.phpt
Normal file
@ -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
|
19
ext/sqlite3/tests/sqlite3result_reset_with_params_fails.phpt
Normal file
19
ext/sqlite3/tests/sqlite3result_reset_with_params_fails.phpt
Normal file
@ -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
|
47
ext/sqlite3/tests/sqlite3stmt_reset_params.phpt
Normal file
47
ext/sqlite3/tests/sqlite3stmt_reset_params.phpt
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user