]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
Updates for configurable-privacy2, hopefully without carriage returns.
authorbretticvs <bsdee@frii.com>
Thu, 31 Mar 2011 22:59:44 +0000 (15:59 -0700)
committerbretticvs <bsdee@frii.com>
Thu, 31 Mar 2011 22:59:44 +0000 (15:59 -0700)
data/config.php.dist
data/templates/bookmarks.tpl.php
tests/BookmarkTest.php
tests/data/BookmarkTest_deliciousbookmarks.xml
tests/data/BookmarkTest_netscapebookmarks.html

index 0f849e2182b41091a8831632dc29ab98f8b36249..302d55f3267e79497ae135bf350e0b650d2b4abe 100644 (file)
@@ -7,12 +7,6 @@
  * See config.default.inc.php for more options.
  */
 
-/**
- * Array for defaults.
- *
- * @var array 
- */
-$defaults = array();
 
 /**
  * The name of this site.
index 44dfe905a800248a7a0be4406667afa2945fb356..e32d3c9e35b52b5d515904f0af78993ccd7516bd 100644 (file)
@@ -256,7 +256,7 @@ if ($currenttag!= '') {
        foreach ($bookmarks as $key => &$row) {
                switch ($row['bStatus']) {
                        case 0:
-                               $access = ' public';
+                               $access = '';
                                break;
                        case 1:
                                $access = ' shared';
index aa0b8c3aa51918d9ae72e3f25ed5ecf3a7728bd0..e6f2b26c4a3461c693742eea850c7cce29df4559 100644 (file)
@@ -1352,18 +1352,93 @@ class BookmarkTest extends TestBase
      */
     public function testDefaultPrivacy()
     {
-        $GLOBALS['defaults']['privacy'] = 1;
-        $uid = $this->addUser();
-        $this->us->setCurrentUserId($uid);
-        $bid = $this->bs->addBookmark('http://www.somedomain.com', 'mybookmark1', 'descr1', 'privatenote1', $GLOBALS['defaults']['privacy'], array());
-        $bm = $this->bs->getBookmark($bid);
-        $this->assertEquals('1', $bm['bStatus']);
-        $GLOBALS['defaults']['privacy'] = 2;
-        $uid = $this->addUser();
-        $this->us->setCurrentUserId($uid);
-        $bid = $this->bs->addBookmark('http://www.anotherdomain.com', 'mybookmark2', 'descr2', 'privatenote2', $GLOBALS['defaults']['privacy'], array());
-        $bm = $this->bs->getBookmark($bid);
+        //For this test, the default privacy has been set to 2 (private) in the configuration file.
+        require_once 'HTTP/Request2.php';
+        require_once dirname(__FILE__) . '/../data/config.php';
+        $this->bs->deleteAll();
+        $this->us->deleteAll();
+        $request = new HTTP_Request2('http://localhost/api/posts_add.php', HTTP_Request2::METHOD_POST);
+        $dpuid = $this->addUser('dpuser', 'dpuserpassword');
+        $request->setAuth('dpuser', 'dpuserpassword'); 
+        $request->addPostParameter('url', 'http://www.testdefaultprivacyposts_add1.com');
+        $request->addPostParameter('description', 'Test bookmark 1 for default privacy.');
+        $request->send();
+        $bm = $this->bs->getBookmark('1');
+        $this->assertEquals('2', $bm['bStatus']);
+
+        $request->addPostParameter('url', 'http://www.testdefaultprivacyposts_add2.com');
+        $request->addPostParameter('description', 'Test bookmark 2 for default privacy.');
+        $request->addPostParameter('status', '0');
+        $request->send();
+
+        $request = new HTTP_Request2('http://localhost/edit.php/2', HTTP_Request2::METHOD_POST);
+        $testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login';
+        $userinfo = $this->us->getUser('1');
+        $testcookiepassword = $userinfo['password'];
+        $testcookievalue = '1:'.md5('dpuser'.$testcookiepassword);
+        $request->setCookieJar(true);
+        $request->addCookie($testcookiekey, $testcookievalue);
+        $request->addPostParameter('title', 'Test bookmark 2 for default privacy.');
+        $request->addPostParameter('address', 'http://www.testdefaultprivacyposts_add2.com');
+        $request->addPostParameter('submitted', '1');
+        $request->send();
+        $bm = $this->bs->getBookmark('2');
         $this->assertEquals('2', $bm['bStatus']);
+
+        $request = new HTTP_Request2('http://localhost/importNetscape.php', HTTP_Request2::METHOD_POST);
+        $request->setCookieJar(true);
+        $request->addCookie($testcookiekey, $testcookievalue);
+        $request->addUpload('userfile', './data/BookmarkTest_netscapebookmarks.html');
+        $request->send();
+        $bm = $this->bs->getBookmark('3');
+        $this->assertEquals('2', $bm['bStatus']);
+        $bm = $this->bs->getBookmark('4');
+        $this->assertEquals('2', $bm['bStatus']);
+        $bm = $this->bs->getBookmark('5');
+        $this->assertEquals('2', $bm['bStatus']);
+
+        $request = new HTTP_Request2('http://localhost/import.php', HTTP_Request2::METHOD_POST);
+        $request->setCookieJar(true);
+        $request->addCookie($testcookiekey, $testcookievalue);
+        $request->addUpload('userfile', './data/BookmarkTest_deliciousbookmarks.xml');
+        $request->send();
+        $bm = $this->bs->getBookmark('6');
+        $this->assertEquals('2', $bm['bStatus']);
+        $bm = $this->bs->getBookmark('7');
+        $this->assertEquals('2', $bm['bStatus']);
+        $bm = $this->bs->getBookmark('8');
+        $this->assertEquals('2', $bm['bStatus']);
+
+        $request = new HTTP_Request2('http://localhost/bookmarks.php/dpuser?action=get', HTTP_Request2::METHOD_POST);
+        $request->setCookieJar(true);
+        $request->addCookie($testcookiekey, $testcookievalue);
+        $request->addPostParameter('submitted', '1');
+        $response = $request->send();
+        $response_body = $response->getBody();
+        $start = strpos($response_body, 'Privacy');
+        $end = strpos($response_body, 'referrer');
+        $length = $end - $start;
+        $response_body = substr($response_body, $start, $length);
+        $start = strpos($response_body, 'selected');
+        $start = $start - 3;
+        $length = 1;
+        $selected_privacy = substr($response_body, $start, $length);
+        $this->assertEquals('2', $selected_privacy);
+
+        $request = new HTTP_Request2('http://localhost/bookmarks.php/dpuser?action=add', HTTP_Request2::METHOD_POST);
+        $request->setCookieJar(true);
+        $request->addCookie($testcookiekey, $testcookievalue);
+        $response = $request->send();
+        $response_body = $response->getBody();
+        $start = strpos($response_body, 'Privacy');
+        $end = strpos($response_body, 'referrer');
+        $length = $end - $start;
+        $response_body = substr($response_body, $start, $length);
+        $start = strpos($response_body, 'selected');
+        $start = $start - 3;
+        $length = 1;
+        $selected_privacy = substr($response_body, $start, $length);
+        $this->assertEquals('2', $selected_privacy);
     }//end function testDefaultPrivacy
 
 
index 1c121100bca879d8d4a8d22a31006900980bd608..1c3fd8dbcd8e5b8aa96371ddd12b2c435b94b264 100755 (executable)
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>\r
-<posts user="dpuser" update="2011-03-24T21:09:22Z" tag="" total="3">\r
+<posts user="dpuser" update="2011-03-24T21:09:22Z" tag="" total="3"> \r
   <post href="http://www.testdefaultprivacyposts_add6.com/" hash="4f8533885bb5740b98b6415140a0c8c6" description="Test bookmark 6 for default privacy." tag="tag1, tag2" time="2011-03-24T21:09:11Z" extended="" meta="5c80704730a1bf1b9eb615d4ba7a59bd" />\r
   <post href="http://www.testdefaultprivacyposts_add7.com/" hash="21eee08d7945ac23c4cc2b6d08d02212" description="Test bookmark 7 for default privacy." tag="tag2, tag3" time="2011-03-24T21:08:33Z" extended="" meta="7514ab84f61ba1dd0413572f7c12348d" />\r
   <post href="http://www.testdefaultprivacyposts_add8.com/" hash="cd64042205a083f1cf1e009344daef84" description="Test bookmark 8 for default privacy." tag="tag1, tag2, tag3" time="2011-03-24T21:07:44Z" extended="" meta="9cb24fddbc011e9634595d2f5e1a6537" />\r
index 3e1bd7ddc67d631821b042c0b469eaa409d33a4c..c91d20afc4f021d017aa916aa70a21dd8300e373 100755 (executable)
@@ -1,7 +1,7 @@
 <!DOCTYPE NETSCAPE-Bookmark-file-1>\r
 \r
 <!-- This is an automatically generated file.\r
-\r
\r
 It will be read and overwritten.\r
 \r
 Do Not Edit! -->\r