From 09fffebffe9ab1cf7622aa141150157b0746e20d Mon Sep 17 00:00:00 2001 From: cweiske Date: Sun, 25 Oct 2009 19:32:48 +0000 Subject: test if deleting bookmarks works. to do this, we need a new testbase method to create users, plus we need to return the uid when creating a new user. registration process needs to be adopted to that. git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@417 b3834d28-1941-0410-a4f8-b48e95affb8f --- tests/TestBase.php | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'tests/TestBase.php') diff --git a/tests/TestBase.php b/tests/TestBase.php index dc5643f..f9946e2 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -27,23 +27,50 @@ class TestBase extends PHPUnit_Framework_TestCase /** * Create a new bookmark. * + * @param integer $user User ID the bookmark shall belong + * * @return integer ID of bookmark */ - protected function addBookmark() + protected function addBookmark($user = null) { - $bs = SemanticScuttle_Service_Factory::get('Bookmark'); + if ($user === null) { + $user = $this->addUser(); + } + + $bs = SemanticScuttle_Service_Factory::get('Bookmark'); $rand = rand(); - $bid = $bs->addBookmark( + $bid = $bs->addBookmark( 'http://example.org/' . $rand, 'unittest bookmark #' . $rand, 'description', null, 0, - array('unittest') + array('unittest'), + null, false, false, + $user ); return $bid; } + + + /** + * 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; + } + } ?> \ No newline at end of file -- cgit v1.2.3