diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 22:52:20 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-02-03 22:52:20 +0100 |
commit | f8d795820e780a6322e054c26c581570613c14f0 (patch) | |
tree | 99d3ae01ce564752807341c5743863b4c92513f8 /ext/pdo_oci | |
parent | d2cb200e10ada6fa44c54a29292bb4665728fff0 (diff) | |
download | php-git-f8d795820e780a6322e054c26c581570613c14f0.tar.gz |
Reindent phpt files
Diffstat (limited to 'ext/pdo_oci')
-rw-r--r-- | ext/pdo_oci/tests/bug46274.phpt | 2 | ||||
-rw-r--r-- | ext/pdo_oci/tests/bug46274_2.phpt | 2 | ||||
-rw-r--r-- | ext/pdo_oci/tests/bug57702.phpt | 50 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt | 36 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_attr_case.phpt | 24 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_attr_client.phpt | 24 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt | 14 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_attr_server.phpt | 6 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_class_constants.phpt | 52 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_fread_1.phpt | 8 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_quote1.phpt | 18 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt | 454 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_stream_1.phpt | 8 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pdo_oci_stream_2b.phpt | 12 | ||||
-rw-r--r-- | ext/pdo_oci/tests/pecl_bug_6364.phpt | 2 |
15 files changed, 356 insertions, 356 deletions
diff --git a/ext/pdo_oci/tests/bug46274.phpt b/ext/pdo_oci/tests/bug46274.phpt index 91aa5c883f..388d297199 100644 --- a/ext/pdo_oci/tests/bug46274.phpt +++ b/ext/pdo_oci/tests/bug46274.phpt @@ -16,7 +16,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true); try { - $db->exec("DROP TABLE test_one_blob"); + $db->exec("DROP TABLE test_one_blob"); } catch (Exception $e) { } diff --git a/ext/pdo_oci/tests/bug46274_2.phpt b/ext/pdo_oci/tests/bug46274_2.phpt index 434cdbc218..cf2618366e 100644 --- a/ext/pdo_oci/tests/bug46274_2.phpt +++ b/ext/pdo_oci/tests/bug46274_2.phpt @@ -16,7 +16,7 @@ $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); try { - $db->exec("DROP TABLE test_one_blob"); + $db->exec("DROP TABLE test_one_blob"); } catch (Exception $e) { } diff --git a/ext/pdo_oci/tests/bug57702.phpt b/ext/pdo_oci/tests/bug57702.phpt index ff64399a9a..12f91226c6 100644 --- a/ext/pdo_oci/tests/bug57702.phpt +++ b/ext/pdo_oci/tests/bug57702.phpt @@ -25,20 +25,20 @@ $stmt->execute(); function do_insert($db, $id, $data1, $data2) { - $db->beginTransaction(); - $stmt = $db->prepare("insert into bug57702 (id, data1, data2) values (:id, empty_blob(), empty_blob()) returning data1, data2 into :blob1, :blob2"); - $stmt->bindParam(':id', $id); - $stmt->bindParam(':blob1', $blob1, PDO::PARAM_LOB); - $stmt->bindParam(':blob2', $blob2, PDO::PARAM_LOB); - $blob1 = null; - $blob2 = null; - $stmt->execute(); - - fwrite($blob1, $data1); - fclose($blob1); - fwrite($blob2, $data2); - fclose($blob2); - $db->commit(); + $db->beginTransaction(); + $stmt = $db->prepare("insert into bug57702 (id, data1, data2) values (:id, empty_blob(), empty_blob()) returning data1, data2 into :blob1, :blob2"); + $stmt->bindParam(':id', $id); + $stmt->bindParam(':blob1', $blob1, PDO::PARAM_LOB); + $stmt->bindParam(':blob2', $blob2, PDO::PARAM_LOB); + $blob1 = null; + $blob2 = null; + $stmt->execute(); + + fwrite($blob1, $data1); + fclose($blob1); + fwrite($blob2, $data2); + fclose($blob2); + $db->commit(); } do_insert($db, 1, "row 1 col 1", "row 1 col 2"); @@ -63,8 +63,8 @@ var_dump($row['data2']); echo "\nSecond Query\n"; foreach($db->query("select data1 as d1, data2 as d2 from bug57702 order by id") as $row) { - var_dump($row['d1']); - var_dump($row['d2']); + var_dump($row['d1']); + var_dump($row['d2']); } //////////////////// @@ -89,8 +89,8 @@ echo "\nFourth Query\n"; $a = array(); $i = 0; foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { - $a[$i][0] = $row['d4_1']; - $a[$i][1] = $row['d4_2']; + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; $i++; } @@ -112,8 +112,8 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Let's use streams $a = array(); $i = 0; foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { - $a[$i][0] = $row['d4_1']; - $a[$i][1] = $row['d4_2']; + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; $i++; } @@ -131,11 +131,11 @@ $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Let's use streams $a = array(); $i = 0; foreach($db->query("select data1 as d4_1, data2 as d4_2 from bug57702 order by id") as $row) { - $a[$i][0] = $row['d4_1']; - $a[$i][1] = $row['d4_2']; - var_dump(stream_get_contents($a[$i][0])); - var_dump(stream_get_contents($a[$i][1])); - $i++; + $a[$i][0] = $row['d4_1']; + $a[$i][1] = $row['d4_2']; + var_dump(stream_get_contents($a[$i][0])); + var_dump(stream_get_contents($a[$i][1])); + $i++; } // Cleanup diff --git a/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt b/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt index f208fd56d9..bfe4c59f87 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt @@ -22,28 +22,28 @@ echo "Test 1 Check beginTransaction insertion\n"; $dbh->beginTransaction(); try { - $dbh->exec("insert into pdo_ac_tab (col1) values ('data 1')"); - $dbh->exec("insert into pdo_ac_tab (col1) values ('data 2')"); - $dbh->commit(); + $dbh->exec("insert into pdo_ac_tab (col1) values ('data 1')"); + $dbh->exec("insert into pdo_ac_tab (col1) values ('data 2')"); + $dbh->commit(); } catch (PDOException $e) { - echo "Caught unexpected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; - $dbh->rollback(); + echo "Caught unexpected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; + $dbh->rollback(); } echo "Test 2 Cause an exception and test beginTransaction rollback\n"; $dbh->beginTransaction(); try { - $dbh->exec("insert into pdo_ac_tab (col1) values ('not committed #1')"); - $dbh->exec("insert into pdo_ac_tab (col1) values ('data that is too long to fit and will barf')"); - $dbh->commit(); + $dbh->exec("insert into pdo_ac_tab (col1) values ('not committed #1')"); + $dbh->exec("insert into pdo_ac_tab (col1) values ('data that is too long to fit and will barf')"); + $dbh->commit(); } catch (PDOException $e) { - echo "Caught expected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; - $dbh->rollback(); + echo "Caught expected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; + $dbh->rollback(); } echo "Test 3 Setting ATTR_AUTOCOMMIT to true will commit and end the transaction\n"; @@ -53,11 +53,11 @@ $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, true); print "PDO::ATTR_AUTOCOMMIT: "; var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT)); try { - $dbh->rollback(); + $dbh->rollback(); } catch (PDOException $e) { - echo "Caught expected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; + echo "Caught expected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; } echo "Test 4 Setting ATTR_AUTOCOMMIT to false will commit and end the transaction\n"; @@ -68,11 +68,11 @@ $dbh->setAttribute(PDO::ATTR_AUTOCOMMIT, false); print "PDO::ATTR_AUTOCOMMIT: "; var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT)); try { - $dbh->rollback(); + $dbh->rollback(); } catch (PDOException $e) { - echo "Caught expected exception at line " . __LINE__ . "\n"; - echo $e->getMessage() . "\n"; + echo "Caught expected exception at line " . __LINE__ . "\n"; + echo $e->getMessage() . "\n"; } echo "Test 5 Handle transactions ourselves\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_attr_case.phpt b/ext/pdo_oci/tests/pdo_oci_attr_case.phpt index 5ad89af6b1..09821cb74d 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_case.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_case.phpt @@ -13,22 +13,22 @@ require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); function do_query1($dbh) { - var_dump($dbh->getAttribute(PDO::ATTR_CASE)); - $s = $dbh->prepare("select dummy from dual"); - $s->execute(); - while ($r = $s->fetch(PDO::FETCH_ASSOC)) { - var_dump($r); - } + var_dump($dbh->getAttribute(PDO::ATTR_CASE)); + $s = $dbh->prepare("select dummy from dual"); + $s->execute(); + while ($r = $s->fetch(PDO::FETCH_ASSOC)) { + var_dump($r); + } } function do_query2($dbh, $mode) { - echo "Mode desired is $mode\n"; - $s = $dbh->prepare("select dummy from dual", array(PDO::ATTR_CASE, $mode)); - $s->execute(); - while ($r = $s->fetch(PDO::FETCH_ASSOC)) { - var_dump($r); - } + echo "Mode desired is $mode\n"; + $s = $dbh->prepare("select dummy from dual", array(PDO::ATTR_CASE, $mode)); + $s->execute(); + while ($r = $s->fetch(PDO::FETCH_ASSOC)) { + var_dump($r); + } } $dbh = PDOTest::factory(); diff --git a/ext/pdo_oci/tests/pdo_oci_attr_client.phpt b/ext/pdo_oci/tests/pdo_oci_attr_client.phpt index 3febab71ea..fdb65cf156 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_client.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_client.phpt @@ -19,19 +19,19 @@ var_dump($cv); $s = explode(".", $cv); if (count($s) > 1 && (($s[0] == 10 && $s[1] >= 2) || $s[0] >= 11)) { - if (count($s) != 5) { - echo "Wrong number of values in array\nVersion was: "; - var_dump($cv); - } else { - echo "Version OK, so far as can be portably checked\n"; - } + if (count($s) != 5) { + echo "Wrong number of values in array\nVersion was: "; + var_dump($cv); + } else { + echo "Version OK, so far as can be portably checked\n"; + } } else { - if (count($s) != 2) { - echo "Wrong number of values in array\nVersion was: "; - var_dump($cv); - } else { - echo "Version OK, so far as can be portably checked\n"; - } + if (count($s) != 2) { + echo "Wrong number of values in array\nVersion was: "; + var_dump($cv); + } else { + echo "Version OK, so far as can be portably checked\n"; + } } echo "Done\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt b/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt index 2a38341b27..cb8edba543 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_nulls_1.phpt @@ -13,13 +13,13 @@ require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); function do_query($dbh) { - var_dump($dbh->getAttribute(PDO::ATTR_ORACLE_NULLS)); - $s = $dbh->prepare("select '' as myempty, null as mynull from dual"); - $s->execute(); - while ($r = $s->fetch()) { - var_dump($r[0]); - var_dump($r[1]); - } + var_dump($dbh->getAttribute(PDO::ATTR_ORACLE_NULLS)); + $s = $dbh->prepare("select '' as myempty, null as mynull from dual"); + $s->execute(); + while ($r = $s->fetch()) { + var_dump($r[0]); + var_dump($r[1]); + } } $dbh = PDOTest::factory(); diff --git a/ext/pdo_oci/tests/pdo_oci_attr_server.phpt b/ext/pdo_oci/tests/pdo_oci_attr_server.phpt index 566bd0749d..e17401ddac 100644 --- a/ext/pdo_oci/tests/pdo_oci_attr_server.phpt +++ b/ext/pdo_oci/tests/pdo_oci_attr_server.phpt @@ -22,10 +22,10 @@ echo "ATTR_SERVER_INFO\n"; $si = $dbh->getAttribute(PDO::ATTR_SERVER_INFO); $pos = strpos($si, "Oracle"); if ($pos === 0) { - echo "Found 'Oracle' at position $pos as expected\n"; + echo "Found 'Oracle' at position $pos as expected\n"; } else { - echo "Unexpected result. Server info was:\n"; - var_dump($si); + echo "Unexpected result. Server info was:\n"; + var_dump($si); } echo "Done\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_class_constants.phpt b/ext/pdo_oci/tests/pdo_oci_class_constants.phpt index 0946b3f89b..f66c825245 100644 --- a/ext/pdo_oci/tests/pdo_oci_class_constants.phpt +++ b/ext/pdo_oci/tests/pdo_oci_class_constants.phpt @@ -12,11 +12,11 @@ PDOTest::skip(); require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); $expected = [ - 'OCI_ATTR_CLIENT_INFO' => true, - 'OCI_ATTR_ACTION' => true, - 'OCI_ATTR_CLIENT_IDENTIFIER' => true, - 'OCI_ATTR_MODULE' => true, - 'OCI_ATTR_CALL_TIMEOUT' => true, + 'OCI_ATTR_CLIENT_INFO' => true, + 'OCI_ATTR_ACTION' => true, + 'OCI_ATTR_CLIENT_IDENTIFIER' => true, + 'OCI_ATTR_MODULE' => true, + 'OCI_ATTR_CALL_TIMEOUT' => true, ]; $ref = new ReflectionClass('PDO'); @@ -24,40 +24,40 @@ $constants = $ref->getConstants(); $values = []; foreach ($constants as $name => $value) { - if (substr($name, 0, 8) == 'OCI_ATTR') { - if (!isset($values[$value])) { - $values[$value] = [$name]; + if (substr($name, 0, 8) == 'OCI_ATTR') { + if (!isset($values[$value])) { + $values[$value] = [$name]; } else { - $values[$value][] = $name; + $values[$value][] = $name; } - if (isset($expected[$name])) { - unset($expected[$name]); - unset($constants[$name]); - } + if (isset($expected[$name])) { + unset($expected[$name]); + unset($constants[$name]); + } - } else { - unset($constants[$name]); - } + } else { + unset($constants[$name]); + } } if (!empty($constants)) { - printf("[001] Dumping list of unexpected constants\n"); - var_dump($constants); + printf("[001] Dumping list of unexpected constants\n"); + var_dump($constants); } if (!empty($expected)) { - printf("[002] Dumping list of missing constants\n"); - var_dump($expected); + printf("[002] Dumping list of missing constants\n"); + var_dump($expected); } if (!empty($values)) { - foreach ($values as $value => $constants) { - if (count($constants) > 1) { - printf("[003] Several constants share the same value '%s'\n", $value); - var_dump($constants); - } - } + foreach ($values as $value => $constants) { + if (count($constants) > 1) { + printf("[003] Several constants share the same value '%s'\n", $value); + var_dump($constants); + } + } } print "done!"; diff --git a/ext/pdo_oci/tests/pdo_oci_fread_1.phpt b/ext/pdo_oci/tests/pdo_oci_fread_1.phpt index 0fa06c9ce4..85a0ca19ed 100644 --- a/ext/pdo_oci/tests/pdo_oci_fread_1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_fread_1.phpt @@ -19,7 +19,7 @@ $dbh->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); // Initialization $stmtarray = array( "begin execute immediate 'drop table pdo_oci_fread_tab'; exception when others then null; end;", - "create table pdo_oci_fread_tab (id number, data clob)", + "create table pdo_oci_fread_tab (id number, data clob)", "declare lob1 clob := 'abc' || lpad('j',4020,'j') || 'xyz'; begin @@ -28,7 +28,7 @@ $stmtarray = array( ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } echo "Test 1\n"; @@ -47,11 +47,11 @@ fclose($sh); // Clean up $stmtarray = array( - "drop table pdo_oci_fread_tab" + "drop table pdo_oci_fread_tab" ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } ?> diff --git a/ext/pdo_oci/tests/pdo_oci_quote1.phpt b/ext/pdo_oci/tests/pdo_oci_quote1.phpt index b71ff17e80..415917829f 100644 --- a/ext/pdo_oci/tests/pdo_oci_quote1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_quote1.phpt @@ -21,17 +21,17 @@ $stmt = $db->prepare('select * from poq_tab'); $a = array(null, "", "a", "ab", "abc", "ab'cd", "a\b\n", "'", "''", "a'", "'z", "a''b", '"'); foreach ($a as $u) { - $q = $db->quote($u); - echo "Unquoted : "; - var_dump($u); - echo "Quoted : "; - var_dump($q); + $q = $db->quote($u); + echo "Unquoted : "; + var_dump($u); + echo "Quoted : "; + var_dump($q); - $db->exec("delete from poq_tab"); + $db->exec("delete from poq_tab"); - $db->query("insert into poq_tab (t) values($q)"); - $stmt->execute(); - var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); + $db->query("insert into poq_tab (t) values($q)"); + $stmt->execute(); + var_dump($stmt->fetchAll(PDO::FETCH_ASSOC)); } echo "Done\n"; diff --git a/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt b/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt index 1b152c5039..4f3a19c8be 100644 --- a/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt +++ b/ext/pdo_oci/tests/pdo_oci_stmt_getcolumnmeta.phpt @@ -13,116 +13,116 @@ echo "Preparations before the test\n"; require(__DIR__ . '/../../pdo/tests/pdo_test.inc'); try { - $db = PDOTest::factory(); - $db->exec(<<<SQL + $db = PDOTest::factory(); + $db->exec(<<<SQL BEGIN EXECUTE IMMEDIATE 'DROP TABLE test'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN - RAISE; + RAISE; END IF; END; SQL ); - $db->exec("CREATE TABLE test(id INT)"); - - $db->beginTransaction(); - - $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); - - echo "Test 1. calling function with invalid parameters\n"; - - // execute() has not been called yet - // NOTE: no warning - if (false !== ($tmp = $stmt->getColumnMeta(0))) - printf("[002] Expecting false got %s\n", var_export($tmp, true)); - - $stmt->execute(); - // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 0 given in - if (false !== ($tmp = @$stmt->getColumnMeta())) - printf("[003] Expecting false got %s\n", var_export($tmp, true)); - - // invalid offset - if (false !== ($tmp = @$stmt->getColumnMeta(-1))) - printf("[004] Expecting false got %s\n", var_export($tmp, true)); - - // Warning: PDOStatement::getColumnMeta() expects parameter 1 to be int, array given in - if (false !== ($tmp = @$stmt->getColumnMeta(array()))) - printf("[005] Expecting false got %s\n", var_export($tmp, true)); - - // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 2 given in - if (false !== ($tmp = @$stmt->getColumnMeta(1, 1))) - printf("[006] Expecting false got %s\n", var_export($tmp, true)); - - // invalid offset - if (false !== ($tmp = $stmt->getColumnMeta(1))) - printf("[007] Expecting false because of invalid offset got %s\n", var_export($tmp, true)); - - echo "Test 2. testing return values\n"; - echo "Test 2.1 testing array returned\n"; - - $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); - $stmt->execute(); - $native = $stmt->getColumnMeta(0); - if (count($native) == 0) { - printf("[008] Meta data seems wrong, %s / %s\n", - var_export($native, true), var_export($emulated, true)); - } - - - function test_return($meta, $offset, $native_type, $pdo_type){ - if (empty($meta)) { - printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset, - $stmt->errorCode(), var_export($stmt->errorInfo(), true)); - return false; - } - $elements = array('flags', 'scale', 'name', 'len', 'precision', 'pdo_type'); - foreach ($elements as $k => $element) - if (!isset($meta[$element])) { - printf("[%03d + 3] Element %s missing, %s\n", $offset, - $element, var_export($meta, true)); - return false; - } - - if (!is_null($native_type)) { - if (!isset($meta['native_type'])) { - printf("[%03d + 4] Element native_type missing, %s\n", $offset, - var_export($meta, true)); - return false; - } - - if (!is_array($native_type)) - $native_type = array($native_type); - - $found = false; - foreach ($native_type as $k => $type) { - if ($meta['native_type'] == $type) { - $found = true; - break; - } - } - - if (!$found) { - printf("[%03d + 5] Expecting native type %s, %s\n", $offset, - var_export($native_type, true), var_export($meta, true)); - return false; - } - } - - if (!is_null($pdo_type) && ($meta['pdo_type'] != $pdo_type)) { - printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, - $pdo_type, var_export($meta, true), var_export($meta['native_type'])); - return false; - } - - return true; - } - - - function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) { - - $db->exec(<<<SQL + $db->exec("CREATE TABLE test(id INT)"); + + $db->beginTransaction(); + + $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); + + echo "Test 1. calling function with invalid parameters\n"; + + // execute() has not been called yet + // NOTE: no warning + if (false !== ($tmp = $stmt->getColumnMeta(0))) + printf("[002] Expecting false got %s\n", var_export($tmp, true)); + + $stmt->execute(); + // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 0 given in + if (false !== ($tmp = @$stmt->getColumnMeta())) + printf("[003] Expecting false got %s\n", var_export($tmp, true)); + + // invalid offset + if (false !== ($tmp = @$stmt->getColumnMeta(-1))) + printf("[004] Expecting false got %s\n", var_export($tmp, true)); + + // Warning: PDOStatement::getColumnMeta() expects parameter 1 to be int, array given in + if (false !== ($tmp = @$stmt->getColumnMeta(array()))) + printf("[005] Expecting false got %s\n", var_export($tmp, true)); + + // Warning: PDOStatement::getColumnMeta() expects exactly 1 parameter, 2 given in + if (false !== ($tmp = @$stmt->getColumnMeta(1, 1))) + printf("[006] Expecting false got %s\n", var_export($tmp, true)); + + // invalid offset + if (false !== ($tmp = $stmt->getColumnMeta(1))) + printf("[007] Expecting false because of invalid offset got %s\n", var_export($tmp, true)); + + echo "Test 2. testing return values\n"; + echo "Test 2.1 testing array returned\n"; + + $stmt = $db->prepare('SELECT id FROM test ORDER BY id ASC'); + $stmt->execute(); + $native = $stmt->getColumnMeta(0); + if (count($native) == 0) { + printf("[008] Meta data seems wrong, %s / %s\n", + var_export($native, true), var_export($emulated, true)); + } + + + function test_return($meta, $offset, $native_type, $pdo_type){ + if (empty($meta)) { + printf("[%03d + 2] getColumnMeta() failed, %d - %s\n", $offset, + $stmt->errorCode(), var_export($stmt->errorInfo(), true)); + return false; + } + $elements = array('flags', 'scale', 'name', 'len', 'precision', 'pdo_type'); + foreach ($elements as $k => $element) + if (!isset($meta[$element])) { + printf("[%03d + 3] Element %s missing, %s\n", $offset, + $element, var_export($meta, true)); + return false; + } + + if (!is_null($native_type)) { + if (!isset($meta['native_type'])) { + printf("[%03d + 4] Element native_type missing, %s\n", $offset, + var_export($meta, true)); + return false; + } + + if (!is_array($native_type)) + $native_type = array($native_type); + + $found = false; + foreach ($native_type as $k => $type) { + if ($meta['native_type'] == $type) { + $found = true; + break; + } + } + + if (!$found) { + printf("[%03d + 5] Expecting native type %s, %s\n", $offset, + var_export($native_type, true), var_export($meta, true)); + return false; + } + } + + if (!is_null($pdo_type) && ($meta['pdo_type'] != $pdo_type)) { + printf("[%03d + 6] Expecting PDO type %s got %s (%s)\n", $offset, + $pdo_type, var_export($meta, true), var_export($meta['native_type'])); + return false; + } + + return true; + } + + + function test_meta(&$db, $offset, $sql_type, $value, $native_type, $pdo_type) { + + $db->exec(<<<SQL BEGIN EXECUTE IMMEDIATE 'DROP TABLE test'; EXCEPTION @@ -134,77 +134,77 @@ END; SQL ); - $sql = sprintf('CREATE TABLE test(id INT, label %s)', $sql_type); - $stmt = $db->prepare($sql); - $stmt->execute(); - - if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) { - printf("[%03d] + 1] Insert failed, %d - %s\n", $offset, - $db->errorCode(), var_export($db->errorInfo(), true)); - return false; - } - - $stmt = $db->prepare('SELECT id, label FROM test'); - $stmt->execute(); - $meta = $stmt->getColumnMeta(1); - return test_return($meta, $offset, $native_type, $pdo_type); - } - - echo "Test 2.2 testing numeric columns\n"; - - test_meta($db, 20, 'NUMBER' , 0 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 30, 'NUMBER' , 256 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 40, 'INT' , 256 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 50, 'INTEGER' , 256 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 60, 'NUMBER' , 256.01 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 70, 'NUMBER' , -8388608 , 'NUMBER', PDO::PARAM_STR); - - test_meta($db, 80, 'NUMBER' , 2147483648 , 'NUMBER', PDO::PARAM_STR); - test_meta($db, 90, 'NUMBER' , 4294967295 , 'NUMBER', PDO::PARAM_STR); - - test_meta($db, 100, 'DEC' , 1.01 , 'NUMBER' , PDO::PARAM_STR); - test_meta($db, 110, 'DECIMAL' , 1.01 , 'NUMBER' , PDO::PARAM_STR); - test_meta($db, 120, 'FLOAT' , 1.01 , 'FLOAT' , PDO::PARAM_STR); - test_meta($db, 130, 'DOUBLE PRECISION', 1.01 , 'FLOAT' , PDO::PARAM_STR); - test_meta($db, 140, 'BINARY_FLOAT' , 1.01 , 'BINARY_FLOAT' , PDO::PARAM_STR); - test_meta($db, 150, 'BINARY_DOUBLE' , 1.01 , 'BINARY_DOUBLE', PDO::PARAM_STR); - - echo "Test 2.3 testing temporal columns\n"; - - $db->exec("alter session set nls_date_format='YYYY-MM-DD'"); - test_meta($db, 160, 'DATE' , '2008-04-23' , 'DATE', PDO::PARAM_STR); - - echo "Test 2.4 testing string columns\n"; - - test_meta($db, 170, 'CHAR(1)' , 'a' , 'CHAR' , PDO::PARAM_STR); - test_meta($db, 180, 'CHAR(10)' , '0123456789' , 'CHAR' , PDO::PARAM_STR); - test_meta($db, 190, 'CHAR(255)' , str_repeat('z', 255) , 'CHAR' , PDO::PARAM_STR); - test_meta($db, 200, 'VARCHAR(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 210, 'VARCHAR(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 220, 'VARCHAR(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 230, 'VARCHAR2(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 240, 'VARCHAR2(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); - test_meta($db, 250, 'VARCHAR2(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); - - test_meta($db, 260, 'NCHAR(1)' , 'a' , 'NCHAR' , PDO::PARAM_STR); - test_meta($db, 270, 'NCHAR(10)' , '0123456789' , 'NCHAR' , PDO::PARAM_STR); - test_meta($db, 280, 'NCHAR(255)' , str_repeat('z', 255) , 'NCHAR' , PDO::PARAM_STR); - test_meta($db, 290, 'NVARCHAR2(1)' , 'a' , 'NVARCHAR2', PDO::PARAM_STR); - test_meta($db, 300, 'NVARCHAR2(10)' , '0123456789' , 'NVARCHAR2', PDO::PARAM_STR); - test_meta($db, 310, 'NVARCHAR2(255)', str_repeat('z', 255) , 'NVARCHAR2', PDO::PARAM_STR); - - echo "Test 2.5 testing lobs columns\n"; - - test_meta($db, 320, 'CLOB' , str_repeat('b', 255) , 'CLOB' , PDO::PARAM_LOB); - test_meta($db, 330, 'BLOB' , str_repeat('b', 256) , 'BLOB' , PDO::PARAM_LOB); - test_meta($db, 340, 'NCLOB' , str_repeat('b', 255) , 'NCLOB' , PDO::PARAM_LOB); - - test_meta($db, 350, 'LONG' , str_repeat('b', 256) , 'LONG' , PDO::PARAM_STR); - test_meta($db, 360, 'LONG RAW' , str_repeat('b', 256) , 'LONG RAW', PDO::PARAM_STR); - test_meta($db, 370, 'RAW(256)' , str_repeat('b', 256) , 'RAW' , PDO::PARAM_STR); - - - $db->exec(<<<SQL + $sql = sprintf('CREATE TABLE test(id INT, label %s)', $sql_type); + $stmt = $db->prepare($sql); + $stmt->execute(); + + if (!$db->exec(sprintf("INSERT INTO test(id, label) VALUES (1, '%s')", $value))) { + printf("[%03d] + 1] Insert failed, %d - %s\n", $offset, + $db->errorCode(), var_export($db->errorInfo(), true)); + return false; + } + + $stmt = $db->prepare('SELECT id, label FROM test'); + $stmt->execute(); + $meta = $stmt->getColumnMeta(1); + return test_return($meta, $offset, $native_type, $pdo_type); + } + + echo "Test 2.2 testing numeric columns\n"; + + test_meta($db, 20, 'NUMBER' , 0 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 30, 'NUMBER' , 256 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 40, 'INT' , 256 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 50, 'INTEGER' , 256 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 60, 'NUMBER' , 256.01 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 70, 'NUMBER' , -8388608 , 'NUMBER', PDO::PARAM_STR); + + test_meta($db, 80, 'NUMBER' , 2147483648 , 'NUMBER', PDO::PARAM_STR); + test_meta($db, 90, 'NUMBER' , 4294967295 , 'NUMBER', PDO::PARAM_STR); + + test_meta($db, 100, 'DEC' , 1.01 , 'NUMBER' , PDO::PARAM_STR); + test_meta($db, 110, 'DECIMAL' , 1.01 , 'NUMBER' , PDO::PARAM_STR); + test_meta($db, 120, 'FLOAT' , 1.01 , 'FLOAT' , PDO::PARAM_STR); + test_meta($db, 130, 'DOUBLE PRECISION', 1.01 , 'FLOAT' , PDO::PARAM_STR); + test_meta($db, 140, 'BINARY_FLOAT' , 1.01 , 'BINARY_FLOAT' , PDO::PARAM_STR); + test_meta($db, 150, 'BINARY_DOUBLE' , 1.01 , 'BINARY_DOUBLE', PDO::PARAM_STR); + + echo "Test 2.3 testing temporal columns\n"; + + $db->exec("alter session set nls_date_format='YYYY-MM-DD'"); + test_meta($db, 160, 'DATE' , '2008-04-23' , 'DATE', PDO::PARAM_STR); + + echo "Test 2.4 testing string columns\n"; + + test_meta($db, 170, 'CHAR(1)' , 'a' , 'CHAR' , PDO::PARAM_STR); + test_meta($db, 180, 'CHAR(10)' , '0123456789' , 'CHAR' , PDO::PARAM_STR); + test_meta($db, 190, 'CHAR(255)' , str_repeat('z', 255) , 'CHAR' , PDO::PARAM_STR); + test_meta($db, 200, 'VARCHAR(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 210, 'VARCHAR(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 220, 'VARCHAR(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 230, 'VARCHAR2(1)' , 'a' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 240, 'VARCHAR2(10)' , '0123456789' , 'VARCHAR2' , PDO::PARAM_STR); + test_meta($db, 250, 'VARCHAR2(255)' , str_repeat('z', 255) , 'VARCHAR2' , PDO::PARAM_STR); + + test_meta($db, 260, 'NCHAR(1)' , 'a' , 'NCHAR' , PDO::PARAM_STR); + test_meta($db, 270, 'NCHAR(10)' , '0123456789' , 'NCHAR' , PDO::PARAM_STR); + test_meta($db, 280, 'NCHAR(255)' , str_repeat('z', 255) , 'NCHAR' , PDO::PARAM_STR); + test_meta($db, 290, 'NVARCHAR2(1)' , 'a' , 'NVARCHAR2', PDO::PARAM_STR); + test_meta($db, 300, 'NVARCHAR2(10)' , '0123456789' , 'NVARCHAR2', PDO::PARAM_STR); + test_meta($db, 310, 'NVARCHAR2(255)', str_repeat('z', 255) , 'NVARCHAR2', PDO::PARAM_STR); + + echo "Test 2.5 testing lobs columns\n"; + + test_meta($db, 320, 'CLOB' , str_repeat('b', 255) , 'CLOB' , PDO::PARAM_LOB); + test_meta($db, 330, 'BLOB' , str_repeat('b', 256) , 'BLOB' , PDO::PARAM_LOB); + test_meta($db, 340, 'NCLOB' , str_repeat('b', 255) , 'NCLOB' , PDO::PARAM_LOB); + + test_meta($db, 350, 'LONG' , str_repeat('b', 256) , 'LONG' , PDO::PARAM_STR); + test_meta($db, 360, 'LONG RAW' , str_repeat('b', 256) , 'LONG RAW', PDO::PARAM_STR); + test_meta($db, 370, 'RAW(256)' , str_repeat('b', 256) , 'RAW' , PDO::PARAM_STR); + + + $db->exec(<<<SQL BEGIN EXECUTE IMMEDIATE 'DROP TABLE test'; EXCEPTION @@ -215,63 +215,63 @@ EXCEPTION END; SQL ); - echo "Test 2.6 testing function return\n"; - - $stmt = $db->query('SELECT count(*) FROM dual'); - $meta = $stmt->getColumnMeta(0); - test_return($meta, 380, 'NUMBER', PDO::PARAM_STR); - $stmt = $db->query("SELECT TO_DATE('2008-04-23') FROM dual"); - $meta = $stmt->getColumnMeta(0); - test_return($meta, 390, 'DATE', PDO::PARAM_STR); - $stmt = $db->query("SELECT TO_CHAR(542) FROM dual"); - $meta = $stmt->getColumnMeta(0); - test_return($meta, 400, 'VARCHAR2', PDO::PARAM_STR); - - - echo "Test 2.7 testing flags returned\n"; - - $sql = sprintf('CREATE TABLE test(id INT NOT NULL, label INT NULL)'); - $stmt = $db->prepare($sql); - $stmt->execute(); - $db->exec('INSERT INTO test(id, label) VALUES (1, 1)'); - $stmt = $db->query('SELECT id, label FROM test'); - $meta = $stmt->getColumnMeta(0); - // verify the flags array contains a not_null flag and not nullable flags - if (!isset($meta['flags'])) { - printf("[1001] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'not_null') - $found = true; - if ($flag == 'nullable') - printf("[1003] Flags seem wrong %s\n", var_export($meta, true)); - } - if (!$found) - printf("[1002] Flags seem wrong %s\n", var_export($meta, true)); - } - $meta = $stmt->getColumnMeta(1); - // verify the flags array contains a nullable flag and not not_null flags - if (!isset($meta['flags'])) { - printf("[1003] No flags contained in metadata %s\n", var_export($meta, true)); - } else { - $flags = $meta['flags']; - $found = false; - foreach ($flags as $k => $flag) { - if ($flag == 'not_null') - printf("[1004] Flags seem wrong %s\n", var_export($meta, true)); - if ($flag == 'nullable') - $found = true; - } - if (!$found) - printf("[1005] Flags seem wrong %s\n", var_export($meta, true)); - } + echo "Test 2.6 testing function return\n"; + + $stmt = $db->query('SELECT count(*) FROM dual'); + $meta = $stmt->getColumnMeta(0); + test_return($meta, 380, 'NUMBER', PDO::PARAM_STR); + $stmt = $db->query("SELECT TO_DATE('2008-04-23') FROM dual"); + $meta = $stmt->getColumnMeta(0); + test_return($meta, 390, 'DATE', PDO::PARAM_STR); + $stmt = $db->query("SELECT TO_CHAR(542) FROM dual"); + $meta = $stmt->getColumnMeta(0); + test_return($meta, 400, 'VARCHAR2', PDO::PARAM_STR); + + + echo "Test 2.7 testing flags returned\n"; + + $sql = sprintf('CREATE TABLE test(id INT NOT NULL, label INT NULL)'); + $stmt = $db->prepare($sql); + $stmt->execute(); + $db->exec('INSERT INTO test(id, label) VALUES (1, 1)'); + $stmt = $db->query('SELECT id, label FROM test'); + $meta = $stmt->getColumnMeta(0); + // verify the flags array contains a not_null flag and not nullable flags + if (!isset($meta['flags'])) { + printf("[1001] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'not_null') + $found = true; + if ($flag == 'nullable') + printf("[1003] Flags seem wrong %s\n", var_export($meta, true)); + } + if (!$found) + printf("[1002] Flags seem wrong %s\n", var_export($meta, true)); + } + $meta = $stmt->getColumnMeta(1); + // verify the flags array contains a nullable flag and not not_null flags + if (!isset($meta['flags'])) { + printf("[1003] No flags contained in metadata %s\n", var_export($meta, true)); + } else { + $flags = $meta['flags']; + $found = false; + foreach ($flags as $k => $flag) { + if ($flag == 'not_null') + printf("[1004] Flags seem wrong %s\n", var_export($meta, true)); + if ($flag == 'nullable') + $found = true; + } + if (!$found) + printf("[1005] Flags seem wrong %s\n", var_export($meta, true)); + } } catch (PDOException $e) { - // we should never get here, we use warnings, but never trust a system... - printf("[001] %s, [%s} %s\n", - $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); + // we should never get here, we use warnings, but never trust a system... + printf("[001] %s, [%s} %s\n", + $e->getMessage(), $db->errorInfo(), implode(' ', $db->errorInfo())); } $db->exec(<<<SQL diff --git a/ext/pdo_oci/tests/pdo_oci_stream_1.phpt b/ext/pdo_oci/tests/pdo_oci_stream_1.phpt index ee2008d33f..a1dd8451ba 100644 --- a/ext/pdo_oci/tests/pdo_oci_stream_1.phpt +++ b/ext/pdo_oci/tests/pdo_oci_stream_1.phpt @@ -20,11 +20,11 @@ $dbh->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false); @$dbh->exec("drop table pdo_oci_stream_1_tab"); $stmtarray = array( - "create table pdo_oci_stream_1_tab (id number, data clob)", + "create table pdo_oci_stream_1_tab (id number, data clob)", ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } $dbh->exec(" @@ -76,11 +76,11 @@ echo 'Read '.stream_get_contents($r['data'], -1, 30000)."\n"; // jjjxyz // Clean up $stmtarray = array( - "drop table pdo_oci_stream_1_tab" + "drop table pdo_oci_stream_1_tab" ); foreach ($stmtarray as $stmt) { - $dbh->exec($stmt); + $dbh->exec($stmt); } ?> diff --git a/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt b/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt index 7164f5ad6f..a50b4815c3 100644 --- a/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt +++ b/ext/pdo_oci/tests/pdo_oci_stream_2b.phpt @@ -26,16 +26,16 @@ $j = 9; $a_val = ord('a'); foreach($db->query("select data1 as d4_1, data2 as d4_2 from pdo_oci_stream_2 order by id") as $row) { $a = $row['d4_1']; - $a1 = $row['d4_2']; + $a1 = $row['d4_2']; $str1 = stream_get_contents($a); - $str2 = stream_get_contents($a1); + $str2 = stream_get_contents($a1); $str1len = strlen($str1); - $str2len = strlen($str2); + $str2len = strlen($str2); $b = ord($str1[0]); - $b1 = ord($str2[0]); + $b1 = ord($str2[0]); if (($b != ($a_val + $i)) && ($str1len != (4086 + $i)) && ($b1 != ($a_val + $j)) && ($str2len != (4086 + $j))) { @@ -56,8 +56,8 @@ foreach($db->query("select data1 as d4_1, data2 as d4_2 from pdo_oci_stream_2 or $i++; if ($i>9) $i = 0; - $j--; - if ($j<0) + $j--; + if ($j<0) $j = 9; } echo "Fetch operation done!\n"; diff --git a/ext/pdo_oci/tests/pecl_bug_6364.phpt b/ext/pdo_oci/tests/pecl_bug_6364.phpt index 054d58a0f8..affdc77649 100644 --- a/ext/pdo_oci/tests/pecl_bug_6364.phpt +++ b/ext/pdo_oci/tests/pecl_bug_6364.phpt @@ -32,7 +32,7 @@ var_dump($out_param1); var_dump($out_param2); foreach ($dbh->query("select * from bug_6364_t") as $row) { - var_dump($row); + var_dump($row); } print "Done\n"; |