public function AcquiaAgentTestCase::testAcquiaAgentSiteStatus in Acquia Connector 7.3
Same name and namespace in other branches
- 7.2 acquia_agent/tests/acquia_agent.test \AcquiaAgentTestCase::testAcquiaAgentSiteStatus()
Tests the site status callback.
File
- acquia_agent/
tests/ acquia_agent.test, line 343 - Tests the functionality of the Acquia Agent module.
Class
- AcquiaAgentTestCase
- AcquiaAgentTestCase.
Code
public function testAcquiaAgentSiteStatus() {
module_load_include('inc', 'acquia_agent', 'acquia_agent.pages');
$uuid = '0dee0d07-4032-44ea-a2f2-84182dc10d54';
$test_url = "https://insight.acquia.com/node/uuid/{$uuid}/dashboard";
$variable_keys = array(
'maintenance_mode',
'cache',
'block_cache',
);
$test_data = array(
'active' => 1,
'href' => $test_url,
);
// Set some sample test data.
variable_set('acquia_subscription_data', $test_data);
// Test _acquia_agent_get_id_from_url().
$key = _acquia_agent_get_id_from_sub($test_data);
$this
->assertIdentical($key, $uuid);
// Add a 'uuid' key to the data and make sure that is returned.
$test_data['uuid'] = $uuid;
$test_data['href'] = 'http://example.com';
$key = _acquia_agent_get_id_from_sub($test_data);
$this
->assertIdentical($key, $uuid);
$query = array(
'key' => hash('sha1', "{$key}:test"),
'nonce' => 'test',
);
$json = $this
->drupalGetAJAX('system/acquia-connector-status', array(
'query' => $query,
));
// Test the version.
$this
->assertIdentical($json['version'], '1.0', 'Correct API version found.');
// Test all of the original values match.
foreach ($variable_keys as $variable) {
$this
->assertEqual($json['data'][$variable], variable_get($variable));
}
// Set the variables to TRUE.
foreach ($variable_keys as $variable) {
variable_set($variable, TRUE);
}
$json = $this
->drupalGetAJAX('system/acquia-connector-status', array(
'query' => $query,
));
// Test the the values again.
foreach ($variable_keys as $variable) {
$this
->assertEqual($json['data'][$variable], variable_get($variable));
}
// Test invalid query string parameters for access.
// A random key value should fail.
$query['key'] = $this
->randomString(16);
$this
->drupalGetAJAX('system/acquia-connector-status', array(
'query' => $query,
));
$this
->assertResponse(403);
}