diff options
author | Christian Weiske <cweiske@cweiske.de> | 2010-10-08 17:43:05 +0200 |
---|---|---|
committer | Christian Weiske <cweiske@cweiske.de> | 2010-10-08 17:43:05 +0200 |
commit | be126cc958212ed74fe916eabcb1e6ac928df5e4 (patch) | |
tree | 80a9644be8b1af487b8b9383cd36b13273f975e2 /tests/TestBase.php | |
parent | cd023dea530870a047ca87405fedc3ddbc06d787 (diff) | |
download | semanticscuttle-be126cc958212ed74fe916eabcb1e6ac928df5e4.tar.gz semanticscuttle-be126cc958212ed74fe916eabcb1e6ac928df5e4.tar.bz2 |
tests for getadminlinkedtags
Diffstat (limited to 'tests/TestBase.php')
-rw-r--r-- | tests/TestBase.php | 28 |
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 |