2009-10-25 15:31:31 +00: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 17:39:17 +00:00
|
|
|
PHPUnit_Util_Filter::addFileToFilter(__FILE__);
|
|
|
|
|
2009-10-25 15:31:31 +00: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 19:32:48 +00:00
|
|
|
* @param integer $user User ID the bookmark shall belong
|
|
|
|
*
|
2009-10-25 15:31:31 +00:00
|
|
|
* @return integer ID of bookmark
|
|
|
|
*/
|
2009-10-25 19:32:48 +00:00
|
|
|
protected function addBookmark($user = null)
|
2009-10-25 15:31:31 +00:00
|
|
|
{
|
2009-10-25 19:32:48 +00:00
|
|
|
if ($user === null) {
|
|
|
|
$user = $this->addUser();
|
|
|
|
}
|
|
|
|
|
|
|
|
$bs = SemanticScuttle_Service_Factory::get('Bookmark');
|
2009-10-25 15:31:31 +00:00
|
|
|
$rand = rand();
|
2009-10-25 19:32:48 +00:00
|
|
|
$bid = $bs->addBookmark(
|
2009-10-25 15:31:31 +00:00
|
|
|
'http://example.org/' . $rand,
|
|
|
|
'unittest bookmark #' . $rand,
|
|
|
|
'description',
|
|
|
|
null,
|
|
|
|
0,
|
2009-10-25 19:32:48 +00:00
|
|
|
array('unittest'),
|
2009-11-23 19:11:33 +00:00
|
|
|
null, null, false, false,
|
2009-10-25 19:32:48 +00:00
|
|
|
$user
|
2009-10-25 15:31:31 +00:00
|
|
|
);
|
|
|
|
return $bid;
|
|
|
|
}
|
|
|
|
|
2009-10-25 19:32:48 +00: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 15:31:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|