cvs: pear /MDB2/tests MDB2_usage_testcase.php
| From: | Lukas Smith | Date: | Sun, 20 Aug 2006 07:14:47 +0000 |
| Subject: | cvs: pear /MDB2/tests MDB2_usage_testcase.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-41749@lists.php.net to get a copy of this message | ||
lsmith Sun Aug 20 07:14:47 2006 UTC
Modified files:
/pear/MDB2/tests MDB2_usage_testcase.php
Log:
- fixed LOB update test in regards to RTRIM
- added RTRIM testing of LOBs into portability test
http://cvs.php.net/viewvc.cgi/pear/MDB2/tests/MDB2_usage_testcase.php?r1=1.77&r2=1.78&diff_format=u
Index: pear/MDB2/tests/MDB2_usage_testcase.php
diff -u pear/MDB2/tests/MDB2_usage_testcase.php:1.77 pear/MDB2/tests/MDB2_usage_testcase.php:1.78
--- pear/MDB2/tests/MDB2_usage_testcase.php:1.77 Sat Aug 19 22:15:26 2006
+++ pear/MDB2/tests/MDB2_usage_testcase.php Sun Aug 20 07:14:47 2006
@@ -41,7 +41,7 @@
// | Author: Paul Cooper <pgc@ucecom.com> |
// +----------------------------------------------------------------------+
//
-// $Id: MDB2_usage_testcase.php,v 1.77 2006/08/19 22:15:26 justinpatrin Exp $
+// $Id: MDB2_usage_testcase.php,v 1.78 2006/08/20 07:14:47 lsmith Exp $
require_once 'MDB2_testcase.php';
@@ -1336,6 +1336,9 @@
$binary_lob .= chr($code);
}
}
+ // need to add a non WS char at the end to not trigger any RTRIMming
+ $character_lob .= 'f';
+ $binary_lob .= 'f';
$stmt->bindParam(0, $character_lob);
$stmt->bindParam(1, $binary_lob);
@@ -1521,6 +1524,115 @@
$this->assertTrue(false, 'Error selecting from
users'.$result->getMessage());
}
$this->assertEquals($value, $result, '"MDB2_PORTABILITY_RTRIM = off" not
working');
+
+ if (!$this->supported('LOBs')) {
+ $this->assertTrue(false, '"LOBs" is not supported');
+ return;
+ }
+
+ $query = 'INSERT INTO files (ID, document, picture) VALUES (1, ?, ?)';
+ $stmt = $this->db->prepare($query, array('clob', 'blob'),
MDB2_PREPARE_MANIP, array('document', 'picture'));
+
+ $character_lob = '';
+ $binary_lob = '';
+
+ for ($i = 0; $i < 999; $i++) {
+ for ($code = 127; $code >= 32; --$code) {
+ $character_lob .= chr($code);
+ }
+ for ($code = 255; $code >= 0; --$code) {
+ $binary_lob .= chr($code);
+ }
+ }
+
+ $stmt->bindParam(0, $character_lob);
+ $stmt->bindParam(1, $binary_lob);
+
+ $result = $stmt->execute();
+
+ if (PEAR::isError($result)) {
+ $this->assertTrue(false, 'Error executing prepared query:
'.$result->getUserInfo());
+ }
+
+ $stmt->free();
+
+ $this->db->setOption('portability', MDB2_PORTABILITY_ALL);
+ $result =& $this->db->query('SELECT document, picture FROM files WHERE id =
1', array('clob', 'blob'));
+ if (PEAR::isError($result)) {
+ $this->assertTrue(false, 'Error selecting from
files'.$result->getMessage());
+ }
+
+ $this->assertTrue($result->valid(), 'The query result seem to have reached the
end of result too soon.');
+
+ $row = $result->fetchRow();
+ $clob = $row[0];
+ if (!PEAR::isError($clob) && is_resource($clob)) {
+ $value = '';
+ while (!feof($clob)) {
+ $data = fread($clob, 8192);
+ $this->assertTrue(strlen($data) >= 0, 'Could not read CLOB');
+ $value.= $data;
+ }
+ $this->db->datatype->destroyLOB($clob);
+ $this->assertEquals(rtrim($character_lob), $value,
'"MDB2_PORTABILITY_RTRIM = on" Retrieved character LOB value is different from what
was stored');
+ } else {
+ $this->assertTrue(false, 'Error retrieving CLOB result');
+ }
+
+ $blob = $row[1];
+ if (!PEAR::isError($blob) && is_resource($blob)) {
+ $value = '';
+ while (!feof($blob)) {
+ $data = fread($blob, 8192);
+ $this->assertTrue(strlen($data) >= 0, 'Could not read BLOB');
+ $value.= $data;
+ }
+
+ $this->db->datatype->destroyLOB($blob);
+ $this->assertEquals(rtrim($binary_lob), $value, '"MDB2_PORTABILITY_RTRIM =
on" Retrieved binary LOB value is different from what was stored');
+ } else {
+ $this->assertTrue(false, 'Error retrieving BLOB result');
+ }
+ $result->free();
+
+ $this->db->setOption('portability', MDB2_PORTABILITY_ALL ^
MDB2_PORTABILITY_RTRIM);
+ $result =& $this->db->query('SELECT document, picture FROM files WHERE id =
1', array('clob', 'blob'));
+ if (PEAR::isError($result)) {
+ $this->assertTrue(false, 'Error selecting from
files'.$result->getMessage());
+ }
+
+ $this->assertTrue($result->valid(), 'The query result seem to have reached the
end of result too soon.');
+
+ $row = $result->fetchRow();
+ $clob = $row[0];
+ if (!PEAR::isError($clob) && is_resource($clob)) {
+ $value = '';
+ while (!feof($clob)) {
+ $data = fread($clob, 8192);
+ $this->assertTrue(strlen($data) >= 0, 'Could not read CLOB');
+ $value.= $data;
+ }
+ $this->db->datatype->destroyLOB($clob);
+ $this->assertEquals($character_lob, $value, '"MDB2_PORTABILITY_RTRIM =
off" Retrieved character LOB value is different from what was stored');
+ } else {
+ $this->assertTrue(false, 'Error retrieving CLOB result');
+ }
+
+ $blob = $row[1];
+ if (!PEAR::isError($blob) && is_resource($blob)) {
+ $value = '';
+ while (!feof($blob)) {
+ $data = fread($blob, 8192);
+ $this->assertTrue(strlen($data) >= 0, 'Could not read BLOB');
+ $value.= $data;
+ }
+
+ $this->db->datatype->destroyLOB($blob);
+ $this->assertEquals($binary_lob, $value, '"MDB2_PORTABILITY_RTRIM =
off" Retrieved binary LOB value is different from what was stored');
+ } else {
+ $this->assertTrue(false, 'Error retrieving BLOB result');
+ }
+ $result->free();
}
/**