You are here

public function AcquiaSPITestCase::testAcquiaSpiUi in Acquia Connector 7.3

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

Needs comment.

File

acquia_spi/tests/acquia_spi.test, line 161

Class

AcquiaSPITestCase
Tests the functionality of the Acquia SPI module.

Code

public function testAcquiaSpiUi() {
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertNoText($this
    ->acquiaSpiStrings('spi-status-text'), 'SPI send option does not exist when site is not connected');

  // Connect site on key and id that will error.
  $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);

  // If name and machine name are empty.
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertText($this
    ->acquiaSpiStrings('spi-not-sent'), 'SPI data was not sent');
  $edit_fields = array(
    'name' => $this->acqtestName,
  );
  $submit_button = 'Save settings';
  $this
    ->drupalPost($this->settingsPath, $edit_fields, $submit_button);

  // Send SPI data.
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertText($this
    ->acquiaSpiStrings('spi-status-text'), 'SPI explanation text exists');
  $this
    ->clickLink($this
    ->acquiaSpiStrings('spi-send-text'));
  $this
    ->assertNoText($this
    ->acquiaSpiStrings('spi-data-sent'), 'SPI data was not sent');
  $this
    ->assertText($this
    ->acquiaSpiStrings('spi-data-sent-error'), 'Page says there was an error sending data');

  // Connect site on non-error key and id.
  $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');

  // Send SPI data.
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->clickLink($this
    ->acquiaSpiStrings('spi-send-text'));
  $this
    ->assertText($this
    ->acquiaSpiStrings('spi-data-sent'), 'SPI data was sent');
  $this
    ->assertNoText($this
    ->acquiaSpiStrings('spi-not-sent'), 'SPI does not say "data has not been sent"');
}