summaryrefslogtreecommitdiff
path: root/tests/TestBaseApi.php
diff options
context:
space:
mode:
authorcweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-03-28 18:07:18 +0000
committercweiske <cweiske@b3834d28-1941-0410-a4f8-b48e95affb8f>2010-03-28 18:07:18 +0000
commit90f7d528d3f34a57d517cca268766bdbae161585 (patch)
tree78a1534c6b9e3f9864a5a5730d6fd47615a6e22f /tests/TestBaseApi.php
parenta518928796f87ff61e7fcb34d69b374378fdadf6 (diff)
downloadsemanticscuttle-90f7d528d3f34a57d517cca268766bdbae161585.tar.gz
semanticscuttle-90f7d528d3f34a57d517cca268766bdbae161585.tar.bz2
more tests for csv export api
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@701 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'tests/TestBaseApi.php')
-rw-r--r--tests/TestBaseApi.php44
1 files changed, 33 insertions, 11 deletions
diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php
index 03ca016..645ead9 100644
--- a/tests/TestBaseApi.php
+++ b/tests/TestBaseApi.php
@@ -42,8 +42,11 @@ class TestBaseApi extends TestBase
$this->url = $GLOBALS['unittestUrl'] . $this->urlPart;
$this->us = SemanticScuttle_Service_Factory::get('User');
+ $this->us->deleteAll();
$this->bs = SemanticScuttle_Service_Factory::get('Bookmark');
$this->bs->deleteAll();
+ $this->b2t = SemanticScuttle_Service_Factory::get('Bookmark2Tag');
+ $this->b2t->deleteAll();
}
@@ -51,28 +54,47 @@ class TestBaseApi extends TestBase
/**
* Gets a HTTP request object
*
- * @param string $urlSuffix Suffix for the URL
- * @param boolean $auth If user authentication is needed
+ * @param string $urlSuffix Suffix for the URL
*
* @return HTTP_Request2 HTTP request object
*/
- protected function getRequest($urlSuffix = null, $auth = true)
+ protected function getRequest($urlSuffix = null)
{
$req = new HTTP_Request2(
$this->url . $urlSuffix,
HTTP_Request2::METHOD_GET
);
- if ($auth) {
- $this->addUser('testuser', 'testpassword');
- $req->setAuth(
- 'testuser', 'testpassword',
- HTTP_Request2::AUTH_BASIC
- );
- }
-
return $req;
}
+
+
+ /**
+ * Gets a HTTP request object
+ *
+ * @param string $urlSuffix Suffix for the URL
+ * @param mixed $auth If user authentication is needed (true/false)
+ * or array with username and password
+ *
+ * @return array(HTTP_Request2, integer) HTTP request object and user id
+ */
+ protected function getAuthRequest($urlSuffix = null, $auth = true)
+ {
+ $req = $this->getRequest($urlSuffix);
+ if (is_array($auth)) {
+ list($username, $password) = $auth;
+ } else {
+ $username = 'testuser';
+ $password = 'testpassword';
+ }
+ $uid = $this->addUser($username, $password);
+ $req->setAuth(
+ $username, $password,
+ HTTP_Request2::AUTH_BASIC
+ );
+ return array($req, $uid);
+ }
+
}
?> \ No newline at end of file