[Pkg-owncloud-commits] [php-sabredav] 129/220: Fixed unittests

David Prévot taffit at moszumanska.debian.org
Thu May 12 01:21:17 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 8419b176edab9ca9965c66df647854e04ab211fd
Author: Evert Pot <me at evertpot.com>
Date:   Tue Apr 5 23:51:33 2016 -0400

    Fixed unittests
---
 tests/Sabre/CardDAV/AddressBookQueryTest.php | 30 ++++++++++++++--------------
 tests/Sabre/CardDAV/Backend/Mock.php         | 25 +++++++++++++++++------
 2 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/tests/Sabre/CardDAV/AddressBookQueryTest.php b/tests/Sabre/CardDAV/AddressBookQueryTest.php
index 7ed94d7..2c3171b 100644
--- a/tests/Sabre/CardDAV/AddressBookQueryTest.php
+++ b/tests/Sabre/CardDAV/AddressBookQueryTest.php
@@ -12,11 +12,11 @@ class AddressBookQueryTest extends AbstractPluginTest {
 
     function testQuery() {
 
-        $request = HTTP\Sapi::createFromServerArray([
-            'REQUEST_METHOD' => 'REPORT',
-            'REQUEST_URI'    => '/addressbooks/user1/book1',
-            'HTTP_DEPTH'     => '1',
-        ]);
+        $request = new HTTP\Request(
+            'REPORT',
+            '/addressbooks/user1/book1',
+            ['Depth' => '1']
+        );
 
         $request->setBody(
 '<?xml version="1.0"?>
@@ -62,11 +62,11 @@ class AddressBookQueryTest extends AbstractPluginTest {
 
     function testQueryDepth0() {
 
-        $request = HTTP\Sapi::createFromServerArray([
-            'REQUEST_METHOD' => 'REPORT',
-            'REQUEST_URI'    => '/addressbooks/user1/book1/card1',
-            'HTTP_DEPTH'     => '0',
-        ]);
+        $request = new HTTP\Request(
+            'REPORT',
+            '/addressbooks/user1/book1/card1',
+            ['Depth' => '0']
+        );
 
         $request->setBody(
 '<?xml version="1.0"?>
@@ -107,11 +107,11 @@ class AddressBookQueryTest extends AbstractPluginTest {
 
     function testQueryNoMatch() {
 
-        $request = HTTP\Sapi::createFromServerArray([
-            'REQUEST_METHOD' => 'REPORT',
-            'REQUEST_URI'    => '/addressbooks/user1/book1',
-            'HTTP_DEPTH'     => '1',
-        ]);
+        $request = new HTTP\Request(
+            'REPORT',
+            '/addressbooks/user1/book1',
+            ['Depth' => '1']
+        );
 
         $request->setBody(
 '<?xml version="1.0"?>
diff --git a/tests/Sabre/CardDAV/Backend/Mock.php b/tests/Sabre/CardDAV/Backend/Mock.php
index ba6da4d..840b898 100644
--- a/tests/Sabre/CardDAV/Backend/Mock.php
+++ b/tests/Sabre/CardDAV/Backend/Mock.php
@@ -124,12 +124,19 @@ class Mock extends AbstractBackend {
 
         $cards = [];
         foreach ($this->cards[$addressBookId] as $uri => $data) {
-            $cards[] = [
-                'uri'      => $uri,
-                'carddata' => $data,
-                'etag'     => '"' . md5($data) . '"',
-                'size'     => strlen($data)
-            ];
+            if (is_resource($data)) {
+                $cards[] = [
+                    'uri'      => $uri,
+                    'carddata' => $data,
+                ];
+            } else {
+                $cards[] = [
+                    'uri'      => $uri,
+                    'carddata' => $data,
+                    'etag'     => '"' . md5($data) . '"',
+                    'size'     => strlen($data)
+                ];
+            }
         }
         return $cards;
 
@@ -190,6 +197,9 @@ class Mock extends AbstractBackend {
      */
     function createCard($addressBookId, $cardUri, $cardData) {
 
+        if (is_resource($cardData)) {
+            $cardData = stream_get_contents($cardData);
+        }
         $this->cards[$addressBookId][$cardUri] = $cardData;
         return '"' . md5($cardData) . '"';
 
@@ -222,6 +232,9 @@ class Mock extends AbstractBackend {
      */
     function updateCard($addressBookId, $cardUri, $cardData) {
 
+        if (is_resource($cardData)) {
+            $cardData = stream_get_contents($cardData);
+        }
         $this->cards[$addressBookId][$cardUri] = $cardData;
         return '"' . md5($cardData) . '"';
 

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



More information about the Pkg-owncloud-commits mailing list