[Pkg-owncloud-commits] [php-sabredav] 38/64: unit test for component filter in ICSExportPlugin

David Prévot taffit at moszumanska.debian.org
Thu Dec 11 15:13:25 UTC 2014


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

taffit pushed a commit to tag 2.2.0alpha1
in repository php-sabredav.

commit 26fec2387fc28c011f265fdec53fe162facbfff1
Author: Armin Hackmann <armin at fruux.com>
Date:   Tue Nov 25 15:01:24 2014 +0100

    unit test for component filter in ICSExportPlugin
---
 tests/Sabre/CalDAV/ICSExportPluginTest.php | 88 ++++++++++++++++++++++++++++++
 1 file changed, 88 insertions(+)

diff --git a/tests/Sabre/CalDAV/ICSExportPluginTest.php b/tests/Sabre/CalDAV/ICSExportPluginTest.php
index 344e582..76044f1 100644
--- a/tests/Sabre/CalDAV/ICSExportPluginTest.php
+++ b/tests/Sabre/CalDAV/ICSExportPluginTest.php
@@ -532,4 +532,92 @@ class ICSExportPluginTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals('text/calendar', $s->httpResponse->getHeader('Content-Type'));
 
     }
+
+    function testFilterComponentVEVENT() {
+
+        $cbackend = TestUtil::getBackend();
+        $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+        $props = array(
+            '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(
+            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=VEVENT',
+            'REQUEST_METHOD' => 'GET',
+        ]);
+
+        $s->httpRequest = $h;
+        $s->httpResponse = new HTTP\ResponseMock();
+
+        $s->exec();
+
+        $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+        $obj = VObject\Reader::read($s->httpResponse->body);
+
+        $this->assertEquals(1,count($obj->VTIMEZONE));
+        $this->assertEquals(1,count($obj->VEVENT));
+        $this->assertEquals(0,count($obj->VTODO));
+
+    }
+
+    function testFilterComponentVTODO() {
+
+        $cbackend = TestUtil::getBackend();
+        $pbackend = new DAVACL\PrincipalBackend\Mock();
+
+        $props = array(
+            '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(
+            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=VTODO',
+            'REQUEST_METHOD' => 'GET',
+        ]);
+
+        $s->httpRequest = $h;
+        $s->httpResponse = new HTTP\ResponseMock();
+
+        $s->exec();
+
+        $this->assertEquals(200, $s->httpResponse->status,'Invalid status received. Response body: '. $s->httpResponse->body);
+        $obj = VObject\Reader::read($s->httpResponse->body);
+
+        $this->assertEquals(0,count($obj->VTIMEZONE));
+        $this->assertEquals(0,count($obj->VEVENT));
+        $this->assertEquals(1,count($obj->VTODO));
+
+    }
 }

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