protected $api_key;
protected $session_id;
protected $nocms_contact_id;
+ protected $old_api_keys;
/**
* @param $apiResult
if (!property_exists($this->settings, 'adminApiKey') || empty($this->settings->adminApiKey)) {
$this->markTestSkipped('CiviSeleniumSettings is missing adminApiKey');
}
+
+ $this->old_api_keys = array();
}
protected function tearDown() {
+ if (!empty($this->old_api_keys)) {
+ foreach ($this->old_api_keys as $cid => $apiKey) {
+ $this->webtest_civicrm_api('Contact', 'create', array(
+ 'id' => $cid,
+ 'api_key' => $apiKey,
+ ));
+ }
+ }
parent::tearDown();
if (isset($this->nocms_contact_id)) {
$deleteParams = array(
* @param $is_error
*/
public function testAPICalls($query, $is_error) {
+ $this->updateAdminApiKey();
+
$client = CRM_Utils_HttpClient::singleton();
list($status, $data) = $client->post($this->url, $query);
$this->assertEquals(CRM_Utils_HttpClient::STATUS_OK, $status);
$this->assertAPIErrorCode($result, 1);
}
+ protected function updateAdminApiKey() {
+ $this->webtestLogin($this->settings->adminUsername, $this->settings->adminPassword);
+ $adminContact = $this->webtestGetLoggedInContact();
+ $this->webtestLogout();
+
+ $this->old_api_keys[$adminContact['id']] = CRM_Core_DAO::singleValueQuery('SELECT api_key FROM civicrm_contact WHERE id = %1', array(
+ 1 => array($adminContact['id'], 'Positive'),
+ ));
+
+ //$this->old_admin_api_key = $this->webtest_civicrm_api('Contact', 'get', array(
+ // 'id' => $adminContact['id'],
+ // 'return' => 'api_key',
+ //));
+
+ $this->webtest_civicrm_api('Contact', 'create', array(
+ 'id' => $adminContact['id'],
+ 'api_key' => $this->settings->adminApiKey,
+ ));
+ }
+
}