Merge branch 'master' into ssl-client-certs
This commit is contained in:
commit
803b83fb7d
18 changed files with 329 additions and 25 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@ dist/
|
||||||
build.properties
|
build.properties
|
||||||
package.xml
|
package.xml
|
||||||
semanticscuttle-dump.sql
|
semanticscuttle-dump.sql
|
||||||
|
data/config.unittest.php
|
||||||
|
|
|
@ -14,6 +14,13 @@
|
||||||
* @link http://sourceforge.net/projects/semanticscuttle/
|
* @link http://sourceforge.net/projects/semanticscuttle/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Array for defaults.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
$defaults = array();
|
||||||
|
|
||||||
|
|
||||||
/***************************************************
|
/***************************************************
|
||||||
* HTML output configuration
|
* HTML output configuration
|
||||||
|
@ -508,6 +515,16 @@ $votingMode = 2;
|
||||||
*/
|
*/
|
||||||
$hideBelowVoting = null;
|
$hideBelowVoting = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default privacy setting for bookmarks:
|
||||||
|
* 0 - Public
|
||||||
|
* 1 - Shared with Watchlist
|
||||||
|
* 2 - Private
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
$defaults['privacy'] = 0;
|
||||||
|
|
||||||
|
|
||||||
/****************************
|
/****************************
|
||||||
* Website Thumbnails
|
* Website Thumbnails
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
* See config.default.inc.php for more options.
|
* See config.default.inc.php for more options.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of this site.
|
* The name of this site.
|
||||||
*
|
*
|
||||||
|
@ -116,6 +117,21 @@ $adminemail = 'admin@example.org';
|
||||||
$admin_users = array();
|
$admin_users = array();
|
||||||
|
|
||||||
|
|
||||||
|
/***************************************************
|
||||||
|
* Bookmarks
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default privacy setting for bookmarks.
|
||||||
|
* 0 - Public
|
||||||
|
* 1 - Shared with Watchlist
|
||||||
|
* 2 - Private
|
||||||
|
*
|
||||||
|
* @var integer
|
||||||
|
*/
|
||||||
|
$defaults['privacy'] = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* You have completed the basic configuration!
|
* You have completed the basic configuration!
|
||||||
* More options can be found in config.default.php.
|
* More options can be found in config.default.php.
|
||||||
|
|
|
@ -107,7 +107,7 @@ T_bind_textdomain_codeset($domain, 'UTF-8');
|
||||||
T_textdomain($domain);
|
T_textdomain($domain);
|
||||||
|
|
||||||
// 4 // Session
|
// 4 // Session
|
||||||
if (!defined('UNIT_TEST_MODE')) {
|
if (!defined('UNIT_TEST_MODE') || defined('HTTP_UNIT_TEST_MODE')) {
|
||||||
session_start();
|
session_start();
|
||||||
if ($GLOBALS['enableVoting']) {
|
if ($GLOBALS['enableVoting']) {
|
||||||
if (isset($_SESSION['lastUrl'])) {
|
if (isset($_SESSION['lastUrl'])) {
|
||||||
|
|
|
@ -406,5 +406,51 @@ TXT;
|
||||||
$this->assertEquals(1, $data['total']);
|
$this->assertEquals(1, $data['total']);
|
||||||
$this->assertEquals($title2, $data['bookmarks'][0]['bTitle']);
|
$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(
|
||||||
|
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_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(
|
||||||
|
array('defaults' => array('privacy' => 0))
|
||||||
|
);
|
||||||
|
list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
|
||||||
|
$req->setMethod(HTTP_Request2::METHOD_POST);
|
||||||
|
$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
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -49,6 +49,11 @@ class TestBaseApi extends TestBase
|
||||||
}
|
}
|
||||||
$this->url = $GLOBALS['unittestUrl'] . $this->urlPart;
|
$this->url = $GLOBALS['unittestUrl'] . $this->urlPart;
|
||||||
|
|
||||||
|
//clean up before test
|
||||||
|
if (file_exists($GLOBALS['datadir'] . '/config.unittest.php')) {
|
||||||
|
unlink($GLOBALS['datadir'] . '/config.unittest.php');
|
||||||
|
}
|
||||||
|
|
||||||
$this->us = SemanticScuttle_Service_Factory::get('User');
|
$this->us = SemanticScuttle_Service_Factory::get('User');
|
||||||
$this->us->deleteAll();
|
$this->us->deleteAll();
|
||||||
$this->bs = SemanticScuttle_Service_Factory::get('Bookmark');
|
$this->bs = SemanticScuttle_Service_Factory::get('Bookmark');
|
||||||
|
@ -60,19 +65,7 @@ class TestBaseApi extends TestBase
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clean up after test
|
* Creates and returns a HTTP GET request object.
|
||||||
*/
|
|
||||||
public function tearDown()
|
|
||||||
{
|
|
||||||
if (file_exists($GLOBALS['datadir'] . '/config.unittest.php')) {
|
|
||||||
unlink($GLOBALS['datadir'] . '/config.unittest.php');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a HTTP request object.
|
|
||||||
* Uses $this->url plus $urlSuffix as request URL.
|
* Uses $this->url plus $urlSuffix as request URL.
|
||||||
*
|
*
|
||||||
* @param string $urlSuffix Suffix for the URL
|
* @param string $urlSuffix Suffix for the URL
|
||||||
|
@ -111,7 +104,7 @@ class TestBaseApi extends TestBase
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a user and a HTTP request object and prepares
|
* Creates a user and a HTTP GET request object and prepares
|
||||||
* the request object with authentication details, so that
|
* the request object with authentication details, so that
|
||||||
* the user is logged in.
|
* the user is logged in.
|
||||||
*
|
*
|
||||||
|
@ -125,6 +118,7 @@ class TestBaseApi extends TestBase
|
||||||
* @return array(HTTP_Request2, integer) HTTP request object and user id
|
* @return array(HTTP_Request2, integer) HTTP request object and user id
|
||||||
*
|
*
|
||||||
* @uses getRequest()
|
* @uses getRequest()
|
||||||
|
* @see getLoggedInRequest()
|
||||||
*/
|
*/
|
||||||
protected function getAuthRequest($urlSuffix = null, $auth = true)
|
protected function getAuthRequest($urlSuffix = null, $auth = true)
|
||||||
{
|
{
|
||||||
|
@ -147,7 +141,7 @@ class TestBaseApi extends TestBase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a user and a HTTP_Request2 object, does a normal login
|
* Creates a user and a HTTP_Request2 object, does a normal login
|
||||||
* and prepares the cookies for the HTTP request object so that
|
* and prepares the cookies for the HTTP GET request object so that
|
||||||
* the user is seen as logged in when requesting any HTML page.
|
* the user is seen as logged in when requesting any HTML page.
|
||||||
*
|
*
|
||||||
* Useful for testing HTML pages or ajax URLs.
|
* Useful for testing HTML pages or ajax URLs.
|
||||||
|
|
7
tests/data/BookmarkTest_deliciousbookmarks.xml
Executable file
7
tests/data/BookmarkTest_deliciousbookmarks.xml
Executable file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<posts user="dpuser" update="2011-03-24T21:09:22Z" tag="" total="3">
|
||||||
|
<post href="http://www.example.org/testdefaultprivacyposts_import1/" hash="4f8533885bb5740b98b6415140a0c8c6" description="Test bookmark 1 for default privacy." tag="tag1, tag2" time="2011-03-24T21:09:11Z" extended="" meta="5c80704730a1bf1b9eb615d4ba7a59bd" />
|
||||||
|
<post href="http://www.example.org/testdefaultprivacyposts_import2/" hash="21eee08d7945ac23c4cc2b6d08d02212" description="Test bookmark 2 for default privacy." tag="tag2, tag3" time="2011-03-24T21:08:33Z" extended="" meta="7514ab84f61ba1dd0413572f7c12348d" />
|
||||||
|
<post href="http://www.example.org/testdefaultprivacyposts_import3/" hash="cd64042205a083f1cf1e009344daef84" description="Test bookmark 3 for default privacy." tag="tag1, tag2, tag3" time="2011-03-24T21:07:44Z" extended="" meta="9cb24fddbc011e9634595d2f5e1a6537" />
|
||||||
|
</posts>
|
||||||
|
<!-- fe09.api.del.ac4.yahoo.net uncompressed/chunked Thur Mar 24 21:09:33 UTC 2011 -->
|
27
tests/data/BookmarkTest_netscapebookmarks.html
Executable file
27
tests/data/BookmarkTest_netscapebookmarks.html
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
<!DOCTYPE NETSCAPE-Bookmark-file-1>
|
||||||
|
|
||||||
|
<!-- This is an automatically generated file.
|
||||||
|
|
||||||
|
It will be read and overwritten.
|
||||||
|
|
||||||
|
Do Not Edit! -->
|
||||||
|
|
||||||
|
<TITLE>Bookmarks for testuser</TITLE>
|
||||||
|
|
||||||
|
<H1>Bookmarks for testuser</H1>
|
||||||
|
|
||||||
|
|
||||||
|
<DL><p>
|
||||||
|
|
||||||
|
<DT><A HREF="http://www.example.org/testdefaultprivacyposts_importNetscape1" ADD_DATE="1301178264" LAST_VISIT="1301178075" LAST_MODIFIED="1301178075">Test bookmark 1 for default privacy.</A>
|
||||||
|
<DT><A HREF="http://www.example.org/testdefaultprivacyposts_importNetscape2" ADD_DATE="1301178264" LAST_VISIT="1301178075" LAST_MODIFIED="1301178075">Test bookmark 2 for default privacy.</A>
|
||||||
|
<DT><A HREF="http://www.example.org/testdefaultprivacyposts_importNetscape3" ADD_DATE="1301178264" LAST_VISIT="1301178075" LAST_MODIFIED="1301178075">Test bookmark 3 for default privacy.</A>
|
||||||
|
<DT><A HREF="http://www.thisbookmarkwillnotbeadded.com" ADD_DATE="1301178264" LAST_VISIT="1301178075" LAST_MODIFIED="1301178075">This bookmark will be ignored by importNetscape.php.</A>
|
||||||
|
|
||||||
|
</DL><p>
|
||||||
|
|
||||||
|
<DL><p>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</DL><p>
|
|
@ -16,7 +16,9 @@
|
||||||
/**
|
/**
|
||||||
* Prepare the application for unit testing
|
* Prepare the application for unit testing
|
||||||
*/
|
*/
|
||||||
|
//that's needed in constants.php
|
||||||
$_SERVER['HTTP_HOST'] = 'http://localhost/';
|
$_SERVER['HTTP_HOST'] = 'http://localhost/';
|
||||||
|
|
||||||
define('UNIT_TEST_MODE', true);
|
define('UNIT_TEST_MODE', true);
|
||||||
|
|
||||||
if ('@data_dir@' == '@' . 'data_dir@') {
|
if ('@data_dir@' == '@' . 'data_dir@') {
|
||||||
|
|
80
tests/www/bookmarksTest.php
Executable file
80
tests/www/bookmarksTest.php
Executable file
|
@ -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
|
||||||
|
?>
|
48
tests/www/editTest.php
Executable file
48
tests/www/editTest.php
Executable file
|
@ -0,0 +1,48 @@
|
||||||
|
<?php
|
||||||
|
require_once dirname(__FILE__) . '/../prepare.php';
|
||||||
|
require_once 'HTTP/Request2.php';
|
||||||
|
|
||||||
|
class www_editTest extends TestBaseApi
|
||||||
|
{
|
||||||
|
protected $urlPart = 'api/posts/add';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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->getLoggedInRequest('?unittestMode=1');
|
||||||
|
$cookies = $req->getCookieJar();
|
||||||
|
$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');
|
||||||
|
$res = $req->send();
|
||||||
|
$this->assertEquals(
|
||||||
|
200, $res->getStatus(),
|
||||||
|
'Adding bookmark failed: ' . $res->getBody());
|
||||||
|
$bms = $this->bs->getBookmarks(0, null, $uId);
|
||||||
|
$bm = reset($bms['bookmarks']);
|
||||||
|
$bmId = $bm['bId'];
|
||||||
|
|
||||||
|
$reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1';
|
||||||
|
$req2 = new HTTP_Request2($reqUrl, HTTP_Request2::METHOD_POST);
|
||||||
|
$req2->setCookieJar($cookies);
|
||||||
|
$req2->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit');
|
||||||
|
$req2->addPostParameter('title', 'Test bookmark 2 for default privacy.');
|
||||||
|
$req2->addPostParameter('submitted', '1');
|
||||||
|
$res = $req2->send();
|
||||||
|
|
||||||
|
$this->assertEquals(302, $res->getStatus(), 'Editing bookmark failed');
|
||||||
|
|
||||||
|
$bm = $this->bs->getBookmark($bmId);
|
||||||
|
$this->assertEquals('2', $bm['bStatus']);
|
||||||
|
}//end testDefaultPrivacyEdit
|
||||||
|
|
||||||
|
}//end class www_editTest
|
||||||
|
?>
|
33
tests/www/importNetscapeTest.php
Executable file
33
tests/www/importNetscapeTest.php
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
require_once dirname(__FILE__) . '/../prepare.php';
|
||||||
|
require_once 'HTTP/Request2.php';
|
||||||
|
|
||||||
|
class www_importNetscapeTest extends TestBaseApi
|
||||||
|
{
|
||||||
|
protected $urlPart = 'importNetscape.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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->getLoggedInRequest();
|
||||||
|
$req->setMethod(HTTP_Request2::METHOD_POST);
|
||||||
|
$req->setUrl($GLOBALS['unittestUrl'] . 'importNetscape.php' . '?unittestMode=1');
|
||||||
|
$req->addUpload('userfile', dirname(__FILE__) . '/../data/BookmarkTest_netscapebookmarks.html');
|
||||||
|
$res = $req->send();
|
||||||
|
$this->assertEquals(200, $res->getStatus(), 'Bookmark import failed');
|
||||||
|
|
||||||
|
$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
|
||||||
|
|
||||||
|
}//end class www_importNetscapeTest
|
||||||
|
?>
|
33
tests/www/importTest.php
Executable file
33
tests/www/importTest.php
Executable file
|
@ -0,0 +1,33 @@
|
||||||
|
<?php
|
||||||
|
require_once dirname(__FILE__) . '/../prepare.php';
|
||||||
|
require_once 'HTTP/Request2.php';
|
||||||
|
|
||||||
|
class www_importTest extends TestBaseApi
|
||||||
|
{
|
||||||
|
protected $urlPart = 'import.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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->getLoggedInRequest();
|
||||||
|
$req->setMethod(HTTP_Request2::METHOD_POST);
|
||||||
|
$req->setUrl($GLOBALS['unittestUrl'] . 'import.php' . '?unittestMode=1');
|
||||||
|
$req->addUpload('userfile', dirname(__FILE__) . '/../data/BookmarkTest_deliciousbookmarks.xml');
|
||||||
|
$res = $req->send();
|
||||||
|
$this->assertEquals(302, $res->getStatus(), 'Bookmark import failed');
|
||||||
|
|
||||||
|
$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
|
||||||
|
|
||||||
|
}//end class www_importTest
|
||||||
|
?>
|
|
@ -81,7 +81,7 @@ if (isset($_REQUEST['dt']) && (trim($_REQUEST['dt']) != '')) {
|
||||||
|
|
||||||
$replace = isset($_REQUEST['replace']) && ($_REQUEST['replace'] == 'yes');
|
$replace = isset($_REQUEST['replace']) && ($_REQUEST['replace'] == 'yes');
|
||||||
|
|
||||||
$status = 0;
|
$status = $GLOBALS['defaults']['privacy'];
|
||||||
if (isset($_REQUEST['status'])) {
|
if (isset($_REQUEST['status'])) {
|
||||||
$status_str = trim($_REQUEST['status']);
|
$status_str = trim($_REQUEST['status']);
|
||||||
if (is_numeric($status_str)) {
|
if (is_numeric($status_str)) {
|
||||||
|
|
|
@ -191,7 +191,7 @@ if ($templatename == 'editbookmark.tpl') {
|
||||||
'bDescription' => stripslashes(POST_DESCRIPTION),
|
'bDescription' => stripslashes(POST_DESCRIPTION),
|
||||||
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
|
'bPrivateNote' => stripslashes(POST_PRIVATENOTE),
|
||||||
'tags' => ($_POST['tags'] ? $_POST['tags'] : array()),
|
'tags' => ($_POST['tags'] ? $_POST['tags'] : array()),
|
||||||
'bStatus' => 0,
|
'bStatus' => $GLOBALS['defaults']['privacy'],
|
||||||
);
|
);
|
||||||
$tplVars['tags'] = $_POST['tags'];
|
$tplVars['tags'] = $_POST['tags'];
|
||||||
} else {
|
} else {
|
||||||
|
@ -207,7 +207,7 @@ if ($templatename == 'editbookmark.tpl') {
|
||||||
'bDescription' => stripslashes(GET_DESCRIPTION),
|
'bDescription' => stripslashes(GET_DESCRIPTION),
|
||||||
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
|
'bPrivateNote' => stripslashes(GET_PRIVATENOTE),
|
||||||
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
|
'tags' => (GET_TAGS ? explode(',', stripslashes(GET_TAGS)) : array()),
|
||||||
'bStatus' => 0
|
'bStatus' => $GLOBALS['defaults']['privacy']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ isset($_POST['title']) ? define('POST_TITLE', $_POST['title']): define('POST_TIT
|
||||||
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
|
isset($_POST['address']) ? define('POST_ADDRESS', $_POST['address']): define('POST_ADDRESS', '');
|
||||||
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
isset($_POST['description']) ? define('POST_DESCRIPTION', $_POST['description']): define('POST_DESCRIPTION', '');
|
||||||
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
|
isset($_POST['privateNote']) ? define('POST_PRIVATENOTE', $_POST['privateNote']): define('POST_PRIVATENOTE', '');
|
||||||
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
|
||||||
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
|
isset($_POST['tags']) ? define('POST_TAGS', $_POST['tags']): define('POST_TAGS', '');
|
||||||
|
|
||||||
isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', '');
|
isset($_GET['popup']) ? define('GET_POPUP', $_GET['popup']): define('GET_POPUP', '');
|
||||||
|
|
|
@ -27,7 +27,7 @@ require_once 'www-header.php';
|
||||||
/* Managing all possible inputs */
|
/* Managing all possible inputs */
|
||||||
// First input is $_FILES
|
// First input is $_FILES
|
||||||
// Other inputs
|
// Other inputs
|
||||||
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
|
||||||
|
|
||||||
|
|
||||||
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
|
if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['size'] > 0) {
|
||||||
|
@ -36,7 +36,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
|
||||||
if (is_numeric(POST_STATUS)) {
|
if (is_numeric(POST_STATUS)) {
|
||||||
$status = intval(POST_STATUS);
|
$status = intval(POST_STATUS);
|
||||||
} else {
|
} else {
|
||||||
$status = 2;
|
$status = $GLOBALS['defaults']['privacy'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$depth = array();
|
$depth = array();
|
||||||
|
|
|
@ -28,7 +28,7 @@ $bookmarkservice =SemanticScuttle_Service_Factory::get('Bookmark');
|
||||||
/* Managing all possible inputs */
|
/* Managing all possible inputs */
|
||||||
// First input is $_FILES
|
// First input is $_FILES
|
||||||
// Other inputs
|
// Other inputs
|
||||||
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', '');
|
isset($_POST['status']) ? define('POST_STATUS', $_POST['status']): define('POST_STATUS', $GLOBALS['defaults']['privacy']);
|
||||||
|
|
||||||
$countImportedBookmarks = 0;
|
$countImportedBookmarks = 0;
|
||||||
$tplVars['msg'] = '';
|
$tplVars['msg'] = '';
|
||||||
|
@ -39,7 +39,7 @@ if ($userservice->isLoggedOn() && sizeof($_FILES) > 0 && $_FILES['userfile']['si
|
||||||
if (is_numeric(POST_STATUS)) {
|
if (is_numeric(POST_STATUS)) {
|
||||||
$status = intval(POST_STATUS);
|
$status = intval(POST_STATUS);
|
||||||
} else {
|
} else {
|
||||||
$status = 2;
|
$status = $GLOBALS['defaults']['privacy'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// File handle
|
// File handle
|
||||||
|
|
Loading…
Reference in a new issue