make privacy tests clearer
This commit is contained in:
parent
6b02db7920
commit
f629d081dd
2 changed files with 31 additions and 47 deletions
|
@ -555,10 +555,10 @@ TXT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the default privacy setting is selected in the Privacy
|
* Test that the default privacy setting is selected in the Privacy
|
||||||
* drop-down list when an existing bookmark is accessed with bookmarks.php
|
* drop-down list when adding a new bookmark, sending the form and
|
||||||
* and the get action.
|
* missing the title and the privacy setting.
|
||||||
*/
|
*/
|
||||||
public function testDefaultPrivacyBookmarksGet()
|
public function testDefaultPrivacyBookmarksAddMissingTitleMissingPrivacy()
|
||||||
{
|
{
|
||||||
$this->setUnittestConfig(
|
$this->setUnittestConfig(
|
||||||
array('defaults' => array('privacy' => 2))
|
array('defaults' => array('privacy' => 2))
|
||||||
|
@ -596,50 +596,31 @@ TXT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test that the default privacy setting is selected in the Privacy
|
* Test that the default privacy setting is selected in the Privacy
|
||||||
* drop-down list when an existing bookmark is accessed with bookmarks.php
|
* drop-down list when a new bookmark is being created.
|
||||||
* and the add action.
|
|
||||||
*/
|
*/
|
||||||
public function testDefaultPrivacyBookmarksAdd()
|
public function testDefaultPrivacyBookmarksAdd()
|
||||||
{
|
{
|
||||||
$this->setUnittestConfig(
|
$this->setUnittestConfig(
|
||||||
array('defaults' => array('privacy' => 1))
|
array('defaults' => array('privacy' => 1))
|
||||||
);
|
);
|
||||||
list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
|
list($req, $uId) = $this->getLoggedInRequest('?unittestMode=1');
|
||||||
$req->setMethod(HTTP_Request2::METHOD_POST);
|
|
||||||
$req->addPostParameter('url', 'http://www.example.org/testdefaultprivacyposts_bookmarksadd');
|
|
||||||
$req->addPostParameter('description', 'Test bookmark 2 for default privacy.');
|
|
||||||
$req->addPostParameter('status', '0');
|
|
||||||
$req->send();
|
|
||||||
$bms = $this->bs->getBookmarks(0, null, $uId);
|
|
||||||
$this->assertEquals(1, count($bms['bookmarks']));
|
|
||||||
$bm = reset($bms['bookmarks']);
|
|
||||||
$bmId = $bm['bId'];
|
|
||||||
$oldUid = $uId;
|
|
||||||
$user = $this->us->getUser($uId);
|
$user = $this->us->getUser($uId);
|
||||||
$userId = $user['username'];
|
$reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/'
|
||||||
$reqUrl = $GLOBALS['unittestUrl'] . 'bookmarks.php/' . $userId . '?action=add' . '&unittestMode=1';
|
. $user['username'] . '?action=add' . '&unittestMode=1';
|
||||||
list($req, $uId) = $this->getAuthRequest('?unittestMode=1');
|
|
||||||
$req->setMethod(HTTP_Request2::METHOD_POST);
|
|
||||||
$req->setUrl($reqUrl);
|
$req->setUrl($reqUrl);
|
||||||
$testcookiekey = md5($GLOBALS['dbname'].$GLOBALS['tableprefix']).'-login';
|
$req->setMethod(HTTP_Request2::METHOD_GET);
|
||||||
$userinfo = $this->us->getUser($oldUid);
|
|
||||||
$testcookiepassword = $userinfo['password'];
|
|
||||||
$testusername = $userinfo['username'];
|
|
||||||
$testcookievalue = $oldUid . ':' . md5($testusername . $testcookiepassword);
|
|
||||||
$req->setCookieJar(true);
|
|
||||||
$req->addCookie($testcookiekey, $testcookievalue);
|
|
||||||
$req->addPostParameter('submitted', '1');
|
|
||||||
$response = $req->send();
|
$response = $req->send();
|
||||||
$response_body = $response->getBody();
|
$response_body = $response->getBody();
|
||||||
$start = strpos($response_body, 'Privacy');
|
$this->assertNotEquals('', $response_body, 'Response is empty');
|
||||||
$end = strpos($response_body, 'referrer');
|
|
||||||
$length = $end - $start;
|
$x = simplexml_load_string($response_body);
|
||||||
$response_body = substr($response_body, $start, $length);
|
$ns = $x->getDocNamespaces();
|
||||||
$start = strpos($response_body, 'selected');
|
$x->registerXPathNamespace('ns', reset($ns));
|
||||||
$start = $start - 3;
|
|
||||||
$length = 1;
|
$elements = $x->xpath('//ns:select[@name="status"]/ns:option[@selected="selected"]');
|
||||||
$selected_privacy = substr($response_body, $start, $length);
|
$this->assertEquals(1, count($elements), 'No selected status option found');
|
||||||
$this->assertEquals('1', $selected_privacy);
|
$this->assertEquals(1, (string)$elements[0]['value']);
|
||||||
}//end testDefaultPrivacyBookmarksAdd
|
}//end testDefaultPrivacyBookmarksAdd
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,8 @@ class TestBaseApi extends TestBase
|
||||||
* the request object with authentication details, so that
|
* the request object with authentication details, so that
|
||||||
* the user is logged in.
|
* the user is logged in.
|
||||||
*
|
*
|
||||||
|
* Only usable for API requests, not "normal" HTTP page requests
|
||||||
|
*
|
||||||
* @param string $urlSuffix Suffix for the URL
|
* @param string $urlSuffix Suffix for the URL
|
||||||
* @param mixed $auth If user authentication is needed (true/false)
|
* @param mixed $auth If user authentication is needed (true/false)
|
||||||
* or array with username and password
|
* or array with username and password
|
||||||
|
@ -96,6 +98,7 @@ class TestBaseApi extends TestBase
|
||||||
* @return array(HTTP_Request2, integer) HTTP request object and user id
|
* @return array(HTTP_Request2, integer) HTTP request object and user id
|
||||||
*
|
*
|
||||||
* @uses getRequest()
|
* @uses getRequest()
|
||||||
|
* @see getLoggedInRequest()
|
||||||
*/
|
*/
|
||||||
protected function getAuthRequest($urlSuffix = null, $auth = true)
|
protected function getAuthRequest($urlSuffix = null, $auth = true)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue