mirror of
https://github.com/php/pecl-database-ibm_db2.git
synced 2026-03-23 23:02:16 +01:00
Fix failing test cases
Mostly involved finding resources relative to the script directory instead of from the current directory, which make test sets as the source directory. Instead of writing a file and then reading it back in to compare, just build up a string in memory and compare them. Connecting to a missing db alias returns an empty SQLSTATE. I'm not sure if/when that changed, but I've adjusted the code to handle either case. Finally, escape.dat was missing a \r in the file.
This commit is contained in:
committed by
Abhinav Radke
parent
fd5c9f9a76
commit
caacad32d9
@@ -1,10 +1,8 @@
|
||||
|
||||
Original: Some random special characters:
|
||||
,
|
||||
, \ , ' , " .
|
||||
,
|
||||
, \ , ' , " .
|
||||
,
|
||||
, \ , ' , " .
|
||||
db2_escape_string: Some random special characters:
|
||||
,
|
||||
, \ , ' , " .
|
||||
|
||||
|
||||
@@ -9,19 +9,17 @@ require_once('connection.inc');
|
||||
|
||||
$conn = db2_connect($db,$username,$password);
|
||||
|
||||
$orig = fopen("pic1.jpg", "rb");
|
||||
$new = fopen("pic1_out.jpg", "wb");
|
||||
$in_file = "pic1.jpg";
|
||||
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
|
||||
|
||||
$result = db2_exec($conn, "select photo_format, picture, length(picture) from emp_photo where photo_format='jpg' and empno='000130'");
|
||||
$row = db2_fetch_array($result);
|
||||
$out = "";
|
||||
if ($row) {
|
||||
fwrite($new, $row[1]);
|
||||
$out .= $row[1];
|
||||
}
|
||||
|
||||
$file0 = file_get_contents("pic1.jpg");
|
||||
$file1 = file_get_contents("pic1_out.jpg");
|
||||
|
||||
if(strcmp($file0, $file1) == 0) {
|
||||
if(strcmp($in, $out) == 0) {
|
||||
echo "The files are the same...good.";
|
||||
} else {
|
||||
echo "The files are not the same...bad.";
|
||||
@@ -37,4 +35,4 @@ echo "\nIterated over $count rows.";
|
||||
?>
|
||||
--EXPECT--
|
||||
The files are the same...good.
|
||||
Iterated over 8 rows.
|
||||
Iterated over 8 rows.
|
||||
|
||||
@@ -9,19 +9,17 @@ require_once('connection.inc');
|
||||
|
||||
$conn = db2_connect($db,$username,$password);
|
||||
|
||||
$orig = fopen("spook.png", "rb");
|
||||
$new = fopen("spook_out.png", "wb");
|
||||
$in_file = "spook.png";
|
||||
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
|
||||
|
||||
$result = db2_exec($conn, "SELECT picture, LENGTH(picture) FROM animal_pics WHERE name = 'Spook'");
|
||||
$row = db2_fetch_array($result);
|
||||
$out = "";
|
||||
if ($row) {
|
||||
fwrite($new, $row[0]);
|
||||
$out .= $row[0];
|
||||
}
|
||||
|
||||
$file0 = file_get_contents("spook.png");
|
||||
$file1 = file_get_contents("spook_out.png");
|
||||
|
||||
if(strcmp($file0, $file1) == 0) {
|
||||
if(strcmp($in, $out) == 0) {
|
||||
echo "The files are the same...good.";
|
||||
} else {
|
||||
echo "The files are not the same...bad.";
|
||||
|
||||
@@ -13,10 +13,9 @@ if ($conn) {
|
||||
echo "??? No way.\n";
|
||||
}
|
||||
else {
|
||||
$err = db2_conn_error();
|
||||
echo $err."\n";
|
||||
echo var_dump(db2_conn_error());
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
0800%d
|
||||
string(5) "%s"
|
||||
|
||||
@@ -19,4 +19,4 @@ else {
|
||||
|
||||
?>
|
||||
--EXPECTF--
|
||||
[IBM][CLI Driver] %s SQLSTATE=%d SQLCODE=-%d
|
||||
[IBM][CLI Driver] %s SQLCODE=-%d
|
||||
|
||||
@@ -9,19 +9,17 @@ require_once('connection.inc');
|
||||
|
||||
$conn = db2_connect($db,$username,$password);
|
||||
|
||||
$orig = fopen("pic1.jpg", "rb");
|
||||
$new = fopen("pic1_out.jpg", "wb");
|
||||
$in_file = "pic1.jpg";
|
||||
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
|
||||
|
||||
$result = db2_exec($conn, "select photo_format, picture, length(picture) from emp_photo where photo_format='jpg' and empno='000130'");
|
||||
$row = db2_fetch_assoc($result);
|
||||
$out = "";
|
||||
if ($row) {
|
||||
fwrite($new, $row['PICTURE']);
|
||||
$out .= $row['PICTURE'];
|
||||
}
|
||||
|
||||
$file0 = file_get_contents("pic1.jpg");
|
||||
$file1 = file_get_contents("pic1_out.jpg");
|
||||
|
||||
if(strcmp($file0, $file1) == 0) {
|
||||
if(strcmp($in, $out) == 0) {
|
||||
echo "The files are the same...good.";
|
||||
} else {
|
||||
echo "The files are not the same...bad.";
|
||||
|
||||
@@ -9,19 +9,17 @@ require_once('connection.inc');
|
||||
|
||||
$conn = db2_connect($db,$username,$password);
|
||||
|
||||
$orig = fopen("pic1.jpg", "rb");
|
||||
$new = fopen("pic1_out.jpg", "wb");
|
||||
$in_file = "pic1.jpg";
|
||||
$in = file_get_contents(dirname(__FILE__)."/".$in_file);
|
||||
|
||||
$result = db2_exec($conn, "select photo_format, picture, length(picture) from emp_photo where photo_format='jpg' and empno='000130'");
|
||||
$row = db2_fetch_both($result);
|
||||
$out = "";
|
||||
if ($row) {
|
||||
fwrite($new, $row['PICTURE']);
|
||||
$out .= $row['PICTURE'];
|
||||
}
|
||||
|
||||
$file0 = file_get_contents("pic1.jpg");
|
||||
$file1 = file_get_contents("pic1_out.jpg");
|
||||
|
||||
if(strcmp($file0, $file1) == 0) {
|
||||
if(strcmp($in, $out) == 0) {
|
||||
echo "The files are the same...good.";
|
||||
} else {
|
||||
echo "The files are not the same...bad.";
|
||||
|
||||
@@ -14,9 +14,6 @@ if ($conn) {
|
||||
$create = 'CREATE TABLE escapeit(id INTEGER, info VARCHAR(200))';
|
||||
$result = @db2_exec($conn, $create);
|
||||
|
||||
$orig = fopen("escape.dat", "rb");
|
||||
$new = fopen("escape_out.dat", "wb");
|
||||
|
||||
$str[0] = "Some random special characters: \n , \r , \ , ' , \" .";
|
||||
$str[1] = "Backslash (\). Single quote ('). Double quote (\")";
|
||||
$str[2] = "The NULL character \\0 must be escaped manually";
|
||||
@@ -26,8 +23,9 @@ if ($conn) {
|
||||
$str[6] = "";
|
||||
|
||||
$count = 0;
|
||||
$out = "";
|
||||
foreach( $str as $string ) {
|
||||
$escaped = db2_escape_string($string);
|
||||
$escaped = db2_escape_string($string);
|
||||
$insert = "INSERT INTO escapeit VALUES($count, '$escaped')";
|
||||
db2_exec($conn, $insert);
|
||||
|
||||
@@ -39,19 +37,18 @@ if ($conn) {
|
||||
$result = db2_fetch_array($stmt);
|
||||
$escapedFromDb = $result[0];
|
||||
|
||||
fwrite($new, "\n");
|
||||
fwrite($new, "Original: " . $string);
|
||||
fwrite($new, "\n");
|
||||
fwrite($new, "db2_escape_string: " . $escapedFromDb);
|
||||
fwrite($new, "\n");
|
||||
|
||||
$out .= "\n";
|
||||
$out .= "Original: " . $string;
|
||||
$out .= "\n";
|
||||
$out .= "db2_escape_string: " . $escapedFromDb;
|
||||
$out .= "\n";
|
||||
|
||||
$count++;
|
||||
}
|
||||
|
||||
$file0 = file_get_contents("escape.dat");
|
||||
$file1 = file_get_contents("escape_out.dat");
|
||||
$in = file_get_contents(dirname(__FILE__)."/escape.dat");
|
||||
|
||||
if(strcmp($file0, $file1) == 0) {
|
||||
if(strcmp($in, $out) == 0) {
|
||||
echo "The files are the same...good.\n";
|
||||
} else {
|
||||
echo "The files are not the same...bad.\n";
|
||||
|
||||
Reference in New Issue
Block a user