2009-10-25 16:31:31 +01:00
|
|
|
<?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
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once 'PHPUnit/Framework.php';
|
|
|
|
|
2009-11-20 18:39:17 +01:00
|
|
|
PHPUnit_Util_Filter::addFileToFilter(__FILE__);
|
|
|
|
|
2009-10-25 16:31:31 +01:00
|
|
|
/**
|
|
|
|
* Base unittest class that provides several helper methods.
|
|
|
|
*
|
|
|
|
* @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 TestBase extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Create a new bookmark.
|
|
|
|
*
|
2009-10-25 20:32:48 +01:00
|
|
|
* @param integer $user User ID the bookmark shall belong
|
|
|
|
*
|
2009-10-25 16:31:31 +01:00
|
|
|
* @return integer ID of bookmark
|
|
|
|
*/
|
2009-10-25 20:32:48 +01:00
|
|
|
protected function addBookmark($user = null)
|
2009-10-25 16:31:31 +01:00
|
|
|
{
|
2009-10-25 20:32:48 +01:00
|
|
|
if ($user === null) {
|
|
|
|
$user = $this->addUser();
|
|
|
|
}
|
|
|
|
|
|
|
|
$bs = SemanticScuttle_Service_Factory::get('Bookmark');
|
2009-10-25 16:31:31 +01:00
|
|
|
$rand = rand();
|
2009-10-25 20:32:48 +01:00
|
|
|
$bid = $bs->addBookmark(
|
2009-10-25 16:31:31 +01:00
|
|
|
'http://example.org/' . $rand,
|
|
|
|
'unittest bookmark #' . $rand,
|
|
|
|
'description',
|
|
|
|
null,
|
|
|
|
0,
|
2009-10-25 20:32:48 +01:00
|
|
|
array('unittest'),
|
2009-11-23 20:11:33 +01:00
|
|
|
null, null, false, false,
|
2009-10-25 20:32:48 +01:00
|
|
|
$user
|
2009-10-25 16:31:31 +01:00
|
|
|
);
|
|
|
|
return $bid;
|
|
|
|
}
|
|
|
|
|
2009-10-25 20:32:48 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates a new user in the database.
|
|
|
|
*
|
|
|
|
* @return integer ID of user
|
|
|
|
*/
|
|
|
|
protected function addUser()
|
|
|
|
{
|
|
|
|
$us = SemanticScuttle_Service_Factory::get('User');
|
|
|
|
$rand = rand();
|
|
|
|
$uid = $us->addUser(
|
|
|
|
'unittestuser-' . $rand,
|
|
|
|
$rand,
|
|
|
|
'unittest-' . $rand . '@example.org'
|
|
|
|
);
|
|
|
|
return $uid;
|
|
|
|
}
|
|
|
|
|
2009-10-25 16:31:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|