From: Michael Wallner Date: Fri, 22 Feb 2013 16:16:12 +0000 (+0100) Subject: tests X-Git-Tag: v0.1.0~4 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=85f142207324c70548bd052164779ded22faa154;p=m6w6%2Fext-pq tests --- diff --git a/tests/lob002.phpt b/tests/lob002.phpt new file mode 100644 index 0000000..e2fd056 --- /dev/null +++ b/tests/lob002.phpt @@ -0,0 +1,48 @@ +--TEST-- +large object stream +--SKIPIF-- + +--FILE-- +startTransaction(); + +$lob = $t->createLOB(); +fwrite($lob->stream, file_get_contents(__FILE__)); +var_dump(ftell($lob->stream)); + +fseek($lob->stream, 0, SEEK_SET); +$dat = fread($lob->stream, filesize(__FILE__)); +var_dump(hash("md5", $dat)==hash_file("md5", __FILE__)); + +ftruncate($lob->stream, 5); + +$lob = new pq\Lob($t, $lob->oid); +var_dump(fread($lob->stream, 123)); + +$t->commit(); +$t->unlinkLOB($lob->oid); + +?> +DONE +--EXPECTF-- +Test +int(503) +bool(true) + +Warning: ftruncate(): Can't truncate this stream! in %s on line %d +string(123) "startTransaction(); + +$lob = $t->creat" +DONE + diff --git a/tests/lob003.phpt b/tests/lob003.phpt new file mode 100644 index 0000000..f6d846e --- /dev/null +++ b/tests/lob003.phpt @@ -0,0 +1,32 @@ +--TEST-- +large object closing stream +--SKIPIF-- + +--FILE-- +startTransaction(); + +$lob = $t->createLOB(); +var_dump($lob->stream); +var_dump($lob->stream); +fclose($lob->stream); // bad boy! +var_dump($lob->stream); +var_dump(fread($lob->stream, 5)); +$lob = null; +?> +DONE +--EXPECTF-- +Test +resource(%d) of type (stream) +resource(%d) of type (stream) + +Warning: fclose(): %d is not a valid stream resource in %s on line %d +resource(%d) of type (stream) +string(0) "" +DONE +