You are here

public function AcquiaSPITestCase::testAcquiaSPISend in Acquia Connector 7.2

Same name and namespace in other branches
  1. 7.3 acquia_spi/tests/acquia_spi.test \AcquiaSPITestCase::testAcquiaSpiSend()

File

acquia_spi/tests/acquia_spi.test, line 167

Class

AcquiaSPITestCase
Tests the functionality of the Acquia SPI module.

Code

public function testAcquiaSPISend() {

  // Connect site on invalid credentials.
  $edit_fields = array(
    'acquia_identifier' => ACQTEST_ERROR_ID,
    'acquia_key' => ACQTEST_ERROR_KEY,
  );
  $submit_button = 'Connect';
  $this
    ->drupalPost($this->credentials_path, $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();
  $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.');
}