From 66d9c24cccd5e233ee0bf92b2c9e543c024ac626 Mon Sep 17 00:00:00 2001 From: Antony Dovgal Date: Thu, 21 Dec 2006 19:23:26 +0000 Subject: [PATCH] improve tests --- ext/oci8/tests/array_bind_014.phpt | 73 +++++++++ ext/oci8/tests/array_bind_int1.phpt | 2 +- ext/oci8/tests/fetch_all2.phpt | 242 ++++++++++++++++++++++++++++ ext/oci8/tests/lob_020.phpt | Bin 1597 -> 3076 bytes ext/oci8/tests/lob_027.phpt | 15 ++ ext/oci8/tests/lob_033.phpt | 38 +++++ ext/oci8/tests/lob_034.phpt | 50 ++++++ ext/oci8/tests/lob_035.phpt | 108 +++++++++++++ 8 files changed, 527 insertions(+), 1 deletion(-) create mode 100644 ext/oci8/tests/array_bind_014.phpt create mode 100644 ext/oci8/tests/fetch_all2.phpt create mode 100644 ext/oci8/tests/lob_033.phpt create mode 100644 ext/oci8/tests/lob_034.phpt create mode 100644 ext/oci8/tests/lob_035.phpt diff --git a/ext/oci8/tests/array_bind_014.phpt b/ext/oci8/tests/array_bind_014.phpt new file mode 100644 index 0000000000..bd9fdf1335 --- /dev/null +++ b/ext/oci8/tests/array_bind_014.phpt @@ -0,0 +1,73 @@ +--TEST-- +oci_bind_array_by_name() and NUMBERs +--SKIPIF-- + +--FILE-- + +--EXPECTF-- +array(5) { + [0]=> + int(5) + [1]=> + int(4) + [2]=> + int(3) + [3]=> + int(2) + [4]=> + int(1) +} +Done diff --git a/ext/oci8/tests/array_bind_int1.phpt b/ext/oci8/tests/array_bind_int1.phpt index eb2072adcf..5e06de876b 100644 --- a/ext/oci8/tests/array_bind_int1.phpt +++ b/ext/oci8/tests/array_bind_int1.phpt @@ -50,7 +50,7 @@ $statement = oci_parse($c, "BEGIN ARRAYBINDPKG1.iobind(:c1); END;"); $array = Array(1,2,3,4,5); -oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_NUM); +oci_bind_array_by_name($statement, ":c1", $array, 10, 5, SQLT_INT); oci_execute($statement); diff --git a/ext/oci8/tests/fetch_all2.phpt b/ext/oci8/tests/fetch_all2.phpt new file mode 100644 index 0000000000..ff44cac70d --- /dev/null +++ b/ext/oci8/tests/fetch_all2.phpt @@ -0,0 +1,242 @@ +--TEST-- +oci_fetch_all() - 2 +--SKIPIF-- + +--FILE-- + +--EXPECT-- +int(3) +array(5) { + ["ID"]=> + array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + } + ["VALUE"]=> + array(3) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + string(1) "1" + } + ["BLOB"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } + ["CLOB"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } + ["STRING"]=> + array(3) { + [0]=> + NULL + [1]=> + NULL + [2]=> + NULL + } +} +int(3) +array(3) { + [0]=> + array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL + } + [1]=> + array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL + } + [2]=> + array(5) { + ["ID"]=> + string(1) "1" + ["VALUE"]=> + string(1) "1" + ["BLOB"]=> + NULL + ["CLOB"]=> + NULL + ["STRING"]=> + NULL + } +} +int(0) +array(0) { +} +int(2) +array(2) { + [0]=> + array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL + } + [1]=> + array(5) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + [2]=> + NULL + [3]=> + NULL + [4]=> + NULL + } +} +int(2) +array(5) { + [0]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + } + [1]=> + array(2) { + [0]=> + string(1) "1" + [1]=> + string(1) "1" + } + [2]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } + [3]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } + [4]=> + array(2) { + [0]=> + NULL + [1]=> + NULL + } +} +int(1) +array(5) { + [0]=> + array(1) { + [0]=> + string(1) "1" + } + [1]=> + array(1) { + [0]=> + string(1) "1" + } + [2]=> + array(1) { + [0]=> + NULL + } + [3]=> + array(1) { + [0]=> + NULL + } + [4]=> + array(1) { + [0]=> + NULL + } +} +Done diff --git a/ext/oci8/tests/lob_020.phpt b/ext/oci8/tests/lob_020.phpt index edd0f02490fea26071ea3cc180de03c403b1d8ec..6564dede9bd6e67f84366906c8fc68186c1616c2 100644 GIT binary patch literal 3076 zcmcIme{Ui;5beL+PchvRWmjT3;Ci|{(h%j6r9!0;@uRJDJy~YgfZN61vrRZu<-2#h z3jxAHPp8B}LTis_-nF3Bj5tZ;m@E}H%=2F{MYa7`jK-c1OKxUx)9HQC zP7n-!ZQr$9xasGsbe002fcFFYVwlie3iLu_7JKLD@!h%aL(G}y>VJ3&LV}%yM_bpw zfU72YY_&V##-H=OquA#KR}8l*LFddP#2OIdSI%EWQV15A3K!A&#c4~#ZWu9ioUpaI zQ<91j{W*b4aNFHM*dIc>JM1}7Jlsl2M>963l~U%0SU43Iyc^`oKeFrh>&_?~fXC*k zSrKdL`NwSg;c(RNw!6O^@%0ERLN`ZjYy!}@C)Nbq3&$yGgNe_XFqoz-Y)TatvlNv# z>H8N>DKpR41zVDs=}7U^NM#LsH*IoDu-<5CJ&d`C$#|9J?`{2;-E~~I44K1nP|Nmy zAhuc7o7oo@EwHP0_CXdPY+a8!L$q@4sUq=Wo?>jvY@UR&Rr<~jGvgZYM`6ryOkqMP zHDH)FppD{UT7l(k1r(cRB^O}37AJw5GPGeSMa8k)ex#t8H#|a9K8Ag|njeE& zwOp^-<&29+&ga}9(i|pBupKu&H3&Q5%@8tfTm9Z|aIAw`y*`ZYZm)+SVk+sUg@TfP z^owC^3AQYjkF%%ba_wruOf(}@DY`=9Gw|Ew(ClONQ_###cYQzcy|p)|)^bX=UTxMv zbFCal$qZ`QzT$1jbdXbBypEf{%AgFj{gf?(2#@6G@-EwjSg?-0ypOcVrT|ZoSrP6N zb{qH$p_%QpjM(i7{XgK_em$k6v6AV&IV^gGzv`p$#Hh4J3L z^|ODhy_5HBeeJlKdpi-kF#1==2YATvTfJH%f6-VEPA*s;CWzwZZa&{+pQv=(nJP}9 z=oO6>3 z|K$pO80fhfI*9P>Wj=`T>{Wge;h@N`_lo?}w-$LM?Bmv+q6t3Gc61d|6nCb~>acNk J&##qw=RaZ;wj}@n delta 18 ZcmZpX*vqrQnPu|>)~}4LF8O(>TmV8w27mwn diff --git a/ext/oci8/tests/lob_027.phpt b/ext/oci8/tests/lob_027.phpt index 577a87014c..8b49b1ac5b 100644 --- a/ext/oci8/tests/lob_027.phpt +++ b/ext/oci8/tests/lob_027.phpt @@ -47,6 +47,16 @@ for ($i = 5; $i >= 0; $i--) { oci_commit($c); } +$select_sql = "SELECT blob FROM ".$schema.$table_name." FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row = oci_fetch_array($s); +var_dump($row['BLOB']->load()); +var_dump($row['BLOB']->truncate(-1)); +var_dump($row['BLOB']->truncate(0)); + +oci_commit($c); require dirname(__FILE__).'/drop_table.inc'; @@ -85,4 +95,9 @@ string(0) "" Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d bool(false) +string(0) "" + +Warning: OCI-Lob::truncate(): Length must be greater than or equal to zero in %s on line %d +bool(false) +bool(true) Done diff --git a/ext/oci8/tests/lob_033.phpt b/ext/oci8/tests/lob_033.phpt new file mode 100644 index 0000000000..5647cd9a41 --- /dev/null +++ b/ext/oci8/tests/lob_033.phpt @@ -0,0 +1,38 @@ +--TEST-- +various oci_lob_write() error messages +--SKIPIF-- + +--FILE-- +save(""); + +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +var_dump($blob->save("")); +var_dump($blob->save("data", 100)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: OCI-Lob::save(): OCI_INVALID_HANDLE in %s on line %d +bool(true) +bool(true) +Done diff --git a/ext/oci8/tests/lob_034.phpt b/ext/oci8/tests/lob_034.phpt new file mode 100644 index 0000000000..6bf4058e74 --- /dev/null +++ b/ext/oci8/tests/lob_034.phpt @@ -0,0 +1,50 @@ +--TEST-- +lob buffering - 2 +--SKIPIF-- + +--FILE-- +getBuffering()); +var_dump($blob->setBuffering(false)); +var_dump($blob->setBuffering(false)); +var_dump($blob->setBuffering(true)); +var_dump($blob->setBuffering(true)); +var_dump($blob->flush()); +var_dump($blob->flush(0)); +var_dump($blob->flush(-1)); + +oci_commit($c); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +bool(false) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) +bool(true) + +Warning: OCI-Lob::flush(): Invalid flag value: -1 in %s on line %d +bool(false) +Done diff --git a/ext/oci8/tests/lob_035.phpt b/ext/oci8/tests/lob_035.phpt new file mode 100644 index 0000000000..6e1f5a7359 --- /dev/null +++ b/ext/oci8/tests/lob_035.phpt @@ -0,0 +1,108 @@ +--TEST-- +oci_lob_copy() - 2 +--SKIPIF-- + +--FILE-- +write("some string here. string, I said")); +oci_commit($c); + +$ora_sql = "INSERT INTO + ".$schema.$table_name." (id, blob) + VALUES (2, empty_blob()) + RETURNING + blob + INTO :v_blob "; + +$statement = oci_parse($c,$ora_sql); +$blob = oci_new_descriptor($c,OCI_D_LOB); +oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB); +oci_execute($statement, OCI_DEFAULT); + +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 1"; +$s = oci_parse($c, $select_sql); +oci_execute($s); + +$row1 = oci_fetch_array($s); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +$row2 = oci_fetch_array($s); + +$dummy = oci_new_descriptor($c, OCI_D_LOB); + +var_dump(oci_lob_copy($dummy, $row1[0])); +var_dump(oci_lob_copy($row2[0], $dummy)); + +var_dump(oci_lob_copy($row2[0], $row1[0], 0)); +var_dump(oci_lob_copy($row2[0], $row1[0], -1)); +var_dump(oci_lob_copy($row2[0], $row1[0], 100000)); + +var_dump(oci_lob_size()); +var_dump(oci_lob_size($row2[0])); +unset($dummy->descriptor); +var_dump(oci_lob_size($dummy)); + +oci_rollback($c); +oci_rollback($c); +oci_commit($c); +oci_commit($c); + +$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE"; +$s = oci_parse($c, $select_sql); +oci_execute($s, OCI_DEFAULT); + +var_dump($row2 = oci_fetch_array($s, OCI_RETURN_LOBS)); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +int(32) + +Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d +bool(false) + +Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d +bool(false) +bool(false) + +Warning: oci_lob_copy(): Length parameter must be greater than 0 in %s on line %d +bool(false) +bool(true) + +Warning: oci_lob_size() expects exactly 1 parameter, 0 given in %s on line %d +NULL +int(0) + +Warning: oci_lob_size(): Unable to find descriptor property in %s on line %d +bool(false) +array(2) { + [0]=> + string(0) "" + ["BLOB"]=> + string(0) "" +} +Done -- 2.50.1