From eaa62a6c450a05295618e98fc41ae1d4d7f720d0 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Wed, 30 Mar 2011 22:03:39 -0700 Subject: Adding directory and files for test data. --- tests/data/BookmarkTest_netscapebookmarks.html | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 tests/data/BookmarkTest_netscapebookmarks.html (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html new file mode 100755 index 0000000..3e1bd7d --- /dev/null +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -0,0 +1,27 @@ + + + + +Bookmarks for dpuser + +

Bookmarks for dpuser

+ + +

+ +

Test bookmark 3 for default privacy. +
Test bookmark 4 for default privacy. +
Test bookmark 5 for default privacy. +
This bookmark will be ignored by importNetscape.php. + +

+ +

+ + + +

-- cgit v1.2.3 From 675eadd584e264ba92091579bbc1166dcf3a5715 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Thu, 31 Mar 2011 15:59:44 -0700 Subject: Updates for configurable-privacy2, hopefully without carriage returns. --- data/config.php.dist | 6 -- data/templates/bookmarks.tpl.php | 2 +- tests/BookmarkTest.php | 97 +++++++++++++++++++++++--- tests/data/BookmarkTest_deliciousbookmarks.xml | 2 +- tests/data/BookmarkTest_netscapebookmarks.html | 2 +- 5 files changed, 89 insertions(+), 20 deletions(-) (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/data/config.php.dist b/data/config.php.dist index 0f849e2..302d55f 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -7,12 +7,6 @@ * See config.default.inc.php for more options. */ -/** - * Array for defaults. - * - * @var array - */ -$defaults = array(); /** * The name of this site. diff --git a/data/templates/bookmarks.tpl.php b/data/templates/bookmarks.tpl.php index 44dfe90..e32d3c9 100644 --- a/data/templates/bookmarks.tpl.php +++ b/data/templates/bookmarks.tpl.php @@ -256,7 +256,7 @@ if ($currenttag!= '') { foreach ($bookmarks as $key => &$row) { switch ($row['bStatus']) { case 0: - $access = ' public'; + $access = ''; break; case 1: $access = ' shared'; diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index aa0b8c3..e6f2b26 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -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 diff --git a/tests/data/BookmarkTest_deliciousbookmarks.xml b/tests/data/BookmarkTest_deliciousbookmarks.xml index 1c12110..1c3fd8d 100755 --- a/tests/data/BookmarkTest_deliciousbookmarks.xml +++ b/tests/data/BookmarkTest_deliciousbookmarks.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html index 3e1bd7d..c91d20a 100755 --- a/tests/data/BookmarkTest_netscapebookmarks.html +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -1,7 +1,7 @@ -- cgit v1.2.3 From f072059f2de515c0125a9f63ab8476e52c4d4353 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Thu, 31 Mar 2011 16:17:53 -0700 Subject: Revert "Updates for configurable-privacy2, hopefully without carriage returns." This reverts commit 675eadd584e264ba92091579bbc1166dcf3a5715. --- data/config.php.dist | 6 ++ data/templates/bookmarks.tpl.php | 2 +- tests/BookmarkTest.php | 97 +++----------------------- tests/data/BookmarkTest_deliciousbookmarks.xml | 2 +- tests/data/BookmarkTest_netscapebookmarks.html | 2 +- 5 files changed, 20 insertions(+), 89 deletions(-) (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/data/config.php.dist b/data/config.php.dist index 302d55f..0f849e2 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -7,6 +7,12 @@ * See config.default.inc.php for more options. */ +/** + * Array for defaults. + * + * @var array + */ +$defaults = array(); /** * The name of this site. diff --git a/data/templates/bookmarks.tpl.php b/data/templates/bookmarks.tpl.php index e32d3c9..44dfe90 100644 --- a/data/templates/bookmarks.tpl.php +++ b/data/templates/bookmarks.tpl.php @@ -256,7 +256,7 @@ if ($currenttag!= '') { foreach ($bookmarks as $key => &$row) { switch ($row['bStatus']) { case 0: - $access = ''; + $access = ' public'; break; case 1: $access = ' shared'; diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index e6f2b26..aa0b8c3 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -1352,93 +1352,18 @@ class BookmarkTest extends TestBase */ public function testDefaultPrivacy() { - //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'); + $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); $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 diff --git a/tests/data/BookmarkTest_deliciousbookmarks.xml b/tests/data/BookmarkTest_deliciousbookmarks.xml index 1c3fd8d..1c12110 100755 --- a/tests/data/BookmarkTest_deliciousbookmarks.xml +++ b/tests/data/BookmarkTest_deliciousbookmarks.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html index c91d20a..3e1bd7d 100755 --- a/tests/data/BookmarkTest_netscapebookmarks.html +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -1,7 +1,7 @@ -- cgit v1.2.3 From 42942507c416b6a4b5042631f18e6596fdac4dd7 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Thu, 31 Mar 2011 16:18:36 -0700 Subject: Revert "Revert "Updates for configurable-privacy2, hopefully without carriage returns."" This reverts commit f072059f2de515c0125a9f63ab8476e52c4d4353. --- data/config.php.dist | 6 -- data/templates/bookmarks.tpl.php | 2 +- tests/BookmarkTest.php | 97 +++++++++++++++++++++++--- tests/data/BookmarkTest_deliciousbookmarks.xml | 2 +- tests/data/BookmarkTest_netscapebookmarks.html | 2 +- 5 files changed, 89 insertions(+), 20 deletions(-) (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/data/config.php.dist b/data/config.php.dist index 0f849e2..302d55f 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -7,12 +7,6 @@ * See config.default.inc.php for more options. */ -/** - * Array for defaults. - * - * @var array - */ -$defaults = array(); /** * The name of this site. diff --git a/data/templates/bookmarks.tpl.php b/data/templates/bookmarks.tpl.php index 44dfe90..e32d3c9 100644 --- a/data/templates/bookmarks.tpl.php +++ b/data/templates/bookmarks.tpl.php @@ -256,7 +256,7 @@ if ($currenttag!= '') { foreach ($bookmarks as $key => &$row) { switch ($row['bStatus']) { case 0: - $access = ' public'; + $access = ''; break; case 1: $access = ' shared'; diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index aa0b8c3..e6f2b26 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -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 diff --git a/tests/data/BookmarkTest_deliciousbookmarks.xml b/tests/data/BookmarkTest_deliciousbookmarks.xml index 1c12110..1c3fd8d 100755 --- a/tests/data/BookmarkTest_deliciousbookmarks.xml +++ b/tests/data/BookmarkTest_deliciousbookmarks.xml @@ -1,5 +1,5 @@ - + diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html index 3e1bd7d..c91d20a 100755 --- a/tests/data/BookmarkTest_netscapebookmarks.html +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -1,7 +1,7 @@ -- cgit v1.2.3 From a0ca39837263bf0ca112c964e8c4d62e0378a399 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Thu, 31 Mar 2011 16:42:44 -0700 Subject: Trying to remove carriage returns from test data. --- tests/data/BookmarkTest_deliciousbookmarks.xml | 7 ------- tests/data/BookmarkTest_netscapebookmarks.html | 27 -------------------------- 2 files changed, 34 deletions(-) (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/tests/data/BookmarkTest_deliciousbookmarks.xml b/tests/data/BookmarkTest_deliciousbookmarks.xml index 1c3fd8d..e69de29 100755 --- a/tests/data/BookmarkTest_deliciousbookmarks.xml +++ b/tests/data/BookmarkTest_deliciousbookmarks.xml @@ -1,7 +0,0 @@ - - - - - - - diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html index c91d20a..e69de29 100755 --- a/tests/data/BookmarkTest_netscapebookmarks.html +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -1,27 +0,0 @@ - - - - -Bookmarks for dpuser - -

Bookmarks for dpuser

- - -

- -

Test bookmark 3 for default privacy. -
Test bookmark 4 for default privacy. -
Test bookmark 5 for default privacy. -
This bookmark will be ignored by importNetscape.php. - -

- -

- - - -

-- cgit v1.2.3 From 1aa20d38ca2833287ae3cd46b78dc000aea93732 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Thu, 31 Mar 2011 16:49:21 -0700 Subject: Re-adding test data without carriage returns. --- tests/data/BookmarkTest_deliciousbookmarks.xml | 7 +++++++ tests/data/BookmarkTest_netscapebookmarks.html | 27 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/tests/data/BookmarkTest_deliciousbookmarks.xml b/tests/data/BookmarkTest_deliciousbookmarks.xml index e69de29..d2bcfc5 100755 --- a/tests/data/BookmarkTest_deliciousbookmarks.xml +++ b/tests/data/BookmarkTest_deliciousbookmarks.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html index e69de29..07c7448 100755 --- a/tests/data/BookmarkTest_netscapebookmarks.html +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -0,0 +1,27 @@ + + + + +Bookmarks for dpuser + +

Bookmarks for dpuser

+ + +

+ +

Test bookmark 3 for default privacy. +
Test bookmark 4 for default privacy. +
Test bookmark 5 for default privacy. +
This bookmark will be ignored by importNetscape.php. + +

+ +

+ + + +

-- cgit v1.2.3 From 3b582fd875de425d91bc143a33dc07e554246a80 Mon Sep 17 00:00:00 2001 From: bretticvs Date: Sun, 17 Apr 2011 17:42:49 -0600 Subject: Moved unit tests to PostsAddTest.php in Api directory. --- tests/Api/PostsAddTest.php | 219 ++++++++++++++++++++++++- tests/BookmarkTest.php | 86 ---------- tests/data/BookmarkTest_deliciousbookmarks.xml | 6 +- tests/data/BookmarkTest_netscapebookmarks.html | 10 +- 4 files changed, 220 insertions(+), 101 deletions(-) (limited to 'tests/data/BookmarkTest_netscapebookmarks.html') diff --git a/tests/Api/PostsAddTest.php b/tests/Api/PostsAddTest.php index f3bb31e..4e2f4fa 100644 --- a/tests/Api/PostsAddTest.php +++ b/tests/Api/PostsAddTest.php @@ -421,6 +421,11 @@ TXT; $this->assertEquals($title2, $data['bookmarks'][0]['bTitle']); } + + /** + * Test that a default privacy setting of 2 (Private) is used in adding + * a bookmark. + */ public function testDefaultPrivacyPrivate() { $this->setUnittestConfig( @@ -428,17 +433,21 @@ TXT; ); list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); $req->setMethod(HTTP_Request2::METHOD_POST); - $req->addPostParameter('url', 'http://www.testdefaultprivacyposts_add1.com'); + $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_addprivate'); $req->addPostParameter('description', 'Test bookmark 1 for default privacy.'); $req->send(); - $this->us->setCurrentUserId($uId); $bms = $this->bs->getBookmarks(0, null, $uId); $this->assertEquals(1, count($bms['bookmarks'])); $bm = reset($bms['bookmarks']); $this->assertEquals('2', $bm['bStatus']); - } + }//end testDefaultPrivacyPrivate + + /** + * Test that a default privacy setting of 0 (Public) is used in adding + * a bookmark. + */ public function testDefaultPrivacyPublic() { $this->setUnittestConfig( @@ -446,19 +455,215 @@ TXT; ); list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); $req->setMethod(HTTP_Request2::METHOD_POST); - $req->addPostParameter('url', 'http://www.testdefaultprivacyposts_add1.com'); + $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_addpublic'); $req->addPostParameter('description', 'Test bookmark 1 for default privacy.'); $req->send(); - $this->us->setCurrentUserId($uId); $bms = $this->bs->getBookmarks(0, null, $uId); $this->assertEquals(1, count($bms['bookmarks'])); $bm = reset($bms['bookmarks']); $this->assertEquals('0', $bm['bStatus']); - } + }//end testDefaultPrivacyPublic + + + /** + * Test that the default privacy setting is used when an existing + * bookmark is updated with edit.php. + */ + public function testDefaultPrivacyEdit() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_edit'); + $req->addPostParameter('description', 'Test bookmark 2 for default privacy.'); + $req->addPostParameter('status', '0'); + $req->send(); + $bms = $this->bs->getBookmarks(0, null, $uId); + $bm = reset($bms['bookmarks']); + $bmId = $bm['bId']; + $oldUid = $uId; + $reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1'; + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($reqUrl); + $testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login'; + $userinfo = $this->us->getUser($oldUid); + $testcookiepassword = $userinfo['password']; + $testusername = $userinfo['username']; + $testcookievalue = $oldUid . ':' . md5($testusername . $testcookiepassword); + $req->setCookieJar(true); + $req->addCookie($testcookiekey, $testcookievalue); + $req->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit'); + $req->addPostParameter('title', 'Test bookmark 2 for default privacy.'); + $req->addPostParameter('submitted', '1'); + $req->send(); + $bm = $this->bs->getBookmark($bmId); + $this->assertEquals('2', $bm['bStatus']); + }//end testDefaultPrivacyEdit + + + /** + * Test that the default privacy setting is used when bookmarks + * are imported from an HTML bookmarks file using importNetscape.php. + */ + public function testDefaultPrivacyImportNetscape() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 1)) + ); + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($GLOBALS['unittestUrl'] . 'importNetscape.php' . '?unittestMode=1'); + $testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login'; + $userinfo = $this->us->getUser($uId); + $testcookiepassword = $userinfo['password']; + $testusername = $userinfo['username']; + $testcookievalue = $uId . ':' . md5($testusername . $testcookiepassword); + $req->setCookieJar(true); + $req->addCookie($testcookiekey, $testcookievalue); + $req->addUpload('userfile', '../data/BookmarkTest_netscapebookmarks.html'); + $req->send(); + $this->us->setCurrentUserId($uId); + $bms = $this->bs->getBookmarks(0, null, $uId); + $this->assertEquals(3, count($bms['bookmarks'])); + $bm = reset($bms['bookmarks']); + $this->assertEquals('1', $bm['bStatus']); + }//end testDefaultPrivacyImportNetscape + + + /** + * Test that the default privacy setting is used when bookmarks + * are imported from an XML bookmarks file using import.php. + */ + public function testDefaultPrivacyImport() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($GLOBALS['unittestUrl'] . 'import.php' . '?unittestMode=1'); + $testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login'; + $userinfo = $this->us->getUser($uId); + $testcookiepassword = $userinfo['password']; + $testusername = $userinfo['username']; + $testcookievalue = $uId . ':' . md5($testusername . $testcookiepassword); + $req->setCookieJar(true); + $req->addCookie($testcookiekey, $testcookievalue); + $req->addUpload('userfile', '../data/BookmarkTest_deliciousbookmarks.xml'); + $req->send(); + $this->us->setCurrentUserId($uId); + $bms = $this->bs->getBookmarks(0, null, $uId); + $this->assertEquals(3, count($bms['bookmarks'])); + $bm = reset($bms['bookmarks']); + $this->assertEquals('2', $bm['bStatus']); + }//end testDefaultPrivacyImport + + + /** + * Test that the default privacy setting is selected in the Privacy + * drop-down list when an existing bookmark is accessed with bookmarks.php + * and the get action. + */ + public function testDefaultPrivacyBookmarksGet() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 2)) + ); + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $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'])); + $bm = reset($bms['bookmarks']); + $bmId = $bm['bId']; + $oldUid = $uId; + $user = $this->us->getUser($uId); + $userId = $user['username']; + $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' . $userId . '?action=get' . '&unittestMode=1'; + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($reqUrl); + $testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login'; + $userinfo = $this->us->getUser($oldUid); + $testcookiepassword = $userinfo['password']; + $testusername = $userinfo['username']; + $testcookievalue = $oldUid . ':' . md5($testusername . $testcookiepassword); + $req->setCookieJar(true); + $req->addCookie($testcookiekey, $testcookievalue); + $req->addPostParameter('submitted', '1'); + $response = $req->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 testDefaultPrivacyBookmarksGet + + + /** + * Test that the default privacy setting is selected in the Privacy + * drop-down list when an existing bookmark is accessed with bookmarks.php + * and the add action. + */ + public function testDefaultPrivacyBookmarksAdd() + { + $this->setUnittestConfig( + array('defaults' => array('privacy' => 1)) + ); + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_bookmarksadd'); + $req->addPostParameter('description', 'Test bookmark 2 for default privacy.'); + $req->addPostParameter('status', '0'); + $req->send(); + $bms = $this->bs->getBookmarks(0, null, $uId); + $this->assertEquals(1, count($bms['bookmarks'])); + $bm = reset($bms['bookmarks']); + $bmId = $bm['bId']; + $oldUid = $uId; + $user = $this->us->getUser($uId); + $userId = $user['username']; + $reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' . $userId . '?action=add' . '&unittestMode=1'; + list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); + $req->setMethod(HTTP_Request2::METHOD_POST); + $req->setUrl($reqUrl); + $testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login'; + $userinfo = $this->us->getUser($oldUid); + $testcookiepassword = $userinfo['password']; + $testusername = $userinfo['username']; + $testcookievalue = $oldUid . ':' . md5($testusername . $testcookiepassword); + $req->setCookieJar(true); + $req->addCookie($testcookiekey, $testcookievalue); + $req->addPostParameter('submitted', '1'); + $response = $req->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('1', $selected_privacy); + }//end testDefaultPrivacyBookmarksAdd + + } if (PHPUnit_MAIN_METHOD == 'Api_PostsAddTest::main') { Api_PostsAddTest::main(); } -?> \ No newline at end of file +?> diff --git a/tests/BookmarkTest.php b/tests/BookmarkTest.php index ad1cb48..f54fe9a 100644 --- a/tests/BookmarkTest.php +++ b/tests/BookmarkTest.php @@ -1343,92 +1343,6 @@ class BookmarkTest extends TestBase } - /** - * Test that the default privacy setting in - * $GLOBALS['defaults']['privacy'] is used - * as expected. - * - * @return void - */ - public function testDefaultPrivacy() - { - //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/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 - - } diff --git a/tests/data/BookmarkTest_deliciousbookmarks.xml b/tests/data/BookmarkTest_deliciousbookmarks.xml index d2bcfc5..87c67dc 100755 --- a/tests/data/BookmarkTest_deliciousbookmarks.xml +++ b/tests/data/BookmarkTest_deliciousbookmarks.xml @@ -1,7 +1,7 @@ - - - + + + diff --git a/tests/data/BookmarkTest_netscapebookmarks.html b/tests/data/BookmarkTest_netscapebookmarks.html index 07c7448..305662c 100755 --- a/tests/data/BookmarkTest_netscapebookmarks.html +++ b/tests/data/BookmarkTest_netscapebookmarks.html @@ -6,16 +6,16 @@ It will be read and overwritten. Do Not Edit! --> -Bookmarks for dpuser +Bookmarks for testuser -

Bookmarks for dpuser

+

Bookmarks for testuser

-

Test bookmark 3 for default privacy. -
Test bookmark 4 for default privacy. -
Test bookmark 5 for default privacy. +
Test bookmark 1 for default privacy. +
Test bookmark 2 for default privacy. +
Test bookmark 3 for default privacy.
This bookmark will be ignored by importNetscape.php.

-- cgit v1.2.3