diff options
author | Morris Jobke <hey@morrisjobke.de> | 2015-04-15 03:08:52 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2015-04-15 03:08:52 +0200 |
commit | e33e5b425aae5013407083d94d3b03401ade5795 (patch) | |
tree | e7f6363c9ec573d6854ace9f00381dce3e403715 /tests | |
parent | 843290a0fbde7d8e680ec80bbc441b210269b136 (diff) | |
parent | eeecca04e66d34733e69289a314b156e8257ffd2 (diff) | |
download | nextcloud-server-e33e5b425aae5013407083d94d3b03401ade5795.tar.gz nextcloud-server-e33e5b425aae5013407083d94d3b03401ade5795.zip |
Merge pull request #12006 from owncloud/dav-put-storage
Work directly on the storage when uploading over webdav
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/connector/sabre/file.php | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/tests/lib/connector/sabre/file.php b/tests/lib/connector/sabre/file.php index 74e289c1751..3fe5c2751f1 100644 --- a/tests/lib/connector/sabre/file.php +++ b/tests/lib/connector/sabre/file.php @@ -10,14 +10,25 @@ namespace Test\Connector\Sabre; class File extends \Test\TestCase { + private function getStream($string) { + $stream = fopen('php://temp', 'r+'); + fwrite($stream, $string); + fseek($stream, 0); + return $stream; + } + /** * @expectedException \Sabre\DAV\Exception */ public function testSimplePutFails() { // setup - $view = $this->getMock('\OC\Files\View', array('file_put_contents', 'getRelativePath'), array()); + $storage = $this->getMock('\OC\Files\Storage\Local', ['fopen'], [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]); + $view = $this->getMock('\OC\Files\View', array('file_put_contents', 'getRelativePath', 'resolvePath'), array()); $view->expects($this->any()) - ->method('file_put_contents') + ->method('resolvePath') + ->will($this->returnValue(array($storage, ''))); + $storage->expects($this->once()) + ->method('fopen') ->will($this->returnValue(false)); $view->expects($this->any()) @@ -25,7 +36,7 @@ class File extends \Test\TestCase { ->will($this->returnValue('/test.txt')); $info = new \OC\Files\FileInfo('/test.txt', null, null, array( - 'permissions'=>\OCP\Constants::PERMISSION_ALL + 'permissions' => \OCP\Constants::PERMISSION_ALL ), null); $file = new \OC\Connector\Sabre\File($view, $info); @@ -36,8 +47,9 @@ class File extends \Test\TestCase { public function testPutSingleFileShare() { // setup - $storage = $this->getMock('\OCP\Files\Storage'); - $view = $this->getMock('\OC\Files\View', array('file_put_contents', 'getRelativePath'), array()); + $stream = fopen('php://temp', 'w+'); + $storage = $this->getMock('\OC\Files\Storage\Local', ['fopen'], [['datadir' => \OC::$server->getTempManager()->getTemporaryFolder()]]); + $view = $this->getMock('\OC\Files\View', array('file_put_contents', 'getRelativePath', 'resolvePath'), array()); $view->expects($this->any()) ->method('resolvePath') ->with('') @@ -49,6 +61,9 @@ class File extends \Test\TestCase { ->method('file_put_contents') ->with('') ->will($this->returnValue(true)); + $storage->expects($this->once()) + ->method('fopen') + ->will($this->returnValue($stream)); $info = new \OC\Files\FileInfo('/foo.txt', null, null, array( 'permissions' => \OCP\Constants::PERMISSION_ALL @@ -56,7 +71,7 @@ class File extends \Test\TestCase { $file = new \OC\Connector\Sabre\File($view, $info); - $this->assertNotEmpty($file->put('test data')); + $this->assertNotEmpty($file->put($this->getStream('test data'))); } /** @@ -91,7 +106,7 @@ class File extends \Test\TestCase { $file = new \OC\Connector\Sabre\File($view, $info); // action - $file->put('test data'); + $file->put($this->getStream('test data')); } /** @@ -114,11 +129,12 @@ class File extends \Test\TestCase { $file = new \OC\Connector\Sabre\File($view, $info); // action - $file->put('test data'); + $file->put($this->getStream('test data')); } /** * Test setting name with setName() with invalid chars + * * @expectedException \OC\Connector\Sabre\Exception\InvalidPath */ public function testSetNameInvalidChars() { @@ -168,7 +184,7 @@ class File extends \Test\TestCase { $file = new \OC\Connector\Sabre\File($view, $info); // action - $file->put('test data'); + $file->put($this->getStream('test data')); } /** |