merged master into privatekey
This commit is contained in:
commit
23cdbb53d0
@ -462,6 +462,21 @@ $filetypes = array(
|
||||
'video' => array('avi', 'mov', 'mp4', 'mpeg', 'mpg', 'wmv')
|
||||
);
|
||||
|
||||
/**
|
||||
* Link protocols that are allowed for newly added bookmarks.
|
||||
* This prevents i.e. adding javascript: links.
|
||||
*
|
||||
* @link http://en.wikipedia.org/wiki/URI_scheme
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
$allowedProtocols = array(
|
||||
'ftp', 'ftps',
|
||||
'http', 'https',
|
||||
'mailto', 'nntp',
|
||||
'xmpp'
|
||||
);
|
||||
|
||||
/**
|
||||
* Enable the "common bookmark description" functionality
|
||||
*
|
||||
|
7
data/schema/6.sql
Normal file
7
data/schema/6.sql
Normal file
@ -0,0 +1,7 @@
|
||||
CREATE TABLE `sc_version` (
|
||||
`schema_version` int(11) NOT NULL
|
||||
) DEFAULT CHARSET=utf8;
|
||||
INSERT INTO `sc_version` (`schema_version`) VALUES ('6');
|
||||
|
||||
ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(33) NULL;
|
||||
CREATE INDEX `privateKey` ON `sc_users` (`privateKey`);
|
@ -186,3 +186,9 @@ CREATE TABLE `sc_votes` (
|
||||
KEY `bid` (`bId`),
|
||||
KEY `uid` (`uId`)
|
||||
) CHARACTER SET utf8 COLLATE utf8_general_ci ;
|
||||
|
||||
|
||||
CREATE TABLE `sc_version` (
|
||||
`schema_version` int(11) NOT NULL
|
||||
) DEFAULT CHARSET=utf8;
|
||||
INSERT INTO `sc_version` (`schema_version`) VALUES ('6');
|
||||
|
@ -6,13 +6,17 @@ ChangeLog for SemantiScuttle
|
||||
- Switch to jQuery and drop dojo
|
||||
- Fix bug #3187177: Wrong URL / Export XML Bookmarks
|
||||
- Fix bug in getTagsForBookmarks() that fetched all tags
|
||||
- Fix bug #3097187: Using opensearch with two tags does not work in Firefox
|
||||
- Fix bug #3251877: French translation JavaScript Bug when editing bookmarks
|
||||
- Implement request #3054906: Show user's full name instead of nickname
|
||||
- Implement patch #3059829: update FR_CA translation
|
||||
- Show error message on mysqli connection errors
|
||||
- Update php-gettext library to 1.0.10
|
||||
- api/posts/add respects the "replace" parameter now
|
||||
- Fix privacy issue when fetching tags of several users
|
||||
- Implement Feature Request #3164013 adding ability to log in vi private key
|
||||
- Only URLs with an allowed protocol may be added to the database
|
||||
- Support HTTPS connections when $root is not configured
|
||||
- SQL schema version table to ease future database upgrades
|
||||
|
||||
|
||||
0.97.2 - 2011-02-17
|
||||
|
@ -2,11 +2,18 @@ Upgrading SemanticScuttle from a previous version
|
||||
=================================================
|
||||
|
||||
|
||||
From version 0.97 to 0.9x
|
||||
From version 0.97 to 0.98
|
||||
-------------------------
|
||||
Update your database:
|
||||
- ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(32) NULL;
|
||||
- CREATE INDEX `privateKey` ON `sc_users` (`privateKey`);
|
||||
Database updates: Apply data/schema/6.sql or do the following:
|
||||
|
||||
CREATE TABLE `sc_version` (
|
||||
`schema_version` int(11) NOT NULL
|
||||
) DEFAULT CHARSET=utf8;
|
||||
|
||||
INSERT INTO `sc_version` (`schema_version`) VALUES ('6');
|
||||
|
||||
ALTER TABLE `sc_users` ADD `privateKey` VARCHAR(33) NULL;
|
||||
CREATE INDEX `privateKey` ON `sc_users` (`privateKey`);
|
||||
|
||||
|
||||
From version 0.96 to 0.97
|
||||
|
46
src/SemanticScuttle/Model/Bookmark.php
Normal file
46
src/SemanticScuttle/Model/Bookmark.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* SemanticScuttle - your social bookmark manager.
|
||||
*
|
||||
* PHP version 5.
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
/**
|
||||
* Bookmark model class, keeping the data of a single bookmark.
|
||||
* It will slowly replace the old array style format.
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
class SemanticScuttle_Model_Bookmark
|
||||
{
|
||||
/**
|
||||
* Checks if the given URL is valid and may be used with this
|
||||
* SemanticScuttle installation.
|
||||
*
|
||||
* @param string $url URL to verify.
|
||||
*
|
||||
* @return boolean True if the URL is allowed, false if not
|
||||
*/
|
||||
public static function isValidUrl($url)
|
||||
{
|
||||
$scheme = parse_url($url, PHP_URL_SCHEME);
|
||||
if (array_search($scheme, $GLOBALS['allowedProtocols']) === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -434,6 +434,10 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
/**
|
||||
* Adds a bookmark to the database.
|
||||
*
|
||||
* Security checks are being made here, but no error reasons will be
|
||||
* returned. It is the responsibility of the code that calls
|
||||
* addBookmark() to verify the data.
|
||||
*
|
||||
* @param string $address Full URL of the bookmark
|
||||
* @param string $title Bookmark title
|
||||
* @param string $description Long bookmark description
|
||||
@ -452,7 +456,8 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
* @param boolean $fromImport True when the bookmark is from an import.
|
||||
* @param integer $sId ID of user who creates the bookmark.
|
||||
*
|
||||
* @return integer Bookmark ID
|
||||
* @return mixed Integer bookmark ID if saving succeeded, false in
|
||||
* case of an error. Error reasons are not returned.
|
||||
*/
|
||||
public function addBookmark(
|
||||
$address, $title, $description, $privateNote, $status, $tags,
|
||||
@ -465,6 +470,9 @@ class SemanticScuttle_Service_Bookmark extends SemanticScuttle_DbService
|
||||
}
|
||||
|
||||
$address = $this->normalize($address);
|
||||
if (!SemanticScuttle_Model_Bookmark::isValidUrl($address)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Note that if date is NULL, then it's added with a date and
|
||||
|
@ -107,6 +107,7 @@ class SemanticScuttle_Service_Factory
|
||||
|
||||
/**
|
||||
* Loads self::$db if it is not loaded already.
|
||||
* Dies if the connection could not be established.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -141,7 +142,7 @@ class SemanticScuttle_Service_Factory
|
||||
/**
|
||||
* Returns sql database object
|
||||
*
|
||||
* @return void
|
||||
* @return sql_db Database instance
|
||||
*/
|
||||
public static function getDb()
|
||||
{
|
||||
|
@ -28,6 +28,14 @@ require_once 'SemanticScuttle/Model/User.php';
|
||||
*/
|
||||
class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
{
|
||||
/**
|
||||
* The ID of the currently logged on user.
|
||||
* NULL when not logged in.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
protected $currentuserId = null;
|
||||
|
||||
/**
|
||||
* Currently logged on user from database
|
||||
*
|
||||
@ -478,10 +486,17 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
*/
|
||||
public function getCurrentUserId()
|
||||
{
|
||||
if (isset($_SESSION[$this->getSessionKey()])) {
|
||||
return (int)$_SESSION[$this->getSessionKey()];
|
||||
if ($this->currentuserId !== null) {
|
||||
return $this->currentuserId;
|
||||
}
|
||||
|
||||
} else if (isset($_COOKIE[$this->getCookieKey()])) {
|
||||
if (isset($_SESSION[$this->getSessionKey()])) {
|
||||
$this->currentuserId = (int)$_SESSION[$this->getSessionKey()];
|
||||
return $this->currentuserId;
|
||||
|
||||
}
|
||||
|
||||
if (isset($_COOKIE[$this->getCookieKey()])) {
|
||||
$cook = explode(':', $_COOKIE[$this->getCookieKey()]);
|
||||
//cookie looks like this: 'id:md5(username+password)'
|
||||
$query = 'SELECT * FROM '. $this->getTableName() .
|
||||
@ -500,10 +515,10 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
|
||||
if ($row = $this->db->sql_fetchrow($dbresult)) {
|
||||
$this->setCurrentUserId(
|
||||
(int)$row[$this->getFieldName('primary')]
|
||||
(int)$row[$this->getFieldName('primary')], true
|
||||
);
|
||||
$this->db->sql_freeresult($dbresult);
|
||||
return (int)$_SESSION[$this->getSessionKey()];
|
||||
return $this->currentuserId;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -514,19 +529,26 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
/**
|
||||
* Set the current user ID (i.e. when logging on)
|
||||
*
|
||||
* @param integer $user User ID or null to unset the user
|
||||
* @param integer $user User ID or null to unset the user
|
||||
* @param boolean $storeInSession Store the user ID in the session
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @internal
|
||||
* No ID verification is being done.
|
||||
*/
|
||||
public function setCurrentUserId($user)
|
||||
public function setCurrentUserId($user, $storeInSession = false)
|
||||
{
|
||||
if ($user === null) {
|
||||
unset($_SESSION[$this->getSessionKey()]);
|
||||
$this->currentuserId = null;
|
||||
if ($storeInSession) {
|
||||
unset($_SESSION[$this->getSessionKey()]);
|
||||
}
|
||||
} else {
|
||||
$_SESSION[$this->getSessionKey()] = (int)$user;
|
||||
$this->currentuserId = (int)$user;
|
||||
if ($storeInSession) {
|
||||
$_SESSION[$this->getSessionKey()] = $this->currentuserId;
|
||||
}
|
||||
}
|
||||
//reload user object
|
||||
$this->getCurrentUser(true);
|
||||
@ -569,10 +591,9 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
$this->db->sql_freeresult($dbresult);
|
||||
|
||||
if ($row) {
|
||||
$id = $_SESSION[$this->getSessionKey()]
|
||||
= $row[$this->getFieldName('primary')];
|
||||
$this->setCurrentUserId($row[$this->getFieldName('primary')], true);
|
||||
if ($remember) {
|
||||
$cookie = $id .':'. md5($username.$password);
|
||||
$cookie = $this->currentuserId . ':' . md5($username.$password);
|
||||
setcookie(
|
||||
$this->cookiekey, $cookie,
|
||||
time() + $this->cookietime, '/'
|
||||
@ -626,11 +647,11 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
}
|
||||
|
||||
/**
|
||||
* Logout current user
|
||||
* Logs the user off
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function logout()
|
||||
public function logout()
|
||||
{
|
||||
@setcookie($this->getCookiekey(), '', time() - 1, '/');
|
||||
unset($_COOKIE[$this->getCookiekey()]);
|
||||
@ -671,18 +692,17 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
return $arrWatch;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the list of user names being watched by the given user.
|
||||
*
|
||||
* @param string $uId Current User ID
|
||||
* @param boolean $watchedby flag to determine:
|
||||
* - If $watchedby is false get the list of users that $uId watches
|
||||
* - If $watchedby is true get the list of users that watch $uId
|
||||
* @param integer $uId User ID
|
||||
* @param boolean $watchedby if false: get the list of users that $uId watches
|
||||
* if true: get the list of users that watch $uId
|
||||
*
|
||||
* @return mixed array if valid query and generates data
|
||||
* boolean false if an error occured
|
||||
* @return array Array of user names
|
||||
*/
|
||||
function getWatchNames($uId, $watchedby = false)
|
||||
public function getWatchNames($uId, $watchedby = false)
|
||||
{
|
||||
if ($watchedby) {
|
||||
$table1 = 'b';
|
||||
@ -691,19 +711,21 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
$table1 = 'a';
|
||||
$table2 = 'b';
|
||||
}
|
||||
$query = 'SELECT '. $table1 .'.'. $this->getFieldName('username')
|
||||
.' FROM '. $GLOBALS['tableprefix'] .'watched AS W, '
|
||||
. $this->getTableName() .' AS a, '. $this->getTableName()
|
||||
.' AS b WHERE W.watched = a.'. $this->getFieldName('primary')
|
||||
.' AND W.uId = b.'. $this->getFieldName('primary') .' AND '
|
||||
. $table2 .'.'. $this->getFieldName('primary') .' = '
|
||||
. intval($uId) .' ORDER BY '. $table1 .'.'
|
||||
. $this->getFieldName('username');
|
||||
$primary = $this->getFieldName('primary');
|
||||
$userfield = $this->getFieldName('username');
|
||||
$query = 'SELECT '. $table1 .'.'. $userfield
|
||||
. ' FROM '. $GLOBALS['tableprefix'] . 'watched AS W,'
|
||||
. ' ' . $this->getTableName() .' AS a,'
|
||||
. ' ' . $this->getTableName() .' AS b'
|
||||
. ' WHERE W.watched = a.' . $primary
|
||||
. ' AND W.uId = b.' . $primary
|
||||
. ' AND ' . $table2 . '.' . $primary . ' = '. intval($uId)
|
||||
. ' ORDER BY '. $table1 . '.' . $userfield;
|
||||
|
||||
if (!($dbresult =& $this->db->sql_query($query))) {
|
||||
if (!($dbresult = $this->db->sql_query($query))) {
|
||||
message_die(
|
||||
GENERAL_ERROR, 'Could not get watchlist', '',
|
||||
__LINE__, __FILE__, $query, $this->db
|
||||
GENERAL_ERROR, 'Could not get watchlist',
|
||||
'', __LINE__, __FILE__, $query, $this->db
|
||||
);
|
||||
return false;
|
||||
}
|
||||
@ -713,31 +735,23 @@ class SemanticScuttle_Service_User extends SemanticScuttle_DbService
|
||||
$this->db->sql_freeresult($dbresult);
|
||||
return $arrWatch;
|
||||
}
|
||||
while ($row =& $this->db->sql_fetchrow($dbresult)) {
|
||||
while ($row = $this->db->sql_fetchrow($dbresult)) {
|
||||
$arrWatch[] = $row[$this->getFieldName('username')];
|
||||
}
|
||||
$this->db->sql_freeresult($dbresult);
|
||||
return $arrWatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Watch Status
|
||||
*
|
||||
* @param string $watcheduser User ID that is being Watched
|
||||
* @param string $currentuser Current User ID
|
||||
*
|
||||
* @return boolean true if it successful, false if not
|
||||
*/
|
||||
|
||||
function getWatchStatus($watcheduser, $currentuser)
|
||||
{
|
||||
// Returns true if the current user is watching
|
||||
// the given user, and false otherwise.
|
||||
$query = 'SELECT watched FROM '. $GLOBALS['tableprefix']
|
||||
.'watched AS W INNER JOIN '. $this->getTableName()
|
||||
.' AS U ON U.'. $this->getFieldName('primary')
|
||||
.' = W.watched WHERE U.'. $this->getFieldName('primary')
|
||||
.' = '. intval($watcheduser) .' AND W.uId = '
|
||||
. intval($currentuser);
|
||||
$query = 'SELECT watched FROM '. $GLOBALS['tableprefix'] .'watched AS W'
|
||||
. ' INNER JOIN '. $this->getTableName() .' AS U'
|
||||
. ' ON U.'. $this->getFieldName('primary') .' = W.watched'
|
||||
. ' WHERE U.'. $this->getFieldName('primary') .' = '
|
||||
. intval($watcheduser) .' AND W.uId = '. intval($currentuser);
|
||||
|
||||
if (! ($dbresult =& $this->db->sql_query($query)) ) {
|
||||
message_die(
|
||||
|
@ -41,7 +41,10 @@ if (!isset($GLOBALS['root'])) {
|
||||
$rootTmp .= '/';
|
||||
}
|
||||
|
||||
define('ROOT', 'http://'. $_SERVER['HTTP_HOST'] . $rootTmp);
|
||||
//we do not prepend http since we also want to support https connections
|
||||
// "http" is not required; it's automatically determined by the browser
|
||||
// depending on the current connection.
|
||||
define('ROOT', '//'. $_SERVER['HTTP_HOST'] . $rootTmp);
|
||||
} else {
|
||||
define('ROOT', $GLOBALS['root']);
|
||||
}
|
||||
|
@ -82,6 +82,7 @@ require_once 'SemanticScuttle/Service.php';
|
||||
require_once 'SemanticScuttle/DbService.php';
|
||||
require_once 'SemanticScuttle/Service/Factory.php';
|
||||
require_once 'SemanticScuttle/functions.php';
|
||||
require_once 'SemanticScuttle/Model/Bookmark.php';
|
||||
require_once 'SemanticScuttle/Model/UserArray.php';
|
||||
|
||||
if (count($GLOBALS['serviceoverrides']) > 0
|
||||
|
@ -12,23 +12,15 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'AllTests::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* SemanticScuttle unit tests.
|
||||
*
|
||||
* To launch this tests, you need PHPUnit 3.
|
||||
* Run them with:
|
||||
* $ php tests/AllTests.php
|
||||
* $ cd tests; phpunit .
|
||||
* or single files like:
|
||||
* $ php tests/BookmarkTest.php
|
||||
*
|
||||
* You also may use phpunit directly:
|
||||
* $ phpunit tests/AllTests.php
|
||||
* $ cd tests; phpunit BookmarkTest.php
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
@ -40,14 +32,6 @@ require_once 'prepare.php';
|
||||
*/
|
||||
class AllTests extends PHPUnit_Framework_TestSuite
|
||||
{
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(self::suite());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function suite()
|
||||
{
|
||||
$suite = new AllTests();
|
||||
@ -74,9 +58,4 @@ class AllTests extends PHPUnit_Framework_TestSuite
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'AllTests::main') {
|
||||
AllTests::main();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -12,14 +12,8 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'Api_ExportCsvTest::main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle csv export API
|
||||
*
|
||||
@ -39,21 +33,6 @@ class Api_ExportCsvTest extends TestBaseApi
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if authentication is required when sending no auth data
|
||||
*/
|
||||
@ -280,8 +259,4 @@ class Api_ExportCsvTest extends TestBaseApi
|
||||
return $ar;
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Api_ExportCsvTest::main') {
|
||||
Api_ExportCsvTest::main();
|
||||
}
|
||||
?>
|
76
tests/Api/OpenSearchTest.php
Normal file
76
tests/Api/OpenSearchTest.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
|
||||
class Api_OpenSearchTest extends TestBaseApi
|
||||
{
|
||||
protected $urlPart = '';
|
||||
|
||||
|
||||
public function testOpenSearchAvailable()
|
||||
{
|
||||
$req = $this->getRequest();
|
||||
$xhtml = $req->send()->getBody();
|
||||
|
||||
$xml = simplexml_load_string($xhtml);
|
||||
$xml->registerXPathNamespace('h', reset($xml->getDocNamespaces()));
|
||||
|
||||
$this->assertInstanceOf(
|
||||
'SimpleXMLElement', $xml,
|
||||
'SemanticScuttle main page XHTML could not be loaded - maybe invalid?'
|
||||
);
|
||||
|
||||
$arElements = $xml->xpath(
|
||||
'//h:head/h:link'
|
||||
. '[@rel="search" and @type="application/opensearchdescription+xml"]'
|
||||
);
|
||||
$this->assertEquals(
|
||||
1, count($arElements),
|
||||
'OpenSearch link in HTML is missing'
|
||||
);
|
||||
$searchDescUrl = $this->completeUrl((string)$arElements[0]['href']);
|
||||
$this->assertNotNull($searchDescUrl, 'Search description URL is empty');
|
||||
|
||||
$req = new HTTP_Request2($searchDescUrl);
|
||||
$res = $req->send();
|
||||
$this->assertEquals(
|
||||
200, $res->getStatus(),
|
||||
'HTTP response status code is not 200'
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
$GLOBALS['unittestUrl'] . 'api/opensearch.php',
|
||||
$searchDescUrl,
|
||||
'OpenSearch URL found, but it is not the expected one.'
|
||||
. ' It may be that you misconfigured the "unittestUrl" setting'
|
||||
);
|
||||
}
|
||||
|
||||
public function testOpenSearchContentType()
|
||||
{
|
||||
$res = $this->getRequest('api/opensearch.php')->send();
|
||||
$this->assertEquals(
|
||||
'text/xml; charset=utf-8',
|
||||
$res->getHeader('content-type')
|
||||
);
|
||||
}
|
||||
|
||||
public function testOpenSearchSearchUrl()
|
||||
{
|
||||
$xml = $this->getRequest('api/opensearch.php')->send()->getBody();
|
||||
$x = simplexml_load_string($xml);
|
||||
$x->registerXPathNamespace('os', reset($x->getDocNamespaces()));
|
||||
|
||||
$arElements = $x->xpath('//os:Url[@type="text/html"]');
|
||||
$this->assertEquals(
|
||||
1, count($arElements),
|
||||
'Url in OpenSearch description is missing'
|
||||
);
|
||||
$this->assertEquals(
|
||||
$GLOBALS['unittestUrl'] . 'search.php/all/{searchTerms}',
|
||||
(string)$arElements[0]['template']
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -12,14 +12,8 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'Api_PostsAddTest::main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle post addition API.
|
||||
*
|
||||
@ -37,21 +31,6 @@ class Api_PostsAddTest extends TestBaseApi
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if authentication is required when sending no auth data
|
||||
*/
|
||||
@ -428,8 +407,4 @@ TXT;
|
||||
$this->assertEquals($title2, $data['bookmarks'][0]['bTitle']);
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Api_PostsAddTest::main') {
|
||||
Api_PostsAddTest::main();
|
||||
}
|
||||
?>
|
@ -12,14 +12,8 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'Api_PostsDeleteTest::main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle post deletion API.
|
||||
*
|
||||
@ -37,21 +31,6 @@ class Api_PostsDeleteTest extends TestBaseApi
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if authentication is required when sending no auth data
|
||||
*/
|
||||
@ -296,8 +275,4 @@ class Api_PostsDeleteTest extends TestBaseApi
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Api_PostsDeleteTest::main') {
|
||||
Api_PostsDeleteTest::main();
|
||||
}
|
||||
?>
|
@ -12,14 +12,8 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'Api_PostsUpdateTest::main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle last-update time API.
|
||||
*
|
||||
@ -37,21 +31,6 @@ class Api_PostsUpdateTest extends TestBaseApi
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if authentication is required when sending no auth data
|
||||
*/
|
||||
@ -128,8 +107,4 @@ class Api_PostsUpdateTest extends TestBaseApi
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Api_PostsUpdateTest::main') {
|
||||
Api_PostsUpdateTest::main();
|
||||
}
|
||||
?>
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'Bookmark2TagTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle bookmark-tag combination service.
|
||||
@ -58,21 +53,6 @@ class Bookmark2TagTest extends TestBase
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->us = SemanticScuttle_Service_Factory::get('User');
|
||||
@ -628,8 +608,4 @@ class Bookmark2TagTest extends TestBase
|
||||
$this->assertContains(array('tag' => 'usable', 'bCount' => '2'), $arTags);
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Bookmark2TagTest::main') {
|
||||
Bookmark2TagTest::main();
|
||||
}
|
||||
?>
|
||||
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'BookmarkTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle bookmark service.
|
||||
@ -37,22 +32,6 @@ class BookmarkTest extends TestBase
|
||||
protected $tts;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->us = SemanticScuttle_Service_Factory::get('User');
|
||||
@ -71,8 +50,6 @@ class BookmarkTest extends TestBase
|
||||
/**
|
||||
* Tests if adding a bookmark with short url name
|
||||
* saves it in the database.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testAddBookmarkShort()
|
||||
{
|
||||
@ -86,7 +63,16 @@ class BookmarkTest extends TestBase
|
||||
$this->assertEquals('myShortName', $bm['bShort']);
|
||||
}
|
||||
|
||||
public function testHardCharactersInBookmarks()
|
||||
public function testAddBookmarkInvalidUrl()
|
||||
{
|
||||
$retval = $this->bs->addBookmark(
|
||||
'javascript:alert(123)', 'title', 'desc', 'priv',
|
||||
0, array()
|
||||
);
|
||||
$this->assertFalse($retval, 'Bookmark with invalid URL was accepted');
|
||||
}
|
||||
|
||||
public function testAddBookmarkWithSpecialCharacters()
|
||||
{
|
||||
$bs = $this->bs;
|
||||
$title = "title&é\"'(-è_çà)=";
|
||||
@ -116,7 +102,7 @@ class BookmarkTest extends TestBase
|
||||
);
|
||||
}
|
||||
|
||||
public function testUnificationOfBookmarks()
|
||||
public function testAddBookmarkUnification()
|
||||
{
|
||||
$bs = $this->bs;
|
||||
|
||||
@ -1390,9 +1376,4 @@ class BookmarkTest extends TestBase
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'BookmarkTest::main') {
|
||||
BookmarkTest::main();
|
||||
}
|
||||
?>
|
||||
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'CommonDescriptionTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle common description service.
|
||||
@ -39,21 +34,6 @@ class CommonDescriptionTest extends TestBase
|
||||
protected $cds;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->us =SemanticScuttle_Service_Factory::get('User');
|
||||
@ -128,9 +108,4 @@ class CommonDescriptionTest extends TestBase
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'CommonDescriptionTest::main') {
|
||||
CommonDescriptionTest::main();
|
||||
}
|
||||
?>
|
||||
|
13
tests/FactoryTest.php
Normal file
13
tests/FactoryTest.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
class FactoryTest extends TestBase
|
||||
{
|
||||
public function testGetDb()
|
||||
{
|
||||
$this->assertInstanceOf(
|
||||
'sql_db',
|
||||
SemanticScuttle_Service_Factory::getDb()
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
65
tests/Model/BookmarkTest.php
Normal file
65
tests/Model/BookmarkTest.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* SemanticScuttle - your social bookmark manager.
|
||||
*
|
||||
* PHP version 5.
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle Bookmark model
|
||||
*
|
||||
* @category Bookmarking
|
||||
* @package SemanticScuttle
|
||||
* @author Christian Weiske <cweiske@cweiske.de>
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
class Model_BookmarkTest extends TestBase
|
||||
{
|
||||
public function testIsValidUrlValid()
|
||||
{
|
||||
$this->assertTrue(
|
||||
SemanticScuttle_Model_Bookmark::isValidUrl(
|
||||
'http://example.org/foo/bar?baz=foorina'
|
||||
)
|
||||
);
|
||||
$this->assertTrue(
|
||||
SemanticScuttle_Model_Bookmark::isValidUrl(
|
||||
'https://example.org/'
|
||||
)
|
||||
);
|
||||
$this->assertTrue(
|
||||
SemanticScuttle_Model_Bookmark::isValidUrl(
|
||||
'ftp://user:pass@example.org/'
|
||||
)
|
||||
);
|
||||
$this->assertTrue(
|
||||
SemanticScuttle_Model_Bookmark::isValidUrl(
|
||||
'mailto:cweiske@example.org'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function testIsValidUrlInvalid()
|
||||
{
|
||||
$this->assertFalse(
|
||||
SemanticScuttle_Model_Bookmark::isValidUrl(
|
||||
'javascript:alert("foo")'
|
||||
)
|
||||
);
|
||||
$this->assertFalse(
|
||||
SemanticScuttle_Model_Bookmark::isValidUrl(
|
||||
'foo://example.org/foo/bar'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'SearchHistoryTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle search history service.
|
||||
@ -38,22 +33,6 @@ class SearchHistoryTest extends TestBase
|
||||
protected $shs;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set up all services
|
||||
*
|
||||
@ -391,10 +370,4 @@ class SearchHistoryTest extends TestBase
|
||||
$this->assertEquals(0, $this->shs->countSearches());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'SearchHistoryTest::main') {
|
||||
SearchHistoryTest::main();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'Tag2TagTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle tag2tag service.
|
||||
@ -37,22 +32,6 @@ class Tag2TagTest extends TestBase
|
||||
protected $tts;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->us =SemanticScuttle_Service_Factory::get('User');
|
||||
@ -550,8 +529,4 @@ class Tag2TagTest extends TestBase
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'Tag2TagTest::main') {
|
||||
Tag2TagTest::main();
|
||||
}
|
||||
?>
|
||||
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'TagTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle tag service.
|
||||
@ -34,22 +29,6 @@ class TagTest extends TestBase
|
||||
protected $ts;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->ts =SemanticScuttle_Service_Factory::get('Tag');
|
||||
@ -109,9 +88,4 @@ class TagTest extends TestBase
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'TagTest::main') {
|
||||
TagTest::main();
|
||||
}
|
||||
?>
|
||||
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'TagsCacheTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle tags cache service.
|
||||
@ -38,19 +33,6 @@ class TagsCacheTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->us =SemanticScuttle_Service_Factory::get('User');
|
||||
@ -207,9 +189,4 @@ class TagsCacheTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(array(), $tcs->getSynonyms('d', 1));
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'TagsCacheTest::main') {
|
||||
TagsCacheTest::main();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -11,6 +11,8 @@
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
/**
|
||||
* Base unittest class for web API tests.
|
||||
*
|
||||
@ -90,6 +92,23 @@ class TestBaseApi extends TestBase
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Completes an URL that's missing the protocol.
|
||||
* Useful when re-using URLs extracted from HTML
|
||||
*
|
||||
* @param string $url Potentially partial URL
|
||||
*
|
||||
* @return string Full URL
|
||||
*/
|
||||
protected function completeUrl($url)
|
||||
{
|
||||
if (substr($url, 0, 2) == '//') {
|
||||
$url = 'http:' . $url;
|
||||
}
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates a user and a HTTP request object and prepares
|
||||
|
@ -11,8 +11,6 @@
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle user array model.
|
||||
*
|
||||
|
@ -12,11 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'UserTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle user service.
|
||||
@ -31,24 +26,6 @@ require_once 'prepare.php';
|
||||
*/
|
||||
class UserTest extends TestBase
|
||||
{
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->us = SemanticScuttle_Service_Factory::get('User');
|
||||
@ -531,11 +508,4 @@ class UserTest extends TestBase
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'UserTest::main') {
|
||||
UserTest::main();
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -10,11 +10,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'VoteTest::main');
|
||||
}
|
||||
|
||||
require_once 'prepare.php';
|
||||
|
||||
/**
|
||||
* Unit tests for the SemanticScuttle voting system.
|
||||
@ -43,21 +38,6 @@ class VoteTest extends TestBase
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite('VoteTest')
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$GLOBALS['enableVoting'] = true;
|
||||
@ -553,9 +533,4 @@ class VoteTest extends TestBase
|
||||
}
|
||||
|
||||
}//class VoteTest extends TestBase
|
||||
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'VoteTest::main') {
|
||||
VoteTest::main();
|
||||
}
|
||||
?>
|
@ -12,14 +12,8 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
if (!defined('PHPUnit_MAIN_METHOD')) {
|
||||
define('PHPUnit_MAIN_METHOD', 'ajax_GetAdminLinkedTagsTest::main');
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit tests for the ajax linked admin tags script
|
||||
*
|
||||
@ -34,22 +28,6 @@ class ajax_GetAdminLinkedTagsTest extends TestBaseApi
|
||||
protected $urlPart = 'ajax/getadminlinkedtags.php';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Used to run this test class standalone
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function main()
|
||||
{
|
||||
require_once 'PHPUnit/TextUI/TestRunner.php';
|
||||
PHPUnit_TextUI_TestRunner::run(
|
||||
new PHPUnit_Framework_TestSuite(__CLASS__)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Verify that we get the configured root tags if
|
||||
* we do not pass any parameters
|
||||
@ -139,8 +117,4 @@ class ajax_GetAdminLinkedTagsTest extends TestBaseApi
|
||||
$this->assertEquals('adminsubtag', $data[0]->data->title);
|
||||
}
|
||||
}
|
||||
|
||||
if (PHPUnit_MAIN_METHOD == 'ajax_GetAdminLinkedTagsTest::main') {
|
||||
ajax_GetAdminLinkedTagsTest::main();
|
||||
}
|
||||
?>
|
@ -12,8 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
/**
|
||||
|
@ -12,8 +12,6 @@
|
||||
* @license GPL http://www.gnu.org/licenses/gpl.html
|
||||
* @link http://sourceforge.net/projects/semanticscuttle
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../prepare.php';
|
||||
require_once 'HTTP/Request2.php';
|
||||
|
||||
/**
|
||||
|
@ -1,10 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<phpunit strict="true" colors="true">
|
||||
<phpunit strict="true" colors="true"
|
||||
bootstrap="prepare.php"
|
||||
>
|
||||
<filter>
|
||||
<whitelist addUncoveredFilesFromWhitelist="false">
|
||||
<directory suffix=".php">../src/SemanticScuttle/</directory>
|
||||
<directory suffix=".php">../data/templates/</directory>
|
||||
<directory suffix=".php">../www/</directory>
|
||||
<exclude>
|
||||
<directory suffix=".php">../src/SemanticScuttle/db/</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
</phpunit>
|
||||
|
68
tests/www/searchTest.php
Normal file
68
tests/www/searchTest.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
class www_SearchTest extends TestBaseApi
|
||||
{
|
||||
protected $urlPart = 'search.php';
|
||||
|
||||
|
||||
/**
|
||||
* Some browsers using opensearch do "urlencode" on the terms,
|
||||
* for example Firefox. Multiple terms separated with space
|
||||
* appear as "foo+bar" in the URL.
|
||||
*/
|
||||
public function testMultipleTermsUrlEncoded()
|
||||
{
|
||||
$this->addBookmark(null, null, 0, null, 'unittest foo bar');
|
||||
$res = $this->getRequest('/all/foo+bar')->send();
|
||||
$this->assertSelectCount(
|
||||
'.xfolkentry', true, $res->getBody(),
|
||||
'No bookmark found', false
|
||||
);
|
||||
|
||||
$res = $this->getRequest('/all/baz+bat')->send();
|
||||
$this->assertSelectCount(
|
||||
'.xfolkentry', false, $res->getBody(),
|
||||
'Bookmarks found', false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Some browsers using opensearch do "rawurlencode" on the terms,
|
||||
* for example Opera. Multiple terms separated with space
|
||||
* appear as "foo%20bar" in the URL.
|
||||
*/
|
||||
public function testMultipleTermsRawUrlEncoded()
|
||||
{
|
||||
$this->addBookmark(null, null, 0, null, 'unittest foo bar');
|
||||
$res = $this->getRequest('/all/foo%20bar')->send();
|
||||
$this->assertSelectCount(
|
||||
'.xfolkentry', true, $res->getBody(),
|
||||
'No bookmark found', false
|
||||
);
|
||||
|
||||
$res = $this->getRequest('/all/baz bat')->send();
|
||||
$this->assertSelectCount(
|
||||
'.xfolkentry', false, $res->getBody(),
|
||||
'Bookmarks found', false
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function testMultipleTags()
|
||||
{
|
||||
$this->markTestSkipped(
|
||||
'FIXME: SemanticScuttle currently does not search multiple tags'
|
||||
);
|
||||
|
||||
$this->addBookmark(null, null, 0, array('foo', 'bar'));
|
||||
$res = $this->getRequest('/all/foo+bar')->send();
|
||||
$this->assertSelectCount(
|
||||
'.xfolkentry', true, $res->getBody(),
|
||||
'No bookmark found', false
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -131,8 +131,11 @@ if ($userservice->isLoggedOn() && POST_SUBMITTED != '') {
|
||||
$templatename = 'editbookmark.tpl';
|
||||
} else {
|
||||
$address = trim(POST_ADDRESS);
|
||||
// If the bookmark exists already, edit the original
|
||||
if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
|
||||
if (!SemanticScuttle_Model_Bookmark::isValidUrl($address)) {
|
||||
$tplVars['error'] = T_('This bookmark URL may not be added');
|
||||
$templatename = 'editbookmark.tpl';
|
||||
} else if ($bookmarkservice->bookmarkExists($address, $currentUserID)) {
|
||||
// If the bookmark exists already, edit the original
|
||||
$bookmark = $bookmarkservice->getBookmarkByAddress($address);
|
||||
header('Location: '. createURL('edit', $bookmark['bId']));
|
||||
exit();
|
||||
|
@ -51,11 +51,13 @@ if (count($exploded) == 4) {
|
||||
list($url, $range, $terms, $page) = $exploded;
|
||||
} elseif (count($exploded) == 2) {
|
||||
list($url, $range) = $exploded;
|
||||
$terms = $page= null;
|
||||
$terms = $page = null;
|
||||
} else {
|
||||
list($url, $range, $terms) = $exploded;
|
||||
$page= null;
|
||||
$page = null;
|
||||
}
|
||||
//some OpenSearch clients need that
|
||||
$terms = urldecode($terms);
|
||||
|
||||
$tplVars['loadjs'] = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user