]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Added RSS Feed tests
authorMark Pemberton <mpemberton5@gmail.com>
Wed, 15 Jun 2011 04:58:29 +0000 (00:58 -0400)
committerMark Pemberton <mpemberton5@gmail.com>
Wed, 15 Jun 2011 04:58:29 +0000 (00:58 -0400)
tests/TestBaseApi.php
tests/www/rssTest.php [new file with mode: 0644]

index 50a2413361569702942ef2fe44f9be6924b5a484..f860d106413538f4c5b06ca574ab0dccfe1d4332 100644 (file)
@@ -187,7 +187,8 @@ class TestBaseApi extends TestBase
      * @uses getRequest()
      */
     protected function getLoggedInRequest(
-        $urlSuffix = null, $auth = true, $privateKey = false
+        $urlSuffix = null, $auth = true, $privateKey = false,
+        $setCookie = true
     ) {
         if (is_array($auth)) {
             list($username, $password) = $auth;
@@ -217,7 +218,9 @@ class TestBaseApi extends TestBase
         $this->assertEquals(302, $res->getStatus(), 'Login failure');
 
         $req = $this->getRequest($urlSuffix);
-        $req->setCookieJar($cookies);
+        if ($setCookie) {
+            $req->setCookieJar($cookies);
+        }
 
         return array($req, $uid);
     }
diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php
new file mode 100644 (file)
index 0000000..1822fc9
--- /dev/null
@@ -0,0 +1,94 @@
+<?php
+require_once dirname(__FILE__) . '/../prepare.php';
+require_once 'HTTP/Request2.php';
+
+class www_rssTest extends TestBaseApi
+{
+    protected $urlPart = 'rss.php';
+
+    /**
+     * Test a user who does not have RSS private key enabled
+     * and with a private bookmark.
+     */
+    public function testNoRSSPrivateKeyEnabled()
+    {
+        $this->setUnittestConfig(
+            array('defaults' => array('privacy' => 2))
+        );
+
+        /* create user without RSS private Key */
+        list($req, $uId) = $this->getLoggedInRequest(null, true, false, false);
+
+        /* create private bookmark */
+        $this->bs->addBookmark(
+            'http://test', 'test', 'desc', 'note',
+            2,//private
+            array(), null, null, false, false, $uId
+        );
+        /* create public bookmark */
+        $this->bs->addBookmark(
+            'http://example.org', 'title', 'desc', 'priv',
+            0,//public
+            array(), null, null, false, false, $uId
+        );
+
+        /* get user details */
+        $user = $this->us->getUser($uId);
+
+        $req->setMethod(HTTP_Request2::METHOD_POST);
+        $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc'));
+        $response = $req->send();
+        $response_body = $response->getBody();
+
+        $rss = simplexml_load_string($response_body);
+        $items = $rss->channel->item;
+
+        $this->assertEquals(1, count($items), 'Incorrect Number of RSS Items');
+        $this->assertEquals('title', (string)$items[0]->title);
+    }//end testNoRSSPrivateKeyEnabled
+
+
+    /**
+     * Test a user who has RSS private key setup
+     * with private bookmark.
+     */
+    public function testRSSPrivateKeyEnabled()
+    {
+        $this->setUnittestConfig(
+            array('defaults' => array('privacy' => 2))
+        );
+
+        /* create user with RSS private Key */
+        list($req, $uId) = $this->getLoggedInRequest(null, true, false, true);
+
+        /* create private bookmark */
+        $this->bs->addBookmark(
+            'http://test', 'test', 'desc', 'note',
+            2,//private
+            array(), null, null, false, false, $uId
+        );
+        /* create public bookmark */
+        $this->bs->addBookmark(
+            'http://example.org', 'title', 'desc', 'priv',
+            0,//public
+            array(), null, null, false, false, $uId
+        );
+
+        /* get user details */
+        $user = $this->us->getUser($uId);
+
+        $req->setMethod(HTTP_Request2::METHOD_POST);
+        $req->setUrl($this->getTestUrl('/' . $user['username'] . '?sort=date_desc&privatekey=' . $user['privatekey']));
+        $response = $req->send();
+        $response_body = $response->getBody();
+
+        $rss = simplexml_load_string($response_body);
+        $items = $rss->channel->item;
+
+        $this->assertEquals(2, count($items), 'Incorrect Number of RSS Items');
+    }//end testRSSPrivateKeyEnabled
+
+
+
+}//end class www_rssTest
+?>