diff options
author | Bjoern Schiessle <schiessle@owncloud.com> | 2013-10-15 11:53:51 +0200 |
---|---|---|
committer | Bjoern Schiessle <schiessle@owncloud.com> | 2013-10-15 11:53:51 +0200 |
commit | 25320f19df017947f31ea156ade061274b5bd691 (patch) | |
tree | 6096ab2633d0b58f594fb5e600638603d85acdc9 /tests | |
parent | 0b8273c76834783461bc186cca69e1a73f2570de (diff) | |
parent | 52501d6ba3da5596975a945ba00ea753f6c7f4e7 (diff) | |
download | nextcloud-server-25320f19df017947f31ea156ade061274b5bd691.tar.gz nextcloud-server-25320f19df017947f31ea156ade061274b5bd691.zip |
Merge branch 'master' into avater_with_encryption
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 b4d896e5196..babafab52c0 100644 --- a/tests/lib/helper.php +++ b/tests/lib/helper.php @@ -208,4 +208,38 @@ class Test_Helper extends PHPUnit_Framework_TestCase { ->will($this->returnValue(true)); // filename(1) (2) (3).ext exists $this->assertEquals('dir/filename(1) (2) (4).ext', OC_Helper::buildNotExistingFileNameForView('dir', 'filename(1) (2) (3).ext', $viewMock)); } + + /** + * @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'), + ); + } } |