From: Antony Dovgal Date: Thu, 1 Mar 2007 23:29:38 +0000 (+0000) Subject: new tests X-Git-Tag: php-5.2.2RC1~249 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7a069b81d80c74436344a3852062d3bb3589b574;p=php new tests --- diff --git a/ext/oci8/tests/bug40415.phpt b/ext/oci8/tests/bug40415.phpt new file mode 100644 index 0000000000..1ebc249d38 --- /dev/null +++ b/ext/oci8/tests/bug40415.phpt @@ -0,0 +1,200 @@ +--TEST-- +Bug #40415 (Using oci_fetchall with nested cursors) +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +Test 1: Associate fetch of nested cursor +Got row "11". Now getting nested cursor: +bool(true) +array(1) { + ["ID2"]=> + string(2) "21" +} +array(1) { + ["ID2"]=> + string(2) "22" +} +array(1) { + ["ID2"]=> + string(2) "23" +} +Got row "12". Now getting nested cursor: +bool(true) +array(1) { + ["ID2"]=> + string(2) "21" +} +array(1) { + ["ID2"]=> + string(2) "22" +} +array(1) { + ["ID2"]=> + string(2) "23" +} +Got row "13". Now getting nested cursor: +bool(true) +array(1) { + ["ID2"]=> + string(2) "21" +} +array(1) { + ["ID2"]=> + string(2) "22" +} +array(1) { + ["ID2"]=> + string(2) "23" +} + +Test 2: fetchall of nested cursor +Rows returned 3 +array(2) { + ["ID1"]=> + array(3) { + [0]=> + string(2) "11" + [1]=> + string(2) "12" + [2]=> + string(2) "13" + } + ["CURSOR"]=> + array(3) { + [0]=> + resource(%d) of type (oci8 statement) + [1]=> + resource(%d) of type (oci8 statement) + [2]=> + resource(%d) of type (oci8 statement) + } +} +Getting nested cursor +bool(true) +array(1) { + ["ID2"]=> + array(3) { + [0]=> + string(2) "21" + [1]=> + string(2) "22" + [2]=> + string(2) "23" + } +} +Getting nested cursor +bool(true) +array(1) { + ["ID2"]=> + array(3) { + [0]=> + string(2) "21" + [1]=> + string(2) "22" + [2]=> + string(2) "23" + } +} +Getting nested cursor +bool(true) +array(1) { + ["ID2"]=> + array(3) { + [0]=> + string(2) "21" + [1]=> + string(2) "22" + [2]=> + string(2) "23" + } +} +Done diff --git a/ext/oci8/tests/fetch_all3.phpt b/ext/oci8/tests/fetch_all3.phpt new file mode 100644 index 0000000000..503e5dd88e --- /dev/null +++ b/ext/oci8/tests/fetch_all3.phpt @@ -0,0 +1,577 @@ +--TEST-- +oci_fetch_all() - all combinations of flags +--SKIPIF-- + +--FILE-- + +--EXPECT-- +None +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_ASSOC +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC +int(4) +array(2) { + ["ID"]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + ["VALUE"]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(2) "-1" + } + [1]=> + array(2) { + ["ID"]=> + string(1) "2" + ["VALUE"]=> + string(2) "-2" + } + [2]=> + array(2) { + ["ID"]=> + string(1) "3" + ["VALUE"]=> + string(2) "-3" + } + [3]=> + array(2) { + ["ID"]=> + string(1) "4" + ["VALUE"]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_FETCHSTATEMENT_BY_COLUMN|OCI_NUM|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_FETCHSTATEMENT_BY_ROW|OCI_NUM|OCI_ASSOC +int(4) +array(4) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(2) "-1" + } + [1]=> + array(2) { + [0]=> + string(1) "2" + [1]=> + string(2) "-2" + } + [2]=> + array(2) { + [0]=> + string(1) "3" + [1]=> + string(2) "-3" + } + [3]=> + array(2) { + [0]=> + string(1) "4" + [1]=> + string(2) "-4" + } +} +OCI_NUM +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +OCI_NUM|OCI_ASSOC +int(4) +array(2) { + [0]=> + array(4) { + [0]=> + string(1) "1" + [1]=> + string(1) "2" + [2]=> + string(1) "3" + [3]=> + string(1) "4" + } + [1]=> + array(4) { + [0]=> + string(2) "-1" + [1]=> + string(2) "-2" + [2]=> + string(2) "-3" + [3]=> + string(2) "-4" + } +} +Done diff --git a/ext/oci8/tests/lob_037.phpt b/ext/oci8/tests/lob_037.phpt new file mode 100644 index 0000000000..228f5e8123 --- /dev/null +++ b/ext/oci8/tests/lob_037.phpt @@ -0,0 +1,68 @@ +--TEST-- +Fetching two different lobs and using them after fetch +--SKIPIF-- + +--FILE-- +write("first lob data")); +oci_commit($c); + +/* insert the second LOB */ +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($s, OCI_DEFAULT); + +var_dump($blob->write("second lob data")); +oci_commit($c); + +/* select both */ + +$ora_sql = "SELECT blob FROM ".$schema.$table_name; +$s = oci_parse($c,$ora_sql); +oci_execute($s, OCI_DEFAULT); + +$rows = array(); +$rows[0] = oci_fetch_assoc($s); +$rows[1] = oci_fetch_assoc($s); + +var_dump($rows[0]['BLOB']->read(1000)); +var_dump($rows[1]['BLOB']->read(1000)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +int(14) +int(15) +string(14) "first lob data" +string(15) "second lob data" +Done diff --git a/ext/oci8/tests/lob_038.phpt b/ext/oci8/tests/lob_038.phpt new file mode 100644 index 0000000000..91dac66c0d --- /dev/null +++ b/ext/oci8/tests/lob_038.phpt @@ -0,0 +1,189 @@ +--TEST-- +Array fetch CLOB and BLOB +--SKIPIF-- + +--FILE-- +save("clob test 1")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->save("clob test 2")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->save("clob test 3")); + + +$s = oci_parse($c,"select clob from ".$schema.$table_name); +var_dump(oci_execute($s)); + +oci_fetch_all($s, $res); + +var_dump($res); + + +echo "Test 1b\n"; + +$s = oci_parse($c, "select clob from ".$schema.$table_name); +var_dump(oci_execute($s, OCI_DEFAULT)); +while ($row = oci_fetch_array($s, OCI_ASSOC)) { + var_dump($row); + $result = $row['CLOB']->load(); + var_dump($result); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Test 2: BLOB\n"; + +require dirname(__FILE__).'/create_table.inc'; + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (blob) + VALUES (empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$s = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_DTYPE_LOB); + + +oci_bind_by_name($s,":v_blob", $blob,-1,OCI_B_BLOB); + +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("blob test 1")); + +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("blob test 2")); + +oci_execute($s, OCI_DEFAULT); +var_dump($blob->save("blob test 3")); + +$s = oci_parse($c, "select blob from ".$schema.$table_name); +var_dump(oci_execute($s)); +oci_fetch_all($s, $res); +var_dump($res); + +echo "Test 2b\n"; + +$s = oci_parse($c, "select blob from ".$schema.$table_name); +var_dump(oci_execute($s, OCI_DEFAULT)); +while ($row = oci_fetch_array($s, OCI_ASSOC)) { + var_dump($row); + $result = $row['BLOB']->load(); + var_dump($result); +} + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1: CLOB +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + ["CLOB"]=> + array(3) { + [0]=> + string(11) "clob test 1" + [1]=> + string(11) "clob test 2" + [2]=> + string(11) "clob test 3" + } +} +Test 1b +bool(true) +array(1) { + ["CLOB"]=> + object(OCI-Lob)#2 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "clob test 1" +array(1) { + ["CLOB"]=> + object(OCI-Lob)#3 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "clob test 2" +array(1) { + ["CLOB"]=> + object(OCI-Lob)#2 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "clob test 3" +Test 2: BLOB +bool(true) +bool(true) +bool(true) +bool(true) +array(1) { + ["BLOB"]=> + array(3) { + [0]=> + string(11) "blob test 1" + [1]=> + string(11) "blob test 2" + [2]=> + string(11) "blob test 3" + } +} +Test 2b +bool(true) +array(1) { + ["BLOB"]=> + object(OCI-Lob)#3 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "blob test 1" +array(1) { + ["BLOB"]=> + object(OCI-Lob)#4 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "blob test 2" +array(1) { + ["BLOB"]=> + object(OCI-Lob)#3 (1) { + ["descriptor"]=> + resource(%d) of type (oci8 descriptor) + } +} +string(11) "blob test 3" +Done \ No newline at end of file diff --git a/ext/oci8/tests/lob_039.phpt b/ext/oci8/tests/lob_039.phpt new file mode 100644 index 0000000000..93251c8d80 --- /dev/null +++ b/ext/oci8/tests/lob_039.phpt @@ -0,0 +1,65 @@ +--TEST-- +Test CLOB->write() for multiple inserts +--SKIPIF-- + +--FILE-- +write("clob test 1")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->write("clob test 2")); + +oci_execute($s, OCI_DEFAULT); +var_dump($clob->write("clob test 3")); + +$s = oci_parse($c,"select clob from ".$schema.$table_name); +var_dump(oci_execute($s)); + +oci_fetch_all($s, $res); + +var_dump($res); + + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECT-- +Test 1: CLOB +int(11) +int(11) +int(11) +bool(true) +array(1) { + ["CLOB"]=> + array(3) { + [0]=> + string(11) "clob test 1" + [1]=> + string(11) "clob test 2" + [2]=> + string(11) "clob test 3" + } +} +Done