summaryrefslogtreecommitdiff
path: root/tests/TestBaseApi.php
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2011-03-26 10:00:18 +0100
committerChristian Weiske <cweiske@cweiske.de>2011-03-26 10:00:18 +0100
commit0f9d06c6644f634b436549f0d5e56fc96ebd361c (patch)
tree82567adec7c04af045da73a4e1dbc4753256aa13 /tests/TestBaseApi.php
parent6d49b0622df0ea44975e99b585781f55fe9ac671 (diff)
downloadsemanticscuttle-0f9d06c6644f634b436549f0d5e56fc96ebd361c.tar.gz
semanticscuttle-0f9d06c6644f634b436549f0d5e56fc96ebd361c.tar.bz2
first working unittest for ajax/getcontacttags with login!
Diffstat (limited to 'tests/TestBaseApi.php')
-rw-r--r--tests/TestBaseApi.php19
1 files changed, 16 insertions, 3 deletions
diff --git a/tests/TestBaseApi.php b/tests/TestBaseApi.php
index b7c1921..2af228a 100644
--- a/tests/TestBaseApi.php
+++ b/tests/TestBaseApi.php
@@ -131,7 +131,6 @@ class TestBaseApi extends TestBase
*/
protected function getLoggedInRequest($urlSuffix = null, $auth = true)
{
- $req = $this->getRequest($urlSuffix);
if (is_array($auth)) {
list($username, $password) = $auth;
} else {
@@ -140,8 +139,22 @@ class TestBaseApi extends TestBase
}
$uid = $this->addUser($username, $password);
- //FIXME: login via the login form, check if it worked
- //FIXME: prepare new request with cookie
+ $req = new HTTP_Request2(
+ $GLOBALS['unittestUrl'] . '/login.php',
+ HTTP_Request2::METHOD_POST
+ );
+ $cookies = $req->setCookieJar()->getCookieJar();
+ $req->addPostParameter('username', $username);
+ $req->addPostParameter('password', $password);
+ $req->addPostParameter('submitted', 'Log In');
+ $res = $req->send();
+
+ //after login, we normally get redirected
+ $this->assertEquals(302, $res->getStatus(), 'Login failure');
+
+ $req = $this->getRequest($urlSuffix);
+ $req->setCookieJar($cookies);
+
return array($req, $uid);
}