public function AcquiaSPITestCase::testAcquiaSpiSend in Acquia Connector 7.3
Same name and namespace in other branches
- 7.2 acquia_spi/tests/acquia_spi.test \AcquiaSPITestCase::testAcquiaSPISend()
Needs comment.
File
- acquia_spi/
tests/ acquia_spi.test, line 280
Class
- AcquiaSPITestCase
- Tests the functionality of the Acquia SPI module.
Code
public function testAcquiaSpiSend() {
// Connect site on invalid credentials.
$edit_fields = array(
'acquia_identifier' => ACQUIA_CONNECTOR_TEST_ERROR_ID,
'acquia_key' => ACQUIA_CONNECTOR_TEST_ERROR_KEY,
);
$submit_button = 'Connect';
$server = array(
'AH_SITE_NAME' => 'site_name',
'AH_SITE_ENVIRONMENT' => 'dev',
);
variable_set('acquia_agent_server_superglobal', $server);
$this
->drupalPost($this->credentialsPath, $edit_fields, $submit_button);
// Attempt to send something.
$result = acquia_spi_send_data(array());
$this
->assertFalse($result, 'acquia_spi_send_data returns false when not connected.');
// Connect site on valid credentials.
$this
->connectSite();
$edit_fields = array(
'name' => $this->acqtestName,
);
$submit_button = 'Save settings';
$this
->drupalPost($this->settingsPath, $edit_fields, $submit_button);
variable_del('acquia_agent_server_superglobal');
$spi_data = acquia_spi_get();
// Check that result is an array.
$result = acquia_spi_send_data($spi_data);
$this
->assertTrue(is_array($result), 'SPI update result is an array');
// Trigger a validation error on response.
$spi_data['test_validation_error'] = TRUE;
$result = acquia_spi_send_data($spi_data);
$this
->assertFalse($result, 'SPI result is false if validation error.');
unset($spi_data['test_validation_error']);
// Trigger a SPI definition update response.
$spi_data['spi_def_update'] = TRUE;
$result = acquia_spi_send_data($spi_data);
$this
->assertTrue(!empty($result['update_spi_definition']), 'SPI result array has expected "update_spi_definition" key.');
}