summaryrefslogtreecommitdiff
path: root/tests/TestBase.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2010-10-08 17:43:05 +0200
committerChristian Weiske <cweiske@cweiske.de>2010-10-08 17:43:05 +0200
commitbe126cc958212ed74fe916eabcb1e6ac928df5e4 (patch)
tree80a9644be8b1af487b8b9383cd36b13273f975e2 /tests/TestBase.php
parentcd023dea530870a047ca87405fedc3ddbc06d787 (diff)
downloadsemanticscuttle-be126cc958212ed74fe916eabcb1e6ac928df5e4.tar.gz
semanticscuttle-be126cc958212ed74fe916eabcb1e6ac928df5e4.tar.bz2
tests for getadminlinkedtags
Diffstat (limited to 'tests/TestBase.php')
-rw-r--r--tests/TestBase.php28
1 files changed, 28 insertions, 0 deletions
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