]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Refined bookmarksTest.php and added indexTest.php
authorMark Pemberton <mpemberton5@gmail.com>
Wed, 8 Jun 2011 02:13:50 +0000 (22:13 -0400)
committerMark Pemberton <mpemberton5@gmail.com>
Wed, 8 Jun 2011 02:13:50 +0000 (22:13 -0400)
tests/www/bookmarksTest.php
tests/www/indexTest.php [new file with mode: 0644]
tests/www/searchTest.php

index eaf78bf849f6d24d5107048270f287113650d13c..1f6d1a5ac8a69b36deceecad4408534e9f42ab8a 100755 (executable)
@@ -98,10 +98,37 @@ class www_bookmarksTest extends TestBaseApi
         $ns = $x->getDocNamespaces();
         $x->registerXPathNamespace('ns', reset($ns));
 
-        $elements = $x->xpath('//ns:link');
-        $this->assertEquals(5, count($elements), 'Number of Links in Head not correct');
-        $this->assertContains('privatekey=', (string)$elements[4]['href']);
+        $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
+        $this->assertEquals(2, count($elements), 'Number of Links in Head not correct');
+        $this->assertContains('privatekey=', (string)$elements[1]['href']);
     }//end testVerifyPrivateRSSLinkExists
 
+
+    /**
+     * Test that the private RSS link doesn't exists when a user
+     * does not have a private key or is not enabled
+     */
+    public function testVerifyPrivateRSSLinkDoesNotExist()
+    {
+        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true);
+
+        $user = $this->us->getUser($uId);
+        $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/'
+            . $user['username'];
+        $req->setUrl($reqUrl);
+        $req->setMethod(HTTP_Request2::METHOD_GET);
+        $response = $req->send();
+        $response_body = $response->getBody();
+        $this->assertNotEquals('', $response_body, 'Response is empty');
+
+        $x = simplexml_load_string($response_body);
+        $ns = $x->getDocNamespaces();
+        $x->registerXPathNamespace('ns', reset($ns));
+
+        $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
+        $this->assertEquals(1, count($elements), 'Number of Links in Head not correct');
+        $this->assertNotContains('privatekey=', (string)$elements[0]['href']);
+    }//end testVerifyPrivateRSSLinkDoesNotExist
+
 }//end class www_bookmarksTest
 ?>
diff --git a/tests/www/indexTest.php b/tests/www/indexTest.php
new file mode 100644 (file)
index 0000000..d95a328
--- /dev/null
@@ -0,0 +1,63 @@
+<?php
+require_once dirname(__FILE__) . '/../prepare.php';
+require_once 'HTTP/Request2.php';
+
+class www_indexTest extends TestBaseApi
+{
+    protected $urlPart = 'api/posts/add';
+
+    /**
+     * Test that the private rss feed exists when user is setup
+     * with a private key and is enabled
+     */
+    public function testVerifyPrivateRSSLinkExists()
+    {
+        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true);
+
+        $user = $this->us->getUser($uId);
+        $reqUrl = $GLOBALS['unittestUrl'] . 'index.php/';
+        $req->setUrl($reqUrl);
+        $req->setMethod(HTTP_Request2::METHOD_GET);
+        $response = $req->send();
+        $response_body = $response->getBody();
+        $this->assertNotEquals('', $response_body, 'Response is empty');
+
+        $x = simplexml_load_string($response_body);
+        $ns = $x->getDocNamespaces();
+        $x->registerXPathNamespace('ns', reset($ns));
+
+        $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
+        $this->assertEquals(2, count($elements), 'Number of Links in Head not correct');
+        $this->assertContains('privatekey=', (string)$elements[1]['href']);
+    }//end testVerifyPrivateRSSLinkExists
+
+
+    /**
+     * Test that the private RSS link doesn't exists when a user
+     * does not have a private key or is not enabled
+     */
+    public function testVerifyPrivateRSSLinkDoesNotExist()
+    {
+        list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true);
+
+        $user = $this->us->getUser($uId);
+        $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/'
+            . $user['username'];
+        $req->setUrl($reqUrl);
+        $req->setMethod(HTTP_Request2::METHOD_GET);
+        $response = $req->send();
+        $response_body = $response->getBody();
+        $this->assertNotEquals('', $response_body, 'Response is empty');
+
+        $x = simplexml_load_string($response_body);
+        $ns = $x->getDocNamespaces();
+        $x->registerXPathNamespace('ns', reset($ns));
+
+        $elements = $x->xpath('//ns:link[@rel="alternate" and @type="application/rss+xml"]');
+        $this->assertEquals(1, count($elements), 'Number of Links in Head not correct');
+        $this->assertNotContains('privatekey=', (string)$elements[0]['href']);
+    }//end testVerifyPrivateRSSLinkDoesNotExist
+
+
+}//end class www_bookmarksTest
+?>
index 5dce69d01b4cbdfd8ecad7ac29595dfe27f03059..89af32d3ddb70c60c8998c2f3b1b9f022c101c32 100644 (file)
@@ -1,4 +1,6 @@
 <?php
+require_once dirname(__FILE__) . '/../prepare.php';
+require_once 'HTTP/Request2.php';
 
 class www_SearchTest extends TestBaseApi
 {
@@ -65,4 +67,4 @@ class www_SearchTest extends TestBaseApi
 
 }
 
-?>
\ No newline at end of file
+?>