From: Antony Dovgal Date: Thu, 21 Dec 2006 12:41:03 +0000 (+0000) Subject: new tests by Christopher Jones X-Git-Tag: RELEASE_1_0_0RC1~576 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=955e71c98566d2d1ef74b582395c3dad709f5f0f;p=php new tests by Christopher Jones --- diff --git a/ext/oci8/tests/lob_030.phpt b/ext/oci8/tests/lob_030.phpt new file mode 100644 index 0000000000..86b2956a51 --- /dev/null +++ b/ext/oci8/tests/lob_030.phpt @@ -0,0 +1,75 @@ +--TEST-- +Test piecewise fetch of CLOBs equal to, and larger than PHP_OCI_LOB_BUFFER_SIZE +--SKIPIF-- + +--FILE-- +write($data); + + // Verify the data + $select_sql = "SELECT clob FROM ".$tn." where id = ".$id; + $s = oci_parse($c, $select_sql); + oci_execute($s); + + $row = oci_fetch_array($s, OCI_RETURN_LOBS); + + var_dump(strlen($row[0])); +} + +echo "Test 1: A CLOB with an even number of bytes\n"; +insert_verify($c, $schema.$table_name, 1, 1050000); + +echo "Test 2: A CLOB with an odd number of bytes\n"; +insert_verify($c, $schema.$table_name, 2, 1050001); + +echo "Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation)\n"; +insert_verify($c, $schema.$table_name, 3, 1048576); + +echo "Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code)\n"; +insert_verify($c, $schema.$table_name, 4, 1049028); + +echo "Test 5: A CLOB of 1049028-1 bytes\n"; +insert_verify($c, $schema.$table_name, 5, 1049028-1); + +echo "Test 6: A CLOB of 1049028+1 bytes\n"; +insert_verify($c, $schema.$table_name, 6, 1049028+1); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Test 1: A CLOB with an even number of bytes +int(1050000) +Test 2: A CLOB with an odd number of bytes +int(1050001) +Test 3: A CLOB of 1048576 bytes (== size of PHP_OCI_LOB_BUFFER_SIZE at time of test creation) +int(1048576) +Test 4: A CLOB of 1049028 bytes (the value used for chunks in the code) +int(1049028) +Test 5: A CLOB of 1049028-1 bytes +int(1049027) +Test 6: A CLOB of 1049028+1 bytes +int(1049029) +Done diff --git a/ext/oci8/tests/lob_031.phpt b/ext/oci8/tests/lob_031.phpt new file mode 100644 index 0000000000..aa83744a58 --- /dev/null +++ b/ext/oci8/tests/lob_031.phpt @@ -0,0 +1,107 @@ +--TEST-- +Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data +--SKIPIF-- + +--FILE-- +write(b"test"); +$blob->tell(); +$blob->seek(10, OCI_SEEK_CUR); +$blob->write(b"string"); +$blob->flush(); + +$select_sql = "SELECT blob FROM ".$schema.$table_name; +$s = oci_parse($c, $select_sql); +oci_execute($s); +$row = oci_fetch_array($s); + +$row[0]->read(3); +echo " 1. ".$row[0]->tell(). "\n"; + +$row[0]->read(3); +echo " 2. ".$row[0]->tell(). "\n"; + +$row[0]->read(3); +echo " 3. ".$row[0]->tell(). "\n"; + +$row[0]->read(6); +echo " 4. ".$row[0]->tell(). "\n"; + +$row[0]->read(4); +echo " 5. ".$row[0]->tell(). "\n"; + +// Read past end +$row[0]->read(5); +echo " 6. ".$row[0]->tell(). "\n"; + +$row[0]->read(1); +echo " 8. ".$row[0]->tell(). "\n"; + +// Now seek +$row[0]->seek(1); +echo " 9. ".$row[0]->tell(). "\n"; + +$row[0]->seek(8); +echo "10. ".$row[0]->tell(). "\n"; + +$row[0]->seek(20); +echo "11. ".$row[0]->tell(). "\n"; + +// Seek past end +$row[0]->seek(25); +echo "12. ".$row[0]->tell(). "\n"; + +// Seek past end +$row[0]->seek(2, OCI_SEEK_SET); +echo "13. ".$row[0]->tell(). "\n"; + +// Move on 2 more +$row[0]->seek(2, OCI_SEEK_CUR); +echo "14. ".$row[0]->tell(). "\n"; + +// Move 3 past the end +$row[0]->seek(3, OCI_SEEK_END); +echo "15. ".$row[0]->tell(). "\n"; + +// Move 4 before the end +$row[0]->seek(-4, OCI_SEEK_END); +echo "16. ".$row[0]->tell(). "\n"; + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- + 1. 3 + 2. 6 + 3. 9 + 4. 15 + 5. 19 + 6. 20 + 8. 20 + 9. 1 +10. 8 +11. 20 +12. 25 +13. 2 +14. 4 +15. 23 +16. 16 +Done diff --git a/ext/oci8/tests/lob_032.phpt b/ext/oci8/tests/lob_032.phpt new file mode 100644 index 0000000000..5d6ff6ec90 --- /dev/null +++ b/ext/oci8/tests/lob_032.phpt @@ -0,0 +1,33 @@ +--TEST-- +oci_lob_write() and friends +--SKIPIF-- + +--FILE-- +write() to fail +$clob->write("data"); + +require dirname(__FILE__).'/drop_table.inc'; + +echo "Done\n"; + +?> +--EXPECTF-- +Warning: OCI-Lob::write(): ORA-22990: %s in %s on line 19 +Done