diff options
author | Yalçın Can <ylcncn@gmail.com> | 2011-07-27 14:23:37 +0300 |
---|---|---|
committer | Yalçın Can <ylcncn@gmail.com> | 2011-07-27 14:23:37 +0300 |
commit | efd842174fdd37f8eb2c460c7adb21954bcfbe9d (patch) | |
tree | a2ab3cc25db92b901b69ce1bc0ad1dedb5d498ef /tests/www/bookmarksTest.php | |
parent | 8cd40b3d76e191b2fbe95b044f69aed07cc27664 (diff) | |
parent | 81aa17b8523d95310c90366d9af09767db0c84f2 (diff) | |
download | semanticscuttle-efd842174fdd37f8eb2c460c7adb21954bcfbe9d.tar.gz semanticscuttle-efd842174fdd37f8eb2c460c7adb21954bcfbe9d.tar.bz2 |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'tests/www/bookmarksTest.php')
-rwxr-xr-x | tests/www/bookmarksTest.php | 92 |
1 files changed, 70 insertions, 22 deletions
diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php index df360cc..ae82118 100755 --- a/tests/www/bookmarksTest.php +++ b/tests/www/bookmarksTest.php @@ -4,7 +4,7 @@ require_once 'HTTP/Request2.php'; class www_bookmarksTest extends TestBaseApi { - protected $urlPart = 'api/posts/add'; + protected $urlPart = 'bookmarks.php'; /** * Test that the default privacy setting is selected in the Privacy @@ -16,23 +16,11 @@ class www_bookmarksTest extends TestBaseApi $this->setUnittestConfig( array('defaults' => array('privacy' => 2)) ); - list($req, $uId) = $this->getLoggedInRequest(); - $cookies = $req->getCookieJar(); - $req->setMethod(HTTP_Request2::METHOD_POST); - $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_bookmarksget'); - $req->addPostParameter('description', 'Test bookmark 1 for default privacy.'); - $req->addPostParameter('status', '0'); - $req->send(); - $bms = $this->bs->getBookmarks(0, null, $uId); - $this->assertEquals(1, count($bms['bookmarks'])); + list($req, $uId) = $this->getLoggedInRequest(); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' . $user['username'] . '?action=get' . '&unittestMode=1'; - - list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); $req->setMethod(HTTP_Request2::METHOD_POST); - $req->setUrl($reqUrl); - $req->setCookieJar($cookies); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?action=get')); $req->addPostParameter('submitted', '1'); $response = $req->send(); $response_body = $response->getBody(); @@ -41,12 +29,15 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:select[@name="status"]/ns:option[@selected="selected"]'); + $elements = $x->xpath( + '//ns:select[@name="status"]/ns:option[@selected="selected"]' + ); $this->assertEquals(1, count($elements), 'No selected status option found'); $this->assertEquals(2, (string)$elements[0]['value']); }//end testDefaultPrivacyBookmarksAddMissingTitleMissingPrivacy + /** * Test that the default privacy setting is selected in the Privacy * drop-down list when a new bookmark is being created. @@ -56,13 +47,10 @@ class www_bookmarksTest extends TestBaseApi $this->setUnittestConfig( array('defaults' => array('privacy' => 1)) ); - list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1'); + list($req, $uId) = $this->getLoggedInRequest(); $user = $this->us->getUser($uId); - $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' - . $user['username'] . '?action=add' . '&unittestMode=1'; - $req->setUrl($reqUrl); - $req->setMethod(HTTP_Request2::METHOD_GET); + $req->setUrl($this->getTestUrl('/' . $user['username'] . '?action=add')); $response = $req->send(); $response_body = $response->getBody(); $this->assertNotEquals('', $response_body, 'Response is empty'); @@ -71,10 +59,70 @@ class www_bookmarksTest extends TestBaseApi $ns = $x->getDocNamespaces(); $x->registerXPathNamespace('ns', reset($ns)); - $elements = $x->xpath('//ns:select[@name="status"]/ns:option[@selected="selected"]'); + $elements = $x->xpath( + '//ns:select[@name="status"]/ns:option[@selected="selected"]' + ); $this->assertEquals(1, count($elements), 'No selected status option found'); $this->assertEquals(1, (string)$elements[0]['value']); }//end testDefaultPrivacyBookmarksAdd + + + /** + * Test that the private RSS link exists when a user + * has a private key and is enabled + */ + public function testVerifyPrivateRSSLinkExists() + { + list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1', true, true); + + $user = $this->us->getUser($uId); + $req->setUrl($this->getTestUrl('/' . $user['username'])); + $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); + $req->setUrl($this->getTestUrl('/' . $user['username'])); + $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 ?> |