summaryrefslogtreecommitdiff
path: root/tests/TestBase.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2010-08-12 20:49:35 +0200
committerChristian Weiske <cweiske@cweiske.de>2010-08-12 20:49:35 +0200
commit0a8dadf87e660e9bf205581f12f7af87bfabf6ca (patch)
treea1218f869401a1ffff764a58c28a0be674ba5362 /tests/TestBase.php
parentb25290cef48251a31cb0f693a53677b566c1b1a4 (diff)
parent31570df64ce6543de407e7b9d751ba9033d930de (diff)
downloadsemanticscuttle-0a8dadf87e660e9bf205581f12f7af87bfabf6ca.tar.gz
semanticscuttle-0a8dadf87e660e9bf205581f12f7af87bfabf6ca.tar.bz2
Merge branch 'master' into pearpkg
Diffstat (limited to 'tests/TestBase.php')
-rw-r--r--tests/TestBase.php51
1 files changed, 41 insertions, 10 deletions
diff --git a/tests/TestBase.php b/tests/TestBase.php
index 05988a5..402330b 100644
--- a/tests/TestBase.php
+++ b/tests/TestBase.php
@@ -29,25 +29,45 @@ class TestBase extends PHPUnit_Framework_TestCase
/**
* Create a new bookmark.
*
- * @param integer $user User ID the bookmark shall belong
+ * @param integer $user User ID the bookmark shall belong
+ * @param string $address Bookmark address to use
+ * @param integer $status Bookmark visibility
+ * @param array $tags Array of tags to attach. If "null" is given,
+ * it will automatically be "unittest"
+ * @param string $title Bookmark title
*
* @return integer ID of bookmark
+ *
+ * @see SemanticScuttle_Service_Bookmark::addBookmark()
*/
- protected function addBookmark($user = null)
- {
+ protected function addBookmark(
+ $user = null, $address = null, $status = 0,
+ $tags = null, $title = null
+ ) {
if ($user === null) {
$user = $this->addUser();
}
+ if ($tags === null) {
+ $tags = array('unittest');
+ }
$bs = SemanticScuttle_Service_Factory::get('Bookmark');
$rand = rand();
+
+ if ($address === null) {
+ $address = 'http://example.org/' . $rand;
+ }
+ if ($title === null) {
+ $title = 'unittest bookmark #' . $rand;
+ }
+
$bid = $bs->addBookmark(
- 'http://example.org/' . $rand,
- 'unittest bookmark #' . $rand,
+ $address,
+ $title,
'description',
null,
- 0,
- array('unittest'),
+ $status,
+ $tags,
null, null, false, false,
$user
);
@@ -59,15 +79,26 @@ class TestBase extends PHPUnit_Framework_TestCase
/**
* Creates a new user in the database.
*
+ * @param string $username Username
+ * @param string $password Password
+ *
* @return integer ID of user
*/
- protected function addUser()
+ protected function addUser($username = null, $password = null)
{
$us = SemanticScuttle_Service_Factory::get('User');
$rand = rand();
+
+ if ($username === null) {
+ $username = 'unittestuser-' . $rand;
+ }
+ if ($password === null) {
+ $password = $rand;
+ }
+
$uid = $us->addUser(
- 'unittestuser-' . $rand,
- $rand,
+ $username,
+ $password,
'unittest-' . $rand . '@example.org'
);
return $uid;