From 49d1349b9acf8aa19ae9f047e9d0a913748508ce Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Thu, 3 Mar 2005 11:49:35 +0000 Subject: [PATCH] Begin porting standard PDO tests to PDO_ODBC, testing against DB2. --- ext/pdo_odbc/tests/connection.inc | 11 +++ ext/pdo_odbc/tests/pdo_001.phpt | 41 ++++++++ ext/pdo_odbc/tests/pdo_002.phpt | 41 ++++++++ ext/pdo_odbc/tests/pdo_003.phpt | 53 ++++++++++ ext/pdo_odbc/tests/pdo_004.phpt | 41 ++++++++ ext/pdo_odbc/tests/pdo_005.phpt | 154 ++++++++++++++++++++++++++++++ ext/pdo_odbc/tests/pdo_015.phpt | 81 ++++++++++++++++ ext/pdo_odbc/tests/prepare.inc | 18 ++++ ext/pdo_odbc/tests/skipif.inc | 12 +++ 9 files changed, 452 insertions(+) create mode 100755 ext/pdo_odbc/tests/connection.inc create mode 100755 ext/pdo_odbc/tests/pdo_001.phpt create mode 100755 ext/pdo_odbc/tests/pdo_002.phpt create mode 100755 ext/pdo_odbc/tests/pdo_003.phpt create mode 100755 ext/pdo_odbc/tests/pdo_004.phpt create mode 100755 ext/pdo_odbc/tests/pdo_005.phpt create mode 100755 ext/pdo_odbc/tests/pdo_015.phpt create mode 100755 ext/pdo_odbc/tests/prepare.inc create mode 100755 ext/pdo_odbc/tests/skipif.inc diff --git a/ext/pdo_odbc/tests/connection.inc b/ext/pdo_odbc/tests/connection.inc new file mode 100755 index 0000000000..0d5ff88843 --- /dev/null +++ b/ext/pdo_odbc/tests/connection.inc @@ -0,0 +1,11 @@ + diff --git a/ext/pdo_odbc/tests/pdo_001.phpt b/ext/pdo_odbc/tests/pdo_001.phpt new file mode 100755 index 0000000000..b9e2caad0f --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_001.phpt @@ -0,0 +1,41 @@ +--TEST-- +PDO_ODBC: PDO_FETCH_ASSOC +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECT-- +array(3) { + [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" + } +} +===DONE=== diff --git a/ext/pdo_odbc/tests/pdo_002.phpt b/ext/pdo_odbc/tests/pdo_002.phpt new file mode 100755 index 0000000000..9c1e79fe8c --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_002.phpt @@ -0,0 +1,41 @@ +--TEST-- +PDO_ODBC: PDO_FETCH_NUM +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECT-- +array(3) { + [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" + } +} +===DONE=== diff --git a/ext/pdo_odbc/tests/pdo_003.phpt b/ext/pdo_odbc/tests/pdo_003.phpt new file mode 100755 index 0000000000..c48d3a4c5a --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_003.phpt @@ -0,0 +1,53 @@ +--TEST-- +PDO_ODBC: PDO_FETCH_BOTH +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECT-- +array(3) { + [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" + } +} +===DONE=== diff --git a/ext/pdo_odbc/tests/pdo_004.phpt b/ext/pdo_odbc/tests/pdo_004.phpt new file mode 100755 index 0000000000..d5321f1d2a --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_004.phpt @@ -0,0 +1,41 @@ +--TEST-- +PDO_ODBC: PDO_FETCH_OBJ +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECTF-- +array(3) { + [0]=> + object(stdClass)#%d (2) { + ["ID"]=> + string(1) "1" + ["VAL"]=> + string(1) "A" + } + [1]=> + object(stdClass)#%d (2) { + ["ID"]=> + string(1) "2" + ["VAL"]=> + string(1) "B" + } + [2]=> + object(stdClass)#%d (2) { + ["ID"]=> + string(1) "3" + ["VAL"]=> + string(1) "C" + } +} +===DONE=== diff --git a/ext/pdo_odbc/tests/pdo_005.phpt b/ext/pdo_odbc/tests/pdo_005.phpt new file mode 100755 index 0000000000..c302208c6a --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_005.phpt @@ -0,0 +1,154 @@ +--TEST-- +PDO_ODBC: PDO_FETCH_CLASS +--SKIPIF-- + +--FILE-- +'CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(10))' +); + +require_once($PDO_TESTS . 'pdo_005.inc'); + +?> +===DONE=== + +--EXPECTF-- +array(3) { + [0]=> + object(stdClass)#%d (3) { + ["ID"]=> + string(1) "1" + ["VAL"]=> + string(1) "A" + ["VAL2"]=> + string(2) "AA" + } + [1]=> + object(stdClass)#%d (3) { + ["ID"]=> + string(1) "2" + ["VAL"]=> + string(1) "B" + ["VAL2"]=> + string(2) "BB" + } + [2]=> + object(stdClass)#%d (3) { + ["ID"]=> + string(1) "3" + ["VAL"]=> + string(1) "C" + ["VAL2"]=> + string(2) "CC" + } +} +array(3) { + [0]=> + object(TestBase)#%d (6) { + ["id"]=> + NULL + ["val:protected"]=> + NULL + ["val2:private"]=> + NULL + ["ID"]=> + string(1) "1" + ["VAL"]=> + string(1) "A" + ["VAL2"]=> + string(2) "AA" + } + [1]=> + object(TestBase)#%d (6) { + ["id"]=> + NULL + ["val:protected"]=> + NULL + ["val2:private"]=> + NULL + ["ID"]=> + string(1) "2" + ["VAL"]=> + string(1) "B" + ["VAL2"]=> + string(2) "BB" + } + [2]=> + object(TestBase)#%d (6) { + ["id"]=> + NULL + ["val:protected"]=> + NULL + ["val2:private"]=> + NULL + ["ID"]=> + string(1) "3" + ["VAL"]=> + string(1) "C" + ["VAL2"]=> + string(2) "CC" + } +} +TestDerived::__construct(0,) +TestDerived::__construct(1,) +TestDerived::__construct(2,) +array(3) { + [0]=> + object(TestDerived)#%d (7) { + ["row:protected"]=> + int(0) + ["id"]=> + NULL + ["val:protected"]=> + NULL + ["val2:private"]=> + NULL + ["ID"]=> + string(1) "1" + ["VAL"]=> + string(1) "A" + ["VAL2"]=> + string(2) "AA" + } + [1]=> + object(TestDerived)#%d (7) { + ["row:protected"]=> + int(1) + ["id"]=> + NULL + ["val:protected"]=> + NULL + ["val2:private"]=> + NULL + ["ID"]=> + string(1) "2" + ["VAL"]=> + string(1) "B" + ["VAL2"]=> + string(2) "BB" + } + [2]=> + object(TestDerived)#%d (7) { + ["row:protected"]=> + int(2) + ["id"]=> + NULL + ["val:protected"]=> + NULL + ["val2:private"]=> + NULL + ["ID"]=> + string(1) "3" + ["VAL"]=> + string(1) "C" + ["VAL2"]=> + string(2) "CC" + } +} +===DONE=== diff --git a/ext/pdo_odbc/tests/pdo_015.phpt b/ext/pdo_odbc/tests/pdo_015.phpt new file mode 100755 index 0000000000..9a0bbc39a5 --- /dev/null +++ b/ext/pdo_odbc/tests/pdo_015.phpt @@ -0,0 +1,81 @@ +--TEST-- +PDO_ODBC: PDO_FETCH_COLUMN +--SKIPIF-- + +--FILE-- +'CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(10))' +); + +//require_once(dirname(__FILE__).'/../../pdo/tests/pdo.inc'); +require_once($PDO_TESTS . 'pdo_015.inc'); + +?> +===DONE=== + +--EXPECTF-- +array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" +} +array(2) { + [0]=> + string(2) "A2" + [1]=> + string(2) "B2" +} +array(2) { + [1]=> + array(1) { + [0]=> + string(1) "A" + } + [2]=> + array(1) { + [0]=> + string(1) "A" + } +} +array(2) { + [1]=> + string(1) "A" + [2]=> + string(1) "A" +} +array(2) { + [1]=> + string(1) "1" + [2]=> + string(1) "2" +} +array(2) { + [1]=> + string(1) "A" + [2]=> + string(1) "A" +} +array(2) { + [1]=> + string(2) "A2" + [2]=> + string(2) "B2" +} +array(1) { + ["A"]=> + array(2) { + [0]=> + string(2) "A2" + [1]=> + string(2) "B2" + } +} +===DONE=== diff --git a/ext/pdo_odbc/tests/prepare.inc b/ext/pdo_odbc/tests/prepare.inc new file mode 100755 index 0000000000..43725d47e5 --- /dev/null +++ b/ext/pdo_odbc/tests/prepare.inc @@ -0,0 +1,18 @@ +'CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10))' +); + +$DB = new pdo($CONNECTION, $USER, $PASSWD); + +foreach(array('test','classtypes') as $name) +{ + $DB->exec("DROP TABLE $name"); +} + +$DB->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_WARNING); + +?> diff --git a/ext/pdo_odbc/tests/skipif.inc b/ext/pdo_odbc/tests/skipif.inc new file mode 100755 index 0000000000..2d44a6c421 --- /dev/null +++ b/ext/pdo_odbc/tests/skipif.inc @@ -0,0 +1,12 @@ + -- 2.50.1