summaryrefslogtreecommitdiffstats
path: root/tests/lib/files
diff options
context:
space:
mode:
authorVincent Petry <pvince81@owncloud.com>2014-03-31 18:36:52 +0200
committerVincent Petry <pvince81@owncloud.com>2014-04-01 10:07:16 +0200
commitd6ce45fe61c05c0779cfaa3207a538a7a5b9a04c (patch)
treec5fbd10a2bf10b5867ae89d2b06f2ae6e9e05919 /tests/lib/files
parentab696edba685cd6d2a64c2e48907f03197aae53f (diff)
downloadnextcloud-server-d6ce45fe61c05c0779cfaa3207a538a7a5b9a04c.tar.gz
nextcloud-server-d6ce45fe61c05c0779cfaa3207a538a7a5b9a04c.zip
Correctly read the full stream in file_get_contents
When using user-defined stream wrappers, PHP will return a maximum of 8192 bytes even if more was requested. This fix uses stream_get_contents to make sure the full stream is read and not only the first 8 KB. Added unit test with a bigger test file to cover this case.
Diffstat (limited to 'tests/lib/files')
-rw-r--r--tests/lib/files/storage/storage.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/lib/files/storage/storage.php b/tests/lib/files/storage/storage.php
index f3bfba3feb8..6ec35dfbc92 100644
--- a/tests/lib/files/storage/storage.php
+++ b/tests/lib/files/storage/storage.php
@@ -113,11 +113,22 @@ abstract class Storage extends \PHPUnit_Framework_TestCase {
);
}
+ function loremFileProvider() {
+ $root = \OC::$SERVERROOT . '/tests/data/';
+ return array(
+ // small file
+ array($root . 'lorem.txt'),
+ // bigger file (> 8 KB which is the standard PHP block size)
+ array($root . 'lorem-big.txt')
+ );
+ }
+
/**
* test the various uses of file_get_contents and file_put_contents
+ *
+ * @dataProvider loremFileProvider
*/
- public function testGetPutContents() {
- $sourceFile = \OC::$SERVERROOT . '/tests/data/lorem.txt';
+ public function testGetPutContents($sourceFile) {
$sourceText = file_get_contents($sourceFile);
//fill a file with string data