[Pkg-owncloud-commits] [php-sabredav] 98/148: A few more tests.

David Prévot taffit at moszumanska.debian.org
Wed Apr 15 01:37:22 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 12c2816dbdb4707c2f9df51ef33dcfeb60f4cb33
Author: Evert Pot <me at evertpot.com>
Date:   Tue Mar 31 15:34:29 2015 -0400

    A few more tests.
---
 lib/CalDAV/Subscriptions/Plugin.php             | 34 ++++++++++++++++++
 lib/CalDAV/Subscriptions/Subscription.php       | 21 -----------
 tests/Sabre/CalDAV/ICSExportPluginTest.php      | 47 ++++++++++++++++++++++---
 tests/Sabre/CalDAV/Subscriptions/PluginTest.php |  5 +++
 tests/Sabre/DAVACL/SimplePluginTest.php         |  5 +++
 5 files changed, 87 insertions(+), 25 deletions(-)

diff --git a/lib/CalDAV/Subscriptions/Plugin.php b/lib/CalDAV/Subscriptions/Plugin.php
index e71c026..2372f99 100644
--- a/lib/CalDAV/Subscriptions/Plugin.php
+++ b/lib/CalDAV/Subscriptions/Plugin.php
@@ -82,4 +82,38 @@ class Plugin extends ServerPlugin {
 
     }
 
+    /**
+     * Returns a plugin name.
+     *
+     * Using this name other plugins will be able to access other plugins
+     * using \Sabre\DAV\Server::getPlugin
+     *
+     * @return string
+     */
+    function getPluginName() {
+
+        return 'subscriptions';
+
+    }
+
+    /**
+     * Returns a bunch of meta-data about the plugin.
+     *
+     * Providing this information is optional, and is mainly displayed by the
+     * Browser plugin.
+     *
+     * The description key in the returned array may contain html and will not
+     * be sanitized.
+     *
+     * @return array
+     */
+    function getPluginInfo() {
+
+        return [
+            'name'        => $this->getPluginName(),
+            'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.',
+            'link'        => null,
+        ];
+
+    }
 }
diff --git a/lib/CalDAV/Subscriptions/Subscription.php b/lib/CalDAV/Subscriptions/Subscription.php
index d94f4a2..562aa4a 100644
--- a/lib/CalDAV/Subscriptions/Subscription.php
+++ b/lib/CalDAV/Subscriptions/Subscription.php
@@ -274,25 +274,4 @@ class Subscription extends Collection implements ISubscription, IACL {
 
     }
 
-    /**
-     * Returns a bunch of meta-data about the plugin.
-     *
-     * Providing this information is optional, and is mainly displayed by the
-     * Browser plugin.
-     *
-     * The description key in the returned array may contain html and will not
-     * be sanitized.
-     *
-     * @return array
-     */
-    function getPluginInfo() {
-
-        return [
-            'name'        => $this->getPluginName(),
-            'description' => 'This plugin allows users to store iCalendar subscriptions in their calendar-home.',
-            'link'        => null,
-        ];
-
-    }
-
 }
diff --git a/tests/Sabre/CalDAV/ICSExportPluginTest.php b/tests/Sabre/CalDAV/ICSExportPluginTest.php
index 76044f1..9fb7c17 100644
--- a/tests/Sabre/CalDAV/ICSExportPluginTest.php
+++ b/tests/Sabre/CalDAV/ICSExportPluginTest.php
@@ -582,18 +582,18 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $cbackend = TestUtil::getBackend();
         $pbackend = new DAVACL\PrincipalBackend\Mock();
 
-        $props = array(
+        $props = [
             'uri'=>'UUID-123467',
             'principaluri' => 'admin',
             'id' => 1,
-        );
+        ];
         // add a todo to the calendar (see /tests/Sabre/TestUtil)
         $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO());
 
-        $tree = array(
+        $tree = [
             new Calendar($cbackend,$props),
             new DAVACL\PrincipalCollection($pbackend),
-        );
+        ];
 
         $p = new ICSExportPlugin();
 
@@ -620,4 +620,43 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals(1,count($obj->VTODO));
 
     }
+
+    function testFilterComponentBadComponent() {
+
+        $cbackend = TestUtil::getBackend();
+        $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+        $props = [
+            'uri'=>'UUID-123467',
+            'principaluri' => 'admin',
+            'id' => 1,
+        ];
+        // add a todo to the calendar (see /tests/Sabre/TestUtil)
+        $cbackend->createCalendarObject(1, 'UUID-3456', TestUtil::getTestTODO());
+
+        $tree = [
+            new Calendar($cbackend,$props),
+            new DAVACL\PrincipalCollection($pbackend),
+        ];
+
+        $p = new ICSExportPlugin();
+
+        $s = new DAV\Server($tree);
+        $s->sapi = new HTTP\SapiMock();
+        $s->addPlugin($p);
+        $s->addPlugin(new Plugin());
+
+        $h = HTTP\Sapi::createFromServerArray([
+            'REQUEST_URI' => '/UUID-123467?export&componentType=VVOODOO',
+            'REQUEST_METHOD' => 'GET',
+        ]);
+
+        $s->httpRequest = $h;
+        $s->httpResponse = new HTTP\ResponseMock();
+
+        $s->exec();
+
+        $this->assertEquals(400, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+
+    }
 }
diff --git a/tests/Sabre/CalDAV/Subscriptions/PluginTest.php b/tests/Sabre/CalDAV/Subscriptions/PluginTest.php
index 4f82cb5..beed601 100644
--- a/tests/Sabre/CalDAV/Subscriptions/PluginTest.php
+++ b/tests/Sabre/CalDAV/Subscriptions/PluginTest.php
@@ -27,6 +27,11 @@ class PluginTest extends \PHPUnit_Framework_TestCase {
             $plugin->getFeatures()
         );
 
+        $this->assertEquals(
+            'subscriptions',
+            $plugin->getPluginInfo()['name']
+        );
+
     }
 
     function testPropFind() {
diff --git a/tests/Sabre/DAVACL/SimplePluginTest.php b/tests/Sabre/DAVACL/SimplePluginTest.php
index 370fac2..67c9240 100644
--- a/tests/Sabre/DAVACL/SimplePluginTest.php
+++ b/tests/Sabre/DAVACL/SimplePluginTest.php
@@ -30,6 +30,11 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase {
 
         $this->assertEquals(array('ACL'), $aclPlugin->getMethods(''));
 
+
+        $this->assertEquals(
+            'acl',
+            $aclPlugin->getPluginInfo()['name']
+        );
     }
 
     function testGetFlatPrivilegeSet() {

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