summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Scott <dbs@php.net>2005-06-15 00:17:18 +0000
committerDan Scott <dbs@php.net>2005-06-15 00:17:18 +0000
commit4187a6e3c73fee0b266ba7bb7780de9cd458eef3 (patch)
treefaf4ee5c12775518dad95459ef385a74f1e7dd42
parent289997715ac763ead51648421f563fbcc22ebbb2 (diff)
downloadphp-git-4187a6e3c73fee0b266ba7bb7780de9cd458eef3.tar.gz
Bring PDO_ODBC tests in sync with PDO base tests.
-rwxr-xr-xext/pdo_odbc/tests/connection.inc2
-rwxr-xr-xext/pdo_odbc/tests/pdo_016.phpt119
-rwxr-xr-xext/pdo_odbc/tests/pdo_018.phpt142
-rwxr-xr-xext/pdo_odbc/tests/pdo_019.phpt54
-rwxr-xr-xext/pdo_odbc/tests/pdo_023.phpt60
-rwxr-xr-xext/pdo_odbc/tests/pdo_024.phpt25
-rwxr-xr-xext/pdo_odbc/tests/pdo_025.phpt70
-rwxr-xr-xext/pdo_odbc/tests/pdo_026.phpt50
-rwxr-xr-xext/pdo_odbc/tests/prepare.inc3
9 files changed, 523 insertions, 2 deletions
diff --git a/ext/pdo_odbc/tests/connection.inc b/ext/pdo_odbc/tests/connection.inc
index 0d5ff88843..2c1fb0a9bb 100755
--- a/ext/pdo_odbc/tests/connection.inc
+++ b/ext/pdo_odbc/tests/connection.inc
@@ -4,7 +4,7 @@ $USER = 'db2inst1';
$PASSWD = 'ibmdb2';
$DBNAME = 'SAMPLE';
-$CONNECTION = "odbc:$DBNAME";
+$CONNECTION = "odbc:DSN=$DBNAME;UID=$USER;PWD=$PASSWD;";
$PDO_TESTS = dirname(__FILE__) . '/../../pdo/tests/';
diff --git a/ext/pdo_odbc/tests/pdo_016.phpt b/ext/pdo_odbc/tests/pdo_016.phpt
new file mode 100755
index 0000000000..bf3751d961
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_016.phpt
@@ -0,0 +1,119 @@
+--TEST--
+PDO_ODBC: PDO_FETCH_BOUND
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+$DB->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER);
+
+require_once($PDO_TESTS . 'pdo_016.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===INIT===
+int(1)
+int(1)
+int(1)
+string(1) "3"
+array(3) {
+ [0]=>
+ string(7) "String0"
+ [1]=>
+ string(7) "String1"
+ [2]=>
+ string(7) "String2"
+}
+===WHILE===
+array(1) {
+ [0]=>
+ string(7) "String0"
+}
+array(1) {
+ [1]=>
+ string(7) "String1"
+}
+array(1) {
+ [2]=>
+ string(7) "String2"
+}
+===ALONE===
+array(1) {
+ [0]=>
+ string(7) "String0"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+ [0]=>
+ string(7) "String0"
+}
+array(1) {
+ [1]=>
+ string(7) "String1"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+ [1]=>
+ string(7) "String1"
+}
+array(1) {
+ [2]=>
+ string(7) "String2"
+}
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+array(1) {
+ [2]=>
+ string(7) "String2"
+}
+===REBIND/SAME===
+array(1) {
+ [0]=>
+ string(7) "String0"
+}
+bool(true)
+bool(true)
+string(7) "String0"
+bool(true)
+bool(true)
+string(1) "0"
+array(1) {
+ [1]=>
+ string(7) "String1"
+}
+bool(true)
+bool(true)
+string(7) "String1"
+bool(true)
+bool(true)
+string(1) "1"
+array(1) {
+ [2]=>
+ string(7) "String2"
+}
+bool(true)
+bool(true)
+string(7) "String2"
+bool(true)
+bool(true)
+string(1) "2"
+===REBIND/CONFLICT===
+string(7) "String0"
+string(7) "String1"
+string(7) "String2"
+===DONE===
diff --git a/ext/pdo_odbc/tests/pdo_018.phpt b/ext/pdo_odbc/tests/pdo_018.phpt
new file mode 100755
index 0000000000..61aea38b61
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_018.phpt
@@ -0,0 +1,142 @@
+--TEST--
+PDO_ODBC: PDO Unserializing
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc');
+if (!interface_exists('Serializable')) die ('skip Interface Serializable does not exist');
+?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+$SQL = array(
+ 'create1'=>'CREATE TABLE classtypes(id INT NOT NULL PRIMARY KEY, name VARCHAR(20) NOT NULL UNIQUE)',
+);
+
+$DB->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER);
+
+require_once($PDO_TESTS . 'pdo_018.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===INIT===
+int(1)
+int(1)
+int(1)
+string(1) "3"
+array(3) {
+ [0]=>
+ string(8) "stdClass"
+ [1]=>
+ string(8) "TestBase"
+ [2]=>
+ string(11) "TestDerived"
+}
+===TYPES===
+array(4) {
+ ["stdClass"]=>
+ string(1) "0"
+ ["TestBase"]=>
+ string(1) "1"
+ ["TestDerived"]=>
+ string(1) "2"
+ ["TestLeaf"]=>
+ NULL
+}
+===INSERT===
+TestBase::serialize() = 'a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}'
+TestDerived::serialize()
+TestBase::serialize() = 'a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}'
+TestDerived::serialize()
+TestBase::serialize() = 'a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}'
+===DATA===
+array(4) {
+ [0]=>
+ NULL
+ [1]=>
+ string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
+ [2]=>
+ string(144) "a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
+ [3]=>
+ string(144) "a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
+}
+===FAILURE===
+Exception:SQLSTATE[HY000]: General error: cannot unserialize class
+===COUNT===
+string(1) "3"
+===DATABASE===
+array(3) {
+ [0]=>
+ array(2) {
+ ["NAME"]=>
+ string(8) "TestBase"
+ ["VAL"]=>
+ string(91) "a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";}"
+ }
+ [1]=>
+ array(2) {
+ ["NAME"]=>
+ string(11) "TestDerived"
+ ["VAL"]=>
+ string(144) "a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
+ }
+ [2]=>
+ array(2) {
+ ["NAME"]=>
+ NULL
+ ["VAL"]=>
+ string(144) "a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";}"
+ }
+}
+===FETCHCLASS===
+TestBase::unserialize[22](a:3:{s:7:"BasePub";s:6:"Public";s:7:"BasePro";s:9:"Protected";s:7:"BasePri";s:7:"Private";})
+TestDerived::unserialize()
+TestBase::unserialize[22](a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";})
+TestDerived::unserialize()
+TestBase::unserialize[22](a:4:{s:7:"BasePub";s:13:"DerivedPublic";s:7:"BasePro";s:16:"DerivdeProtected";s:10:"DerivedPub";s:6:"Public";s:10:"DerivedPro";s:9:"Protected";})
+array(3) {
+ [0]=>
+ object(TestBase)#%d (3) {
+ ["BasePub"]=>
+ string(7) "#Public"
+ ["BasePro:protected"]=>
+ string(10) "#Protected"
+ ["BasePri:private"]=>
+ string(8) "#Private"
+ }
+ [1]=>
+ object(TestDerived)#%d (6) {
+ ["BasePub"]=>
+ string(14) "#DerivedPublic"
+ ["BasePro:protected"]=>
+ string(17) "#DerivdeProtected"
+ ["DerivedPub"]=>
+ string(7) "#Public"
+ ["DerivedPro:protected"]=>
+ string(10) "#Protected"
+ ["DerivedPri:private"]=>
+ string(7) "Private"
+ ["BasePri:private"]=>
+ string(7) "Private"
+ }
+ [2]=>
+ object(TestLeaf)#%d (6) {
+ ["BasePub"]=>
+ string(14) "#DerivedPublic"
+ ["BasePro:protected"]=>
+ string(17) "#DerivdeProtected"
+ ["DerivedPub"]=>
+ string(7) "#Public"
+ ["DerivedPro:protected"]=>
+ string(10) "#Protected"
+ ["DerivedPri:private"]=>
+ string(7) "Private"
+ ["BasePri:private"]=>
+ string(7) "Private"
+ }
+}
+===DONE===
diff --git a/ext/pdo_odbc/tests/pdo_019.phpt b/ext/pdo_odbc/tests/pdo_019.phpt
new file mode 100755
index 0000000000..b35656c7a8
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_019.phpt
@@ -0,0 +1,54 @@
+--TEST--
+PDO_ODBC: fetch() and while()
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc');
+?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+$DB->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER);
+
+require_once($PDO_TESTS . 'pdo_019.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+===INIT===
+int(1)
+int(1)
+int(1)
+int(1)
+string(1) "4"
+array(4) {
+ [0]=>
+ string(7) "String0"
+ [1]=>
+ string(7) "String1"
+ [2]=>
+ string(7) "String2"
+ [3]=>
+ string(7) "String3"
+}
+===WHILE===
+array(1) {
+ [0]=>
+ string(7) "String0"
+}
+array(1) {
+ [1]=>
+ string(7) "String1"
+}
+array(1) {
+ [2]=>
+ string(7) "String2"
+}
+array(1) {
+ [3]=>
+ string(7) "String3"
+}
+===DONE===
diff --git a/ext/pdo_odbc/tests/pdo_023.phpt b/ext/pdo_odbc/tests/pdo_023.phpt
new file mode 100755
index 0000000000..6c6f366620
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_023.phpt
@@ -0,0 +1,60 @@
+--TEST--
+PDO_ODBC: Overloading
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_023_def.inc');
+
+$DB = NULL;
+
+$DB = new PDODatabaseX($CONNECTION, $USER, $PASSWD);
+$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING);
+
+require_once($PDO_TESTS . 'pdo_023.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+int(1)
+int(2)
+object(PDODatabaseX)#%d (2) {
+ ["test1"]=>
+ int(1)
+ ["test2"]=>
+ int(22)
+}
+PDODatabaseX::query()
+PDOStatementX::__construct()
+PDOStatementX::__destruct()
+PDODatabaseX::query()
+PDOStatementX::__construct()
+PDOStatementX::__destruct()
+PDODatabaseX::query()
+PDOStatementX::__construct()
+PDOStatementX::__destruct()
+PDODatabaseX::query()
+PDOStatementX::__construct()
+object(PDOStatementX)#%d (3) {
+ ["test1"]=>
+ int(1)
+ ["queryString"]=>
+ string(24) "SELECT val, id FROM test"
+ ["test2"]=>
+ int(22)
+}
+array(2) {
+ ["A"]=>
+ string(1) "0"
+ ["B"]=>
+ string(1) "1"
+}
+PDOStatementX::__destruct()
+PDODatabaseX::__destruct()
+===DONE===
diff --git a/ext/pdo_odbc/tests/pdo_024.phpt b/ext/pdo_odbc/tests/pdo_024.phpt
new file mode 100755
index 0000000000..633c2ad341
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_024.phpt
@@ -0,0 +1,25 @@
+--TEST--
+PDO_ODBC: Bind does not convert NULL
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+$SQL['create'] = 'CREATE TABLE test(id INT, val VARCHAR(10))';
+
+$DB->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER);
+
+require_once($PDO_TESTS . 'pdo_024.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+bind: success
+bool(true)
+NULL
+===DONE===
diff --git a/ext/pdo_odbc/tests/pdo_025.phpt b/ext/pdo_odbc/tests/pdo_025.phpt
new file mode 100755
index 0000000000..569113f9c0
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_025.phpt
@@ -0,0 +1,70 @@
+--TEST--
+PDO_ODBC: PDO_FETCH_INTO
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+$DB->setAttribute(PDO_ATTR_CASE, PDO_CASE_LOWER);
+
+require_once($PDO_TESTS . 'pdo_025.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECTF--
+object(Test)#%d (3) {
+ ["id"]=>
+ string(2) "10"
+ ["val"]=>
+ string(3) "Abc"
+ ["val2"]=>
+ string(3) "zxy"
+}
+object(Test)#%d (3) {
+ ["id"]=>
+ string(2) "20"
+ ["val"]=>
+ string(3) "Def"
+ ["val2"]=>
+ string(3) "wvu"
+}
+object(Test)#%d (3) {
+ ["id"]=>
+ string(2) "30"
+ ["val"]=>
+ string(3) "Ghi"
+ ["val2"]=>
+ string(3) "tsr"
+}
+object(Test)#%d (3) {
+ ["id"]=>
+ string(2) "40"
+ ["val"]=>
+ string(3) "Jkl"
+ ["val2"]=>
+ string(3) "qpo"
+}
+object(Test)#%d (3) {
+ ["id"]=>
+ string(2) "50"
+ ["val"]=>
+ string(3) "Mno"
+ ["val2"]=>
+ string(3) "nml"
+}
+object(Test)#%d (3) {
+ ["id"]=>
+ string(2) "60"
+ ["val"]=>
+ string(3) "Pqr"
+ ["val2"]=>
+ string(3) "kji"
+}
+===FAIL===
+
+Fatal error: Cannot access protected property Fail::$id in %spdo_025.inc on line %d
diff --git a/ext/pdo_odbc/tests/pdo_026.phpt b/ext/pdo_odbc/tests/pdo_026.phpt
new file mode 100755
index 0000000000..a8837305dc
--- /dev/null
+++ b/ext/pdo_odbc/tests/pdo_026.phpt
@@ -0,0 +1,50 @@
+--TEST--
+PDO_ODBC: Deriving PDO
+--SKIPIF--
+<?php # vim:ft=php
+require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+require_once('connection.inc');
+require_once('prepare.inc');
+
+require_once($PDO_TESTS . 'pdo_026.inc');
+
+?>
+===DONE===
+<?php exit(0); ?>
+--EXPECT--
+string(11) "PDODatabase"
+string(12) "PDOStatement"
+PDODatabase::query()
+PDOStatementX::__construct()
+string(13) "PDOStatementX"
+string(11) "PDODatabase"
+array(3) {
+ ["ID"]=>
+ string(2) "10"
+ ["VAL"]=>
+ string(3) "Abc"
+ ["VAL2"]=>
+ string(3) "zxy"
+}
+array(3) {
+ ["ID"]=>
+ string(2) "20"
+ ["VAL"]=>
+ string(3) "Def"
+ ["VAL2"]=>
+ string(3) "wvu"
+}
+array(3) {
+ ["ID"]=>
+ string(2) "30"
+ ["VAL"]=>
+ string(3) "Ghi"
+ ["VAL2"]=>
+ string(3) "tsr"
+}
+===DONE===
+PDODatabase::__destruct()
+PDOStatementX::__destruct()
diff --git a/ext/pdo_odbc/tests/prepare.inc b/ext/pdo_odbc/tests/prepare.inc
index 43725d47e5..22a6fc720f 100755
--- a/ext/pdo_odbc/tests/prepare.inc
+++ b/ext/pdo_odbc/tests/prepare.inc
@@ -6,7 +6,8 @@ $SQL = array(
'create'=>'CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))'
);
-$DB = new pdo($CONNECTION, $USER, $PASSWD);
+//$DB = new pdo($CONNECTION, $USER, $PASSWD);
+$DB = new pdo($CONNECTION);
foreach(array('test','classtypes') as $name)
{