From: Tim Otten Date: Thu, 2 Apr 2015 03:11:09 +0000 (-0700) Subject: CRM-11889 - CiviSeleniumTestCase - Use browser session for rest_civicrm_api. Add... X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ef9cbdb75771b2a9ac9836b623a7688e33481724;p=civicrm-core.git CRM-11889 - CiviSeleniumTestCase - Use browser session for rest_civicrm_api. Add webtestGetLoggedInContact & assertAPISuccess. --- diff --git a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php index 6bd435c871..c2379df5af 100644 --- a/tests/phpunit/CiviTest/CiviSeleniumTestCase.php +++ b/tests/phpunit/CiviTest/CiviSeleniumTestCase.php @@ -315,13 +315,13 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { } $result = civicrm_api($entity, $action, $params); - $this->assertTrue(!civicrm_error($result), 'Civicrm api error.'); + $this->assertAPISuccess($result); return $result; } /** - * Call the API on the remote server. - * Experimental - currently only works if permissions on remote site allow anon user to access ajax api + * Call the API on the remote server using the AJAX endpoint. + * * @see CRM-11889 * @param $entity * @param $action @@ -332,17 +332,28 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase { $params += array( 'version' => 3, ); - $url = "{$this->settings->sandboxURL}/{$this->sboxPath}civicrm/ajax/rest?entity=$entity&action=$action&json=" . json_encode($params); - $request = array( - 'http' => array( - 'method' => 'POST', - // Naughty sidestep of civi's security checks - 'header' => "X-Requested-With: XMLHttpRequest", - ), + static $reqId = 0; + $reqId++; + + $jsCmd = ' + setTimeout(function(){ + CRM.api3("@entity", "@action", @params).then(function(a){ + cj("