]> source.dussan.org Git - nextcloud-server.git/commitdiff
pass a stream to the tests
authorRobin Appelman <icewind@owncloud.com>
Tue, 14 Apr 2015 13:25:52 +0000 (15:25 +0200)
committerRobin Appelman <icewind@owncloud.com>
Tue, 14 Apr 2015 13:25:52 +0000 (15:25 +0200)
lib/private/connector/sabre/file.php
tests/lib/connector/sabre/file.php

index bc4535657dc19e00c3d936ac6dfa9a44667faae6..8d739167f8fcdf6bbcbb3e35a86f5ed0cc5480f4 100644 (file)
@@ -82,12 +82,6 @@ class File extends Node implements IFile {
         * @return string|null
         */
        public function put($data) {
-               if (is_string($data)) {
-                       $stream = fopen('php://temp', 'r+');
-                       fwrite($stream, $data);
-                       fseek($stream, 0);
-                       $data = $stream;
-               };
                try {
                        $exists = $this->fileView->file_exists($this->path);
                        if ($this->info && $exists && !$this->info->isUpdateable()) {
index 13884656310c59dc05d638d2d6cc446303d558ea..3fe5c2751f1b68365f15319a2d612fe4952abe72 100644 (file)
@@ -10,6 +10,13 @@ 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
         */
@@ -29,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);
@@ -64,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')));
        }
 
        /**
@@ -99,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'));
        }
 
        /**
@@ -122,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() {
@@ -176,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'));
        }
 
        /**