From be126cc958212ed74fe916eabcb1e6ac928df5e4 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Fri, 8 Oct 2010 17:43:05 +0200 Subject: tests for getadminlinkedtags --- tests/TestBase.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'tests/TestBase.php') diff --git a/tests/TestBase.php b/tests/TestBase.php index 402330b..c0acd58 100644 --- a/tests/TestBase.php +++ b/tests/TestBase.php @@ -104,6 +104,34 @@ class TestBase extends PHPUnit_Framework_TestCase return $uid; } + + + /** + * Retrieves the UID of an admin user. + * If that user does not exist in the database, it is created. + * + * @return integer UID of admin user + */ + protected function getAdminUser() + { + if (count($GLOBALS['admin_users']) == 0) { + $this->fail('No admin users configured'); + } + $adminUserName = reset($GLOBALS['admin_users']); + + $us = SemanticScuttle_Service_Factory::get('User'); + $uid = $us->getIdFromUser($adminUserName); + if ($uid === null) { + //that user does not exist in the database; create it + $uid = $us->addUser( + $adminUserName, + rand(), + 'unittest-admin-' . $adminUserName . '@example.org' + ); + } + + return $uid; + } } ?> \ No newline at end of file -- cgit v1.2.3