[Pkg-owncloud-commits] [php-sabredav] 98/163: More tests.

David Prévot taffit at moszumanska.debian.org
Tue May 20 18:54:58 UTC 2014


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

taffit pushed a commit to annotated tag upstream/2.0.0_beta1
in repository php-sabredav.

commit 4bb4a1fb9c231cda577a4681719bfcf337a64d15
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Mon Apr 28 22:55:29 2014 -0400

    More tests.
---
 lib/Sabre/DAV/Property/ResponseList.php    |   2 +-
 tests/Sabre/CalDAV/ICSExportPluginTest.php |   6 +-
 tests/Sabre/DAV/ClientMock.php             |  23 +++---
 tests/Sabre/DAV/ClientTest.php             | 125 +++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+), 15 deletions(-)

diff --git a/lib/Sabre/DAV/Property/ResponseList.php b/lib/Sabre/DAV/Property/ResponseList.php
index b832ed8..d15ac85 100644
--- a/lib/Sabre/DAV/Property/ResponseList.php
+++ b/lib/Sabre/DAV/Property/ResponseList.php
@@ -79,7 +79,7 @@ class ResponseList extends DAV\Property {
     public static function unserialize(\DOMElement $prop, array $propertyMap) {
 
         $xpath = new \DOMXPath( $prop->ownerDocument );
-        $xpath->registerNamespace('d','DAV:');
+        $xpath->registerNamespace('d','urn:DAV');
 
         // Finding the 'response' element
         $xResponses = $xpath->evaluate(
diff --git a/tests/Sabre/CalDAV/ICSExportPluginTest.php b/tests/Sabre/CalDAV/ICSExportPluginTest.php
index 1c81ce5..c0e25e2 100644
--- a/tests/Sabre/CalDAV/ICSExportPluginTest.php
+++ b/tests/Sabre/CalDAV/ICSExportPluginTest.php
@@ -35,6 +35,8 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
             'uri'=>'UUID-123467',
             'principaluri' => 'admin',
             'id' => 1,
+            '{DAV:}displayname' => 'Hello!',
+            '{http://apple.com/ns/ical/}calendar-color' => '#AA0000FF',
         ];
         $tree = [
             new Calendar($cbackend,$props),
@@ -63,13 +65,15 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
 
         $obj = VObject\Reader::read($s->httpResponse->body);
 
-        $this->assertEquals(5,count($obj->children()));
+        $this->assertEquals(7,count($obj->children()));
         $this->assertEquals(1,count($obj->VERSION));
         $this->assertEquals(1,count($obj->CALSCALE));
         $this->assertEquals(1,count($obj->PRODID));
         $this->assertTrue(strpos((string)$obj->PRODID, DAV\Version::VERSION)!==false);
         $this->assertEquals(1,count($obj->VTIMEZONE));
         $this->assertEquals(1,count($obj->VEVENT));
+        $this->assertEquals("Hello!", $obj->{"X-WR-CALNAME"});
+        $this->assertEquals("#AA0000FF", $obj->{"X-APPLE-CALENDAR-COLOR"});
 
     }
     function testBeforeMethodNoVersion() {
diff --git a/tests/Sabre/DAV/ClientMock.php b/tests/Sabre/DAV/ClientMock.php
index 590c6a4..d8b53a5 100644
--- a/tests/Sabre/DAV/ClientMock.php
+++ b/tests/Sabre/DAV/ClientMock.php
@@ -2,26 +2,16 @@
 
 namespace Sabre\DAV;
 
+use Sabre\HTTP\RequestInterface;
+
 class ClientMock extends Client {
 
+    public $request;
     public $response;
 
     public $url;
     public $curlSettings;
 
-    protected function curlRequest($curlSettings) {
-
-        // We're just doing this so we don't have to change the unittests that
-        // much ;)
-        $this->url = $curlSettings[CURLOPT_URL];
-
-        unset($curlSettings[CURLOPT_URL]);
-
-        $this->curlSettings = $curlSettings;
-        return $this->response;
-
-    }
-
     /**
      * Just making this method public
      *
@@ -34,4 +24,11 @@ class ClientMock extends Client {
 
     }
 
+    public function doRequest(RequestInterface $request) {
+
+        $this->request = $request;
+        return $this->response;
+
+    }
+
 }
diff --git a/tests/Sabre/DAV/ClientTest.php b/tests/Sabre/DAV/ClientTest.php
index fae73a2..dd04f91 100644
--- a/tests/Sabre/DAV/ClientTest.php
+++ b/tests/Sabre/DAV/ClientTest.php
@@ -2,6 +2,9 @@
 
 namespace Sabre\DAV;
 
+use Sabre\HTTP\Request;
+use Sabre\HTTP\Response;
+
 require_once 'Sabre/DAV/ClientMock.php';
 
 class ClientTest extends \PHPUnit_Framework_TestCase {
@@ -24,4 +27,126 @@ class ClientTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    function testAuth() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+            'userName' => 'foo',
+            'password' => 'bar',
+        ]);
+
+        $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
+        $this->assertEquals(CURLAUTH_BASIC | CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]);
+
+    }
+
+    function testBasicAuth() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+            'userName' => 'foo',
+            'password' => 'bar',
+            'authType' => Client::AUTH_BASIC
+        ]);
+
+        $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
+        $this->assertEquals(CURLAUTH_BASIC, $client->curlSettings[CURLOPT_HTTPAUTH]);
+
+    }
+
+    function testDigestAuth() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+            'userName' => 'foo',
+            'password' => 'bar',
+            'authType' => Client::AUTH_DIGEST
+        ]);
+
+        $this->assertEquals("foo:bar", $client->curlSettings[CURLOPT_USERPWD]);
+        $this->assertEquals(CURLAUTH_DIGEST, $client->curlSettings[CURLOPT_HTTPAUTH]);
+
+    }
+
+
+    function testProxy() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+            'proxy' => 'localhost:8888',
+        ]);
+
+        $this->assertEquals("localhost:8888", $client->curlSettings[CURLOPT_PROXY]);
+
+    }
+
+    function testEncoding() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+            'encoding' => Client::ENCODING_IDENTITY | Client::ENCODING_GZIP | Client::ENCODING_DEFLATE,
+        ]);
+
+        $this->assertEquals("identity,deflate,gzip", $client->curlSettings[CURLOPT_ENCODING]);
+
+    }
+
+
+    function testCAInfo() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+        ]);
+        $client->addTrustedCertificates('foo.txt');
+        $this->assertEquals("foo.txt", $client->curlSettings[CURLOPT_CAINFO]);
+
+    }
+
+
+    function testSetVerifyPeer() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+        ]);
+        $client->setVerifyPeer(false);
+        $this->assertEquals(false, $client->curlSettings[CURLOPT_SSL_VERIFYPEER]);
+
+    }
+
+    function testPropFind() {
+
+        $client = new ClientMock([
+            'baseUri' => '/',
+        ]);
+
+        $responseBody = <<<XML
+<?xml version="1.0"?>
+<multistatus xmlns="DAV:">
+<response>
+  <href>/foo</href>
+  <propstat>
+    <prop>
+      <displayname>bar</displayname>
+    </prop>
+    <status>HTTP/1.1 200 OK</status>
+  </propstat>
+</response>
+</multistatus>
+XML;
+
+        $client->response = new Response(207, [], $responseBody);
+        $result = $client->propfind('foo', ['{DAV:}displayname', '{urn:zim}gir']);
+
+        $this->assertEquals(['{DAV:}displayname' => 'bar'], $result);
+
+        $request = $client->request;
+        $this->assertEquals('PROPFIND', $request->getMethod());
+        $this->assertEquals('/foo', $request->getUrl());
+        $this->assertEquals([
+            'Depth' => '0',
+            'Content-Type' => 'application/xml',
+        ], $request->getHeaders());
+
+    }
+
 }

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