summaryrefslogtreecommitdiff
path: root/ext/pdo_sqlite/tests
diff options
context:
space:
mode:
authorMarcus Boerger <helly@php.net>2005-02-20 17:56:19 +0000
committerMarcus Boerger <helly@php.net>2005-02-20 17:56:19 +0000
commit94c286f2efb3f82bdd13ddd071a3f9adbd372a40 (patch)
treee507c1c1c6839371d0cd0061406cbcfbaf7f788a /ext/pdo_sqlite/tests
parent26677dd2a225384dc177a9d98db8a0422a50ee9c (diff)
downloadphp-git-94c286f2efb3f82bdd13ddd071a3f9adbd372a40.tar.gz
- Attempt at an unified test suite
Diffstat (limited to 'ext/pdo_sqlite/tests')
-rwxr-xr-xext/pdo_sqlite/tests/connection.inc7
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_001.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_002.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_003.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_004.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_005.phpt31
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_006.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_007.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_008.phpt13
-rwxr-xr-xext/pdo_sqlite/tests/pdo_sqlite_009.phpt42
-rwxr-xr-xext/pdo_sqlite/tests/prepare.inc9
-rwxr-xr-xext/pdo_sqlite/tests/skipif.inc5
12 files changed, 57 insertions, 128 deletions
diff --git a/ext/pdo_sqlite/tests/connection.inc b/ext/pdo_sqlite/tests/connection.inc
new file mode 100755
index 0000000000..278a2652bd
--- /dev/null
+++ b/ext/pdo_sqlite/tests/connection.inc
@@ -0,0 +1,7 @@
+<?php
+
+$CONNECTION = 'sqlite::memory:';
+
+$PDO_TESTS = dirname(__FILE__) . '/../../pdo/tests/';
+
+?> \ No newline at end of file
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt
index 86c9ce8636..1228d23ad3 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_001.phpt
@@ -2,20 +2,15 @@
PDO-SQLite: PDO_FETCH_ASSOC
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$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")');
+require_once($PDO_TESTS . 'pdo_001.inc');
-$stmt = $db->query('SELECT * FROM test');
-
-var_dump($stmt->fetchAll(PDO_FETCH_ASSOC));
?>
===DONE===
<?php exit(0); ?>
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt
index 227f738df7..3d1265efa6 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_002.phpt
@@ -2,20 +2,15 @@
PDO-SQLite: PDO_FETCH_NUM
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$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")');
+require_once($PDO_TESTS . 'pdo_002.inc');
-$stmt = $db->query('SELECT * FROM test');
-
-var_dump($stmt->fetchAll(PDO_FETCH_NUM));
?>
===DONE===
<?php exit(0); ?>
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt
index e7cffae940..3e393358a5 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_003.phpt
@@ -2,20 +2,15 @@
PDO-SQLite: PDO_FETCH_BOTH
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$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")');
+require_once($PDO_TESTS . 'pdo_003.inc');
-$stmt = $db->query('SELECT * FROM test');
-
-var_dump($stmt->fetchAll(PDO_FETCH_BOTH));
?>
===DONE===
<?php exit(0); ?>
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt
index 2e6e93d920..9ab0ee1482 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_004.phpt
@@ -2,20 +2,15 @@
PDO-SQLite: PDO_FETCH_OBJ
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$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")');
+require_once($PDO_TESTS . 'pdo_004.inc');
-$stmt = $db->query('SELECT * FROM test');
-
-var_dump($stmt->fetchAll(PDO_FETCH_OBJ));
?>
===DONE===
<?php exit(0); ?>
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt
index a28c77a218..13593bb5c6 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_005.phpt
@@ -2,38 +2,15 @@
PDO-SQLite: PDO_FETCH_CLASS
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$db->exec('CREATE TABLE test(id int PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(10))');
-$db->exec('INSERT INTO test VALUES(1, "A", "AA")');
-$db->exec('INSERT INTO test VALUES(2, "B", "BB")');
-$db->exec('INSERT INTO test VALUES(3, "C", "CC")');
+require_once($PDO_TESTS . 'pdo_005.inc');
-class TestBase
-{
- public $id;
- protected $val;
- private $val2;
-}
-
-class TestDerived extends TestBase
-{
- protected $row;
-
- public function __construct(&$row)
- {
- echo __METHOD__ . "($row,{$this->id})\n";
- $this->row = $row++;
- }
-}
-
-var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS));
-var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestBase'));
-var_dump($db->query('SELECT * FROM test')->fetchAll(PDO_FETCH_CLASS, 'TestDerived', array(0)));
?>
===DONE===
<?php exit(0); ?>
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_006.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_006.phpt
index 8a4084b424..08403b12a2 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_006.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_006.phpt
@@ -2,19 +2,14 @@
PDO-SQLite: PDO_FETCH_GROUP
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$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, "A")');
-$db->exec('INSERT INTO test VALUES(3, "C")');
-
-var_dump($db->query('SELECT val, id FROM test')->fetchAll(PDO_FETCH_NUM|PDO_FETCH_GROUP));
-var_dump($db->query('SELECT val, id FROM test')->fetchAll(PDO_FETCH_ASSOC|PDO_FETCH_GROUP));
+require_once($PDO_TESTS . 'pdo_006.inc');
?>
===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_007.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_007.phpt
index 66604b3b09..abd0d1d169 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_007.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_007.phpt
@@ -2,19 +2,14 @@
PDO-SQLite: PDO_FETCH_UNIQUE
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$db->exec('CREATE TABLE test(id CHAR(1) PRIMARY KEY, val VARCHAR(10))');
-$db->exec('INSERT INTO test VALUES("A", "A")');
-$db->exec('INSERT INTO test VALUES("B", "A")');
-$db->exec('INSERT INTO test VALUES("C", "C")');
-
-var_dump($db->query('SELECT id, val FROM test')->fetchAll(PDO_FETCH_NUM|PDO_FETCH_UNIQUE));
-var_dump($db->query('SELECT id, val FROM test')->fetchAll(PDO_FETCH_ASSOC|PDO_FETCH_UNIQUE));
+require_once($PDO_TESTS . 'pdo_007.inc');
?>
===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_008.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_008.phpt
index 03eb014d81..fc9427d3d0 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_008.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_008.phpt
@@ -2,19 +2,14 @@
PDO-SQLite: PDO_FETCH_UNIQUE conflict
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$db->exec('CREATE TABLE test(id CHAR(1) PRIMARY KEY, val VARCHAR(10))');
-$db->exec('INSERT INTO test VALUES("A", "A")');
-$db->exec('INSERT INTO test VALUES("B", "A")');
-$db->exec('INSERT INTO test VALUES("C", "C")');
-
-var_dump($db->query('SELECT val, id FROM test')->fetchAll(PDO_FETCH_NUM|PDO_FETCH_UNIQUE));
-// check that repeated first columns overwrite existing array elements
+require_once($PDO_TESTS . 'pdo_008.inc');
?>
===DONE===
diff --git a/ext/pdo_sqlite/tests/pdo_sqlite_009.phpt b/ext/pdo_sqlite/tests/pdo_sqlite_009.phpt
index cfc975c47e..b1a0e1193b 100755
--- a/ext/pdo_sqlite/tests/pdo_sqlite_009.phpt
+++ b/ext/pdo_sqlite/tests/pdo_sqlite_009.phpt
@@ -2,49 +2,15 @@
PDO-SQLite: PDO_FETCH_CLASSTYPE
--SKIPIF--
<?php # vim:ft=php
-if (!extension_loaded("pdo_sqlite")) print "skip"; ?>
+require_once('skipif.inc'); ?>
--FILE--
<?php
-$db =new pdo('sqlite::memory:');
+require_once('connection.inc');
+require_once('prepare.inc');
-$db->exec('CREATE TABLE classtypes(id int PRIMARY KEY, name VARCHAR(10) UNIQUE)');
-$db->exec('INSERT INTO classtypes VALUES(0, "stdClass")');
-$db->exec('INSERT INTO classtypes VALUES(1, "Test1")');
-$db->exec('INSERT INTO classtypes VALUES(2, "Test2")');
-$db->exec('CREATE TABLE test(id int PRIMARY KEY, classtype int, val VARCHAR(10))');
-$db->exec('INSERT INTO test VALUES(1, 0, "A")');
-$db->exec('INSERT INTO test VALUES(2, 1, "B")');
-$db->exec('INSERT INTO test VALUES(3, 2, "C")');
-$db->exec('INSERT INTO test VALUES(4, 3, "D")');
+require_once($PDO_TESTS . 'pdo_009.inc');
-class Test1
-{
- public function __construct()
- {
- echo __METHOD__ . "()\n";
- }
-}
-
-class Test2
-{
- public function __construct()
- {
- echo __METHOD__ . "()\n";
- }
-}
-
-class Test3
-{
- public function __construct()
- {
- echo __METHOD__ . "()\n";
- }
-}
-
-$sql = 'SELECT classtypes.name, test.id AS id, test.val AS val FROM test LEFT JOIN classtypes ON test.classtype=classtypes.id';
-var_dump($db->query($sql)->fetchAll(PDO_FETCH_NUM));
-var_dump($db->query($sql)->fetchAll(PDO_FETCH_CLASS|PDO_FETCH_CLASSTYPE, 'Test3'));
?>
===DONE===
<?php exit(0); ?>
diff --git a/ext/pdo_sqlite/tests/prepare.inc b/ext/pdo_sqlite/tests/prepare.inc
new file mode 100755
index 0000000000..46ef5b845a
--- /dev/null
+++ b/ext/pdo_sqlite/tests/prepare.inc
@@ -0,0 +1,9 @@
+<?php
+
+require_once('connection.inc');
+
+$SQL = array();
+
+$DB = new pdo($CONNECTION);
+
+?> \ No newline at end of file
diff --git a/ext/pdo_sqlite/tests/skipif.inc b/ext/pdo_sqlite/tests/skipif.inc
new file mode 100755
index 0000000000..fc80707efe
--- /dev/null
+++ b/ext/pdo_sqlite/tests/skipif.inc
@@ -0,0 +1,5 @@
+<?php
+
+if (!extension_loaded("pdo_sqlite")) print "skip";
+
+?> \ No newline at end of file