summaryrefslogtreecommitdiff
path: root/tests/www/bookmarksTest.php
diff options
context:
space:
mode:
authorbretticvs <bsdee@frii.com>2011-05-05 16:24:21 -0600
committerbretticvs <bsdee@frii.com>2011-05-05 16:24:21 -0600
commitfc093a5fe51d35a2991e549e8836cac15dc2888b (patch)
tree3606d2acbcbf1d204ace13d8d610830eb1a8878d /tests/www/bookmarksTest.php
parent8be81abfe6193e221afcdc35582d34505797a7b8 (diff)
downloadsemanticscuttle-fc093a5fe51d35a2991e549e8836cac15dc2888b.tar.gz
semanticscuttle-fc093a5fe51d35a2991e549e8836cac15dc2888b.tar.bz2
Moved testDefaultPrivacyEdit() to tests/www/editTest.php.
Moved testDefaultPrivacyImportNetscape() to tests/www/importNetscapeTest.php. Moved testDefaultPrivacyImport() to tests/www/importTest.php. Moved testDefaultPrivacyBookmarksAddMissingTitleMissingPrivacy() to tests/www/bookmarksTest.php. Moved testDefaultPrivacyBookmarksAdd() to tests/www/bookmarksTest.php. Kept testDefaultPrivacyPrivate() in tests/api/PostsAddTest.php. Kept testDefaultPrivacyPublic() in tests/api/PostsAddTest.php.
Diffstat (limited to 'tests/www/bookmarksTest.php')
-rwxr-xr-xtests/www/bookmarksTest.php80
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/www/bookmarksTest.php b/tests/www/bookmarksTest.php
new file mode 100755
index 0000000..df360cc
--- /dev/null
+++ b/tests/www/bookmarksTest.php
@@ -0,0 +1,80 @@
+<?php
+require_once dirname(__FILE__) . '/../prepare.php';
+require_once 'HTTP/Request2.php';
+
+class www_bookmarksTest extends TestBaseApi
+{
+ protected $urlPart = 'api/posts/add';
+
+ /**
+ * Test that the default privacy setting is selected in the Privacy
+ * drop-down list when adding a new bookmark, sending the form and
+ * missing the title and the privacy setting.
+ */
+ public function testDefaultPrivacyBookmarksAddMissingTitleMissingPrivacy()
+ {
+ $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']));
+ $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->addPostParameter('submitted', '1');
+ $response = $req->send();
+ $response_body = $response->getBody();
+
+ $x = simplexml_load_string($response_body);
+ $ns = $x->getDocNamespaces();
+ $x->registerXPathNamespace('ns', reset($ns));
+
+ $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.
+ */
+ public function testDefaultPrivacyBookmarksAdd()
+ {
+ $this->setUnittestConfig(
+ array('defaults' => array('privacy' => 1))
+ );
+ list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
+
+ $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);
+ $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: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
+
+}//end class www_bookmarksTest
+?>