[Pkg-owncloud-commits] [php-sabredav] 85/148: PartialUpdate tests.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:20 UTC 2015


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

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

commit 54f202050337dc56f40a3caa8632767c9c6f4b38
Author: Evert Pot <me at evertpot.com>
Date:   Tue Mar 24 09:56:49 2015 -0400

    PartialUpdate tests.
---
 lib/DAV/PartialUpdate/Plugin.php             |  4 +-
 tests/Sabre/DAV/PartialUpdate/PluginTest.php | 81 +++++++++++++---------------
 2 files changed, 37 insertions(+), 48 deletions(-)

diff --git a/lib/DAV/PartialUpdate/Plugin.php b/lib/DAV/PartialUpdate/Plugin.php
index 18aff67..576d88e 100644
--- a/lib/DAV/PartialUpdate/Plugin.php
+++ b/lib/DAV/PartialUpdate/Plugin.php
@@ -208,10 +208,8 @@ class Plugin extends DAV\ServerPlugin {
             return [self::RANGE_APPEND];
         } elseif (strlen($matches[2])>0) {
             return [self::RANGE_START, $matches[2], $matches[3]?:null];
-        } elseif ($matches[4]) {
-            return [self::RANGE_END, $matches[4]];
         } else {
-            return null;
+            return [self::RANGE_END, $matches[4]];
         }
 
     }
diff --git a/tests/Sabre/DAV/PartialUpdate/PluginTest.php b/tests/Sabre/DAV/PartialUpdate/PluginTest.php
index 5351565..6068c73 100644
--- a/tests/Sabre/DAV/PartialUpdate/PluginTest.php
+++ b/tests/Sabre/DAV/PartialUpdate/PluginTest.php
@@ -12,7 +12,7 @@ class PluginTest extends \Sabre\DAVServerTest {
     protected $node;
     protected $plugin;
 
-    public function setUp() {
+    function setUp() {
 
         $this->node = new FileMock();
         $this->tree[] = $this->node;
@@ -26,40 +26,35 @@ class PluginTest extends \Sabre\DAVServerTest {
 
     }
 
-    public function testInit() {
+    function testInit() {
 
         $this->assertEquals('partialupdate', $this->plugin->getPluginName());
-        $this->assertEquals(array('sabredav-partialupdate'), $this->plugin->getFeatures());
-        $this->assertEquals(array(
+        $this->assertEquals(['sabredav-partialupdate'], $this->plugin->getFeatures());
+        $this->assertEquals([
             'PATCH'
-        ), $this->plugin->getHTTPMethods('partial'));
-        $this->assertEquals(array(
-        ), $this->plugin->getHTTPMethods(''));
+        ], $this->plugin->getHTTPMethods('partial'));
+        $this->assertEquals([
+        ], $this->plugin->getHTTPMethods(''));
 
     }
 
-    public function testPatchNoRange() {
+    function testPatchNoRange() {
 
         $this->node->put('00000000');
-        $request = HTTP\Sapi::createFromServerArray(array(
+        $request = HTTP\Sapi::createFromServerArray([
             'REQUEST_METHOD' => 'PATCH',
             'REQUEST_URI'    => '/partial',
-        ));
+        ]);
         $response = $this->request($request);
 
         $this->assertEquals(400, $response->status, 'Full response body:' . $response->body);
 
     }
 
-    public function testPatchNotSupported() {
+    function testPatchNotSupported() {
 
         $this->node->put('00000000');
-        $request = HTTP\Sapi::createFromServerArray(array(
-            'REQUEST_METHOD' => 'PATCH',
-            'REQUEST_URI'    => '/',
-            'X_UPDATE_RANGE' => '3-4',
-
-        ));
+        $request = new HTTP\Request('PATCH', '/', ['X-Update-Range' => '3-4']);
         $request->setBody(
             '111'
         );
@@ -69,15 +64,10 @@ class PluginTest extends \Sabre\DAVServerTest {
 
     }
 
-    public function testPatchNoContentType() {
+    function testPatchNoContentType() {
 
         $this->node->put('00000000');
-        $request = HTTP\Sapi::createFromServerArray(array(
-            'REQUEST_METHOD'      => 'PATCH',
-            'REQUEST_URI'         => '/partial',
-            'HTTP_X_UPDATE_RANGE' => 'bytes=3-4',
-
-        ));
+        $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4']);
         $request->setBody(
             '111'
         );
@@ -87,15 +77,23 @@ class PluginTest extends \Sabre\DAVServerTest {
 
     }
 
-    public function testPatchBadRange() {
+    function testPatchBadRange() {
+
+        $this->node->put('00000000');
+        $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-4', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
+        $request->setBody(
+            '111'
+        );
+        $response = $this->request($request);
+
+        $this->assertEquals(416, $response->status, 'Full response body:' . $response->body);
+
+    }
+
+    function testPatchNoLength() {
 
         $this->node->put('00000000');
-        $request = HTTP\Sapi::createFromServerArray(array(
-            'REQUEST_METHOD'      => 'PATCH',
-            'REQUEST_URI'         => '/partial',
-            'HTTP_X_UPDATE_RANGE' => 'bytes=3-4',
-            'HTTP_CONTENT_TYPE'   => 'application/x-sabredav-partialupdate',
-        ));
+        $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate']);
         $request->setBody(
             '111'
         );
@@ -105,16 +103,10 @@ class PluginTest extends \Sabre\DAVServerTest {
 
     }
 
-    public function testPatchSuccess() {
+    function testPatchSuccess() {
 
         $this->node->put('00000000');
-        $request = HTTP\Sapi::createFromServerArray(array(
-            'REQUEST_METHOD'      => 'PATCH',
-            'REQUEST_URI'         => '/partial',
-            'HTTP_X_UPDATE_RANGE' => 'bytes=3-5',
-            'HTTP_CONTENT_TYPE'   => 'application/x-sabredav-partialupdate',
-            'HTTP_CONTENT_LENGTH' => 3,
-        ));
+        $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-5', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => 3]);
         $request->setBody(
             '111'
         );
@@ -125,14 +117,13 @@ class PluginTest extends \Sabre\DAVServerTest {
 
     }
 
-    public function testPatchNoEndRange() {
+    function testPatchNoEndRange() {
 
         $this->node->put('00000');
-        $request = new HTTP\Request('PATCH','/partial',[
-            'X-Update-Range' => 'bytes=3-',
-            'Content-Type'   => 'application/x-sabredav-partialupdate',
-            'Content-Length' => '3',
-        ], '111');
+        $request = new HTTP\Request('PATCH', '/partial', ['X-Update-Range' => 'bytes=3-', 'Content-Type' => 'application/x-sabredav-partialupdate', 'Content-Length' => '3']);
+        $request->setBody(
+            '111'
+        );
 
         $response = $this->request($request);
 

-- 
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