tony2001                Thu Dec 21 12:41:36 2006 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/oci8/tests     lob_030.phpt lob_031.phpt lob_032.phpt 
  Log:
  new tests
  
  

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/lob_030.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/lob_030.phpt
+++ php-src/ext/oci8/tests/lob_030.phpt
--TEST--
Test piecewise fetch of CLOBs equal to, and larger than PHP_OCI_LOB_BUFFER_SIZE
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php

require dirname(__FILE__).'/connect.inc';
require dirname(__FILE__).'/create_table.inc';

function insert_verify($c, $tn, $id, $length)
{
    // Insert the data
    $ora_sql = "INSERT INTO
                       ".$tn." (id, clob)
                      VALUES (".$id.", empty_clob())
                      RETURNING
                               clob
                      INTO :v_clob ";

    $statement = oci_parse($c,$ora_sql);
    $clob = oci_new_descriptor($c,OCI_D_LOB);
    oci_bind_by_name($statement,":v_clob", $clob, -1, OCI_B_CLOB);
    oci_execute($statement, OCI_DEFAULT);

    $data = str_pad("x", $length, "x");
    $clob->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

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/lob_031.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/lob_031.phpt
+++ php-src/ext/oci8/tests/lob_031.phpt
--TEST--
Test LOB->read(), LOB->seek() and LOB->tell() with nul bytes in data
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
        
require dirname(__FILE__).'/connect.inc';
require dirname(__FILE__).'/create_table.inc';

$ora_sql = "INSERT INTO
                       ".$schema.$table_name." (blob)
                      VALUES (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);

$blob->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

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/lob_032.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/lob_032.phpt
+++ php-src/ext/oci8/tests/lob_032.phpt
--TEST--
oci_lob_write() and friends
--SKIPIF--
<?php if (!extension_loaded('oci8')) die("skip no oci8 extension"); ?>
--FILE--
<?php
        
require dirname(__FILE__).'/connect.inc';
require dirname(__FILE__).'/create_table.inc';

$ora_sql = "INSERT INTO
                       ".$schema.$table_name." (id, clob)
                      VALUES (2, empty_clob())
                      RETURNING
                               clob
                      INTO :v_clob ";

$statement = oci_parse($c,$ora_sql);
$clob = oci_new_descriptor($c,OCI_D_LOB);
oci_bind_by_name($statement,":v_clob", $clob,-1,OCI_B_CLOB);
oci_execute($statement, OCI_DEFAULT);

oci_commit($c);  // This will cause subsequent ->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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to