]> granicus.if.org Git - php/commitdiff
Begin porting standard PDO tests to PDO_ODBC, testing against DB2.
authorDan Scott <dbs@php.net>
Thu, 3 Mar 2005 11:49:35 +0000 (11:49 +0000)
committerDan Scott <dbs@php.net>
Thu, 3 Mar 2005 11:49:35 +0000 (11:49 +0000)
ext/pdo_odbc/tests/connection.inc [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_001.phpt [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_002.phpt [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_003.phpt [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_004.phpt [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_005.phpt [new file with mode: 0755]
ext/pdo_odbc/tests/pdo_015.phpt [new file with mode: 0755]
ext/pdo_odbc/tests/prepare.inc [new file with mode: 0755]
ext/pdo_odbc/tests/skipif.inc [new file with mode: 0755]

diff --git a/ext/pdo_odbc/tests/connection.inc b/ext/pdo_odbc/tests/connection.inc
new file mode 100755 (executable)
index 0000000..0d5ff88
--- /dev/null
@@ -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 (executable)
index 0000000..b9e2caa
--- /dev/null
@@ -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 (executable)
index 0000000..9c1e79f
--- /dev/null
@@ -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 (executable)
index 0000000..c48d3a4
--- /dev/null
@@ -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 (executable)
index 0000000..d5321f1
--- /dev/null
@@ -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 (executable)
index 0000000..c302208
--- /dev/null
@@ -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 (executable)
index 0000000..9a0bbc3
--- /dev/null
@@ -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 (executable)
index 0000000..43725d4
--- /dev/null
@@ -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 (executable)
index 0000000..2d44a6c
--- /dev/null
@@ -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');
+}
+
+?>