From cd2756a4d0d18497648deacfb619e227335648ad Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Tue, 7 Jun 2011 22:13:50 -0400 Subject: Refined bookmarksTest.php and added indexTest.php --- tests/www/indexTest.php | 63 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/www/indexTest.php (limited to 'tests/www/indexTest.php') diff --git a/tests/www/indexTest.php b/tests/www/indexTest.php new file mode 100644 index 0000000..d95a328 --- /dev/null +++ b/tests/www/indexTest.php @@ -0,0 +1,63 @@ +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 +?> -- cgit v1.2.3-54-g00ecf