diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-14 23:33:23 +0400 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2013-10-15 01:55:53 +0400 |
commit | 703e7506dd7544271090711baa5ba35721b66599 (patch) | |
tree | af36066e4fea2c236acb6cf034c9b54303c4bc3e /tests | |
parent | d53b603b8259e9c9fe498b4bd50b4dbedc0bf01b (diff) |
streamCopy() should return proper structure.
Callers of streamCopy() expect an array to be returned containing count and result.
Conflicts:
lib/helper.php
tests/lib/helper.php
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/helper.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/lib/helper.php b/tests/lib/helper.php index 336e8f8b3c5..7de63b74b49 100644 --- a/tests/lib/helper.php +++ b/tests/lib/helper.php @@ -137,4 +137,38 @@ class Test_Helper extends PHPUnit_Framework_TestCase { $result = OC_Helper::recursiveArraySearch($haystack, "NotFound"); $this->assertFalse($result); } + + /** + * @dataProvider streamCopyDataProvider + */ + public function testStreamCopy($expectedCount, $expectedResult, $source, $target) { + + if (is_string($source)) { + $source = fopen($source, 'r'); + } + if (is_string($target)) { + $target = fopen($target, 'w'); + } + + list($count, $result) = \OC_Helper::streamCopy($source, $target); + + if (is_resource($source)) { + fclose($source); + } + if (is_resource($target)) { + fclose($target); + } + + $this->assertSame($expectedCount, $count); + $this->assertSame($expectedResult, $result); + } + + + function streamCopyDataProvider() { + return array( + array(0, false, false, false), + array(0, false, \OC::$SERVERROOT . '/tests/data/lorem.txt', false), + array(446, true, \OC::$SERVERROOT . '/tests/data/lorem.txt', \OC::$SERVERROOT . '/tests/data/lorem-copy.txt'), + ); + } } |