[Pkg-owncloud-commits] [php-sabredav] 50/80: Lots of stream fixes.

David Prévot taffit at moszumanska.debian.org
Thu Jan 7 02:56:32 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository php-sabredav.

commit 15976cbba7d6133f88a78be3798b911221961302
Author: Evert Pot <me at evertpot.com>
Date:   Mon Jan 4 20:38:03 2016 -0500

    Lots of stream fixes.
---
 composer.json                          |  4 ++--
 tests/Sabre/DAV/Mock/Collection.php    |  9 +++++++++
 tests/Sabre/DAV/Mock/StreamingFile.php | 16 +++++++++++++++-
 tests/Sabre/DAV/ServerRangeTest.php    | 29 +++++++++++++++++++++++++++++
 4 files changed, 55 insertions(+), 3 deletions(-)

diff --git a/composer.json b/composer.json
index 3ed80b4..c2b4328 100644
--- a/composer.json
+++ b/composer.json
@@ -18,7 +18,7 @@
         "sabre/vobject": "~4.0",
         "sabre/event" : ">=2.0.0, <4.0.0",
         "sabre/xml"  : "~1.0",
-        "sabre/http" : "~4.0",
+        "sabre/http" : "dev-master",
         "sabre/uri" : "~1.0",
         "ext-dom": "*",
         "ext-pcre": "*",
@@ -31,7 +31,7 @@
         "ext-libxml" : "*"
     },
     "require-dev" : {
-        "phpunit/phpunit" : ">= 4.8.18 < 6.0.0",
+        "phpunit/phpunit" : "~5.0.0",
         "evert/phpdoc-md" : "~0.1.0",
         "sabre/cs"        : "~0.0.5"
     },
diff --git a/tests/Sabre/DAV/Mock/Collection.php b/tests/Sabre/DAV/Mock/Collection.php
index 09a5e0e..6ccab4f 100644
--- a/tests/Sabre/DAV/Mock/Collection.php
+++ b/tests/Sabre/DAV/Mock/Collection.php
@@ -121,6 +121,15 @@ class Collection extends DAV\Collection {
     }
 
     /**
+     * Adds an already existing node to this collection.
+     */
+    function addNode(\Sabre\DAV\INode $node) {
+
+        $this->children[] = $node;
+
+    }
+
+    /**
      * Removes a childnode from this node.
      *
      * @param string $name
diff --git a/tests/Sabre/DAV/Mock/StreamingFile.php b/tests/Sabre/DAV/Mock/StreamingFile.php
index ef2016d..af7eef3 100644
--- a/tests/Sabre/DAV/Mock/StreamingFile.php
+++ b/tests/Sabre/DAV/Mock/StreamingFile.php
@@ -14,6 +14,8 @@ namespace Sabre\DAV\Mock;
  */
 class StreamingFile extends File {
 
+    protected $size;
+
     /**
      * Updates the data
      *
@@ -81,7 +83,19 @@ class StreamingFile extends File {
      */
     function getSize() {
 
-        return null;
+        return $this->size;
+
+    }
+
+    /**
+     * Allows testing scripts to set the resource's file size.
+     *
+     * @param int $size
+     * @return void
+     */
+    function setSize($size) {
+
+        $this->size = $size;
 
     }
 
diff --git a/tests/Sabre/DAV/ServerRangeTest.php b/tests/Sabre/DAV/ServerRangeTest.php
index 4d19eb5..b745485 100644
--- a/tests/Sabre/DAV/ServerRangeTest.php
+++ b/tests/Sabre/DAV/ServerRangeTest.php
@@ -30,6 +30,14 @@ class ServerRangeTest extends \Sabre\DAVServerTest {
             new DateTime('@' . $this->server->tree->getNodeForPath('files/test.txt')->getLastModified())
         );
 
+        $stream = popen('echo "Test contents"', 'r');
+        $streamingFile = new Mock\StreamingFile(
+                'no-seeking.txt',
+                $stream
+            );
+        $streamingFile->setSize(12);
+        $this->server->tree->getNodeForPath('files')->addNode($streamingFile);
+
     }
 
     function testRange() {
@@ -124,6 +132,27 @@ class ServerRangeTest extends \Sabre\DAVServerTest {
 
     }
 
+    function testNonSeekableStream() {
+
+        $request = new HTTP\Request('GET', '/files/no-seeking.txt', ['Range' => 'bytes=2-5']);
+        $response = $this->request($request);
+
+        $this->assertEquals(206, $response->getStatus(), $response);
+        $this->assertEquals([
+            'X-Sabre-Version' => [Version::VERSION],
+            'Content-Type'    => ['application/octet-stream'],
+            'Content-Length'  => [4],
+            'Content-Range'   => ['bytes 2-5/12'],
+            // 'ETag'            => ['"' . md5('Test contents') . '"'],
+            'Last-Modified'   => [$this->lastModified],
+            ],
+            $response->getHeaders()
+        );
+
+        $this->assertEquals('st c', $response->getBodyAsString());
+
+    }
+
     /**
      * @depends testRange
      */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list