From 045d139d64ada2c510ed05e177ba6f484ad68496 Mon Sep 17 00:00:00 2001 From: Mark Pemberton Date: Wed, 15 Jun 2011 00:58:29 -0400 Subject: Added RSS Feed tests --- tests/www/rssTest.php | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 tests/www/rssTest.php (limited to 'tests/www/rssTest.php') diff --git a/tests/www/rssTest.php b/tests/www/rssTest.php new file mode 100644 index 0000000..1822fc9 --- /dev/null +++ b/tests/www/rssTest.php @@ -0,0 +1,94 @@ +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 +?> -- cgit v1.2.3