diff options
| author | Dan Scott <dbs@php.net> | 2005-03-03 11:49:35 +0000 |
|---|---|---|
| committer | Dan Scott <dbs@php.net> | 2005-03-03 11:49:35 +0000 |
| commit | 49d1349b9acf8aa19ae9f047e9d0a913748508ce (patch) | |
| tree | b435678d91809ede0cb162ed299f720bdca238f2 /ext/pdo_odbc | |
| parent | d9145daa61fa264d7223023f2a760bbfab676e00 (diff) | |
| download | php-git-49d1349b9acf8aa19ae9f047e9d0a913748508ce.tar.gz | |
Begin porting standard PDO tests to PDO_ODBC, testing against DB2.
Diffstat (limited to 'ext/pdo_odbc')
| -rwxr-xr-x | ext/pdo_odbc/tests/connection.inc | 11 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/pdo_001.phpt | 41 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/pdo_002.phpt | 41 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/pdo_003.phpt | 53 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/pdo_004.phpt | 41 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/pdo_005.phpt | 154 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/pdo_015.phpt | 81 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/prepare.inc | 18 | ||||
| -rwxr-xr-x | ext/pdo_odbc/tests/skipif.inc | 12 |
9 files changed, 452 insertions, 0 deletions
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 @@ +<?php + +$USER = 'db2inst1'; +$PASSWD = 'ibmdb2'; +$DBNAME = 'SAMPLE'; + +$CONNECTION = "odbc:$DBNAME"; + +$PDO_TESTS = dirname(__FILE__) . '/../../pdo/tests/'; + +?> 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-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_001.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--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-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_002.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--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-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_003.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--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-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +require_once($PDO_TESTS . 'pdo_004.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--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-- +<?php # vim:ft=php +require_once('skipif.inc'); ?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +$SQL = array( + 'create'=>'CREATE TABLE test(id int NOT NULL PRIMARY KEY, val VARCHAR(10), val2 VARCHAR(10))' +); + +require_once($PDO_TESTS . 'pdo_005.inc'); + +?> +===DONE=== +<?php exit(0); ?> +--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-- +<?php # vim:ft=php +require_once('skipif.inc'); +?> +--FILE-- +<?php + +require_once('connection.inc'); +require_once('prepare.inc'); + +$SQL = array( + 'create1'=>'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=== +<?php exit(0); ?> +--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 @@ +<?php + +require_once('connection.inc'); + +$SQL = array( + 'create'=>'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 @@ +<?php + +if (!extension_loaded('pdo_odbc')) die('skip'); + +require_once('connection.inc'); +require_once('prepare.inc'); + +if (!$DB) { + die('skip cannot open db'); +} + +?> |
