diff options
author | Marcus Boerger <helly@php.net> | 2005-02-19 19:52:41 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2005-02-19 19:52:41 +0000 |
commit | 89f1128cf49218b6a4e52b462e7c7bb63744ae40 (patch) | |
tree | facc151d958a2499b618d566ab7b3b6707265bc3 /ext/pdo_sqlite | |
parent | 539b81e03a1b7bdc0ac874aef36128e83d1c6776 (diff) | |
download | php-git-89f1128cf49218b6a4e52b462e7c7bb63744ae40.tar.gz |
- Add first tests
Diffstat (limited to 'ext/pdo_sqlite')
-rwxr-xr-x | ext/pdo_sqlite/tests/pdo_sqlite_001.phpt | 53 | ||||
-rwxr-xr-x | ext/pdo_sqlite/tests/pdo_sqlite_002.phpt | 53 | ||||
-rwxr-xr-x | ext/pdo_sqlite/tests/pdo_sqlite_003.phpt | 69 |
3 files changed, 175 insertions, 0 deletions
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt new file mode 100755 index 0000000000..0a3dfbf089 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt @@ -0,0 +1,53 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_ASSOC +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded("pdo_sqlite")) print "skip"; ?> +--FILE-- +<?php + +$db =new pdo('sqlite::memory:'); + +$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, "A")'); +$db->exec('INSERT INTO test VALUES(2, "B")'); +$db->exec('INSERT INTO test VALUES(3, "C")'); + +$stmt = $db->query('SELECT * FROM test'); + +var_dump($stmt->fetchAll(PDO_FETCH_ASSOC)); +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +array(4) { + [0]=> + array(2) { + ["id"]=> + string(1) "1" + ["val"]=> + string(1) "A" + } + [1]=> + array(2) { + ["id"]=> + string(1) "2" + ["val"]=> + string(1) "B" + } + [2]=> + array(2) { + ["id"]=> + string(1) "3" + ["val"]=> + string(1) "C" + } + [3]=> + array(2) { + ["id"]=> + string(1) "4" + ["val"]=> + string(1) "D" + } +} +===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt new file mode 100755 index 0000000000..187085a9f6 --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt @@ -0,0 +1,53 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_NUM +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded("pdo_sqlite")) print "skip"; ?> +--FILE-- +<?php + +$db =new pdo('sqlite::memory:'); + +$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, "A")'); +$db->exec('INSERT INTO test VALUES(2, "B")'); +$db->exec('INSERT INTO test VALUES(3, "C")'); + +$stmt = $db->query('SELECT * FROM test'); + +var_dump($stmt->fetchAll(PDO_FETCH_NUM)); +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "A" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(1) "B" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(1) "C" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(1) "D" + } +} +===DONE=== diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt new file mode 100755 index 0000000000..82d9b37e1a --- /dev/null +++ b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt @@ -0,0 +1,69 @@ +--TEST-- +PDO-SQLite: PDO_FETCH_BOTH +--SKIPIF-- +<?php # vim:ft=php +if (!extension_loaded("pdo_sqlite")) print "skip"; ?> +--FILE-- +<?php + +$db =new pdo('sqlite::memory:'); + +$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10))'); +$db->exec('INSERT INTO test VALUES(1, "A")'); +$db->exec('INSERT INTO test VALUES(2, "B")'); +$db->exec('INSERT INTO test VALUES(3, "C")'); + +$stmt = $db->query('SELECT * FROM test'); + +var_dump($stmt->fetchAll(PDO_FETCH_BOTH)); +?> +===DONE=== +<?php exit(0); ?> +--EXPECT-- +array(4) { + [0]=> + array(4) { + ["id"]=> + string(1) "1" + [0]=> + string(1) "1" + ["val"]=> + string(1) "A" + [1]=> + string(1) "A" + } + [1]=> + array(4) { + ["id"]=> + string(1) "2" + [0]=> + string(1) "2" + ["val"]=> + string(1) "B" + [1]=> + string(1) "B" + } + [2]=> + array(4) { + ["id"]=> + string(1) "3" + [0]=> + string(1) "3" + ["val"]=> + string(1) "C" + [1]=> + string(1) "C" + } + [3]=> + array(4) { + ["id"]=> + string(1) "4" + [0]=> + string(1) "4" + ["val"]=> + string(1) "D" + [1]=> + string(1) "D" + } +} +===DONE=== |