com php-src: Make this test meaningful: ext/hash/tests/hash_u pdate_file.phpt
| From: | Christoph Michael Becker | Date: | Tue, 18 Oct 2016 12:57:41 +0000 |
| Subject: | com php-src: Make this test meaningful: ext/hash/tests/hash_u pdate_file.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95205@lists.php.net to get a copy of this message | ||
Commit: 35b19cd2d936fb8caa081496fb610e79c4bab003
Author: Christoph M. Becker <cmbecker69@gmx.de> Tue, 18 Oct 2016 14:56:20 +0200
Parents: b7fe687914759cae706e318c3a4c245c9f71400d
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=35b19cd2d936fb8caa081496fb610e79c4bab003
Log:
Make this test meaningful
We're not only checking that hash_update_file() succeeds, but rather
that it properly works.
Furthermore, we fix the SKIPIF section – we don't need mhash to run the
test, and we don't need to check for unsupported PHP versions.
We also shorten the test name to avoid cluttering the test reports with
unnecessary detail.
Changed paths:
M ext/hash/tests/hash_update_file.phpt
Diff:
diff --git a/ext/hash/tests/hash_update_file.phpt b/ext/hash/tests/hash_update_file.phpt
index 32ce962..488be47 100644
--- a/ext/hash/tests/hash_update_file.phpt
+++ b/ext/hash/tests/hash_update_file.phpt
@@ -1,21 +1,24 @@
--TEST--
-bool hash_update_file ( resource $hcontext , string $filename [, resource $scontext = NULL ] );
+hash_update_file() function - basic test
--CREDITS--
marcosptf - <marcosptf@yahoo.com.br> - @phpsp - sao paulo - br
--SKIPIF--
<?php
-if (phpversion() < "5.3.0") {
- die('SKIP php version so lower.');
-}
-require_once(dirname(__FILE__) . '/skip_mhash.inc'); ?>
+if (!extension_loaded('hash')) die('skip hash extension not available');
?>
--FILE--
<?php
+$filePath = __DIR__ . DIRECTORY_SEPARATOR . 'hash_update_stream.txt';
+file_put_contents($filePath, 'The quick brown fox jumped over the lazy dog.');
+
$ctx = hash_init('md5');
-$filePath = __DIR__ . DIRECTORY_SEPARATOR . 'sha1.phpt';
-fopen($filePath, "r");
var_dump(hash_update_file($ctx, $filePath));
-hash_final($ctx);
+echo hash_final($ctx);
?>
--EXPECT--
bool(true)
+5c6ffbdd40d9556b73a21e63c3e0e904
+--CLEAN--
+<?php
+unlink(__DIR__ . DIRECTORY_SEPARATOR . 'hash_update_stream.txt');
+?>