make edit test much easier and do not rely on manual cookie setting

This commit is contained in:
Christian Weiske 2011-04-18 19:16:58 +02:00
parent f3fdb6ca14
commit 87eab925e4

View file

@ -475,31 +475,31 @@ TXT;
$this->setUnittestConfig( $this->setUnittestConfig(
array('defaults' => array('privacy' => 2)) array('defaults' => array('privacy' => 2))
); );
list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
$cookies = $req->getCookieJar();
$req->setMethod(HTTP_Request2::METHOD_POST); $req->setMethod(HTTP_Request2::METHOD_POST);
$req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_edit'); $req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_edit');
$req->addPostParameter('description', 'Test bookmark 2 for default privacy.'); $req->addPostParameter('description', 'Test bookmark 2 for default privacy.');
$req->addPostParameter('status', '0'); $req->addPostParameter('status', '0');
$req->send(); $res = $req->send();
$this->assertEquals(
200, $res->getStatus(),
'Adding bookmark failed: ' . $res->getBody());
$bms = $this->bs->getBookmarks(0, null, $uId); $bms = $this->bs->getBookmarks(0, null, $uId);
$bm = reset($bms['bookmarks']); $bm = reset($bms['bookmarks']);
$bmId = $bm['bId']; $bmId = $bm['bId'];
$oldUid = $uId;
$reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1'; $reqUrl = $GLOBALS['unittestUrl'] . 'edit.php/' . $bmId . '?unittestMode=1';
list($req, $uId) = $this->getAuthRequest('?unittestMode=1'); $req2 = new HTTP_Request2($reqUrl, HTTP_Request2::METHOD_POST);
$req->setMethod(HTTP_Request2::METHOD_POST); $req2->setCookieJar($cookies);
$req->setUrl($reqUrl); $req2->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit');
$testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login'; $req2->addPostParameter('title', 'Test bookmark 2 for default privacy.');
$userinfo = $this->us->getUser($oldUid); $req2->addPostParameter('submitted', '1');
$testcookiepassword = $userinfo['password']; $res = $req2->send();
$testusername = $userinfo['username'];
$testcookievalue = $oldUid . ':' . md5($testusername . $testcookiepassword); $this->assertEquals(302, $res->getStatus(), 'Editing bookmark failed');
$req->setCookieJar(true);
$req->addCookie($testcookiekey, $testcookievalue);
$req->addPostParameter('address', 'http://www.example.org/testdefaultprivacyposts_edit');
$req->addPostParameter('title', 'Test bookmark 2 for default privacy.');
$req->addPostParameter('submitted', '1');
$req->send();
$bm = $this->bs->getBookmark($bmId); $bm = $this->bs->getBookmark($bmId);
$this->assertEquals('2', $bm['bStatus']); $this->assertEquals('2', $bm['bStatus']);
}//end testDefaultPrivacyEdit }//end testDefaultPrivacyEdit