You are here

public function AcquiaAgentTestCase::testAcquiaAgentGetConnected in Acquia Connector 7.3

Same name and namespace in other branches
  1. 7.2 acquia_agent/tests/acquia_agent.test \AcquiaAgentTestCase::testAcquiaAgentGetConnected()

Test Acquia Agent connection.

File

acquia_agent/tests/acquia_agent.test, line 166
Tests the functionality of the Acquia Agent module.

Class

AcquiaAgentTestCase
AcquiaAgentTestCase.

Code

public function testAcquiaAgentGetConnected() {

  // Check for call to get connected.
  $this
    ->drupalGet('admin');
  $this
    ->assertText($this
    ->acquiaAgentStrings('free'), 'The explanation of services text exists');
  $this
    ->assertLinkByHref($this->cloudFreeUrl, 0, 'Link to Acquia.com Cloud Services exists');
  $this
    ->assertText($this
    ->acquiaAgentStrings('get-connected'), 'The call-to-action to connect text exists');
  $this
    ->assertLink('connect now', 0, 'The "connect now" link exists');

  // Check connection setup page.
  $this
    ->drupalGet($this->setupPath);
  $this
    ->assertText($this
    ->acquiaAgentStrings('enter-email'), 'The email address field label exists');
  $this
    ->assertText($this
    ->acquiaAgentStrings('enter-password'), 'The password field label exists');
  $this
    ->assertLinkByHref($this->cloudFreeUrl, 0, 'Link to Acquia.com free signup exists');

  // Check errors on automatic setup page.
  $edit_fields = array(
    'email' => $this
      ->randomName(),
    'pass' => $this
      ->randomName(),
  );
  $submit_button = 'Next';
  $this
    ->drupalPost($this->setupPath, $edit_fields, $submit_button);
  $this
    ->assertText($this
    ->acquiaAgentStrings('account-not-found'), 'Account not found for random automatic setup attempt');
  $this
    ->assertText($this
    ->acquiaAgentStrings('menu-inactive'), 'Subscription not active menu message appears');

  // Check manual connection.
  $this
    ->drupalGet($this->credentialsPath);
  $this
    ->assertText($this
    ->acquiaAgentStrings('id-key'), 'The network key and id description exists');
  $this
    ->assertText($this
    ->acquiaAgentStrings('enter-key'), 'The network key field label exists');
  $this
    ->assertLinkByHref($this->cloudFreeUrl, 0, 'Link to Acquia.com free signup exists');

  // Check errors on connection page.
  $edit_fields = array(
    'acquia_identifier' => $this
      ->randomName(),
    'acquia_key' => $this
      ->randomName(),
  );
  $submit_button = 'Connect';
  $this
    ->drupalPost($this->credentialsPath, $edit_fields, $submit_button);
  $this
    ->assertText($this
    ->acquiaAgentStrings('subscription-not-found'), 'Subscription not found for random credentials');
  $this
    ->assertText($this
    ->acquiaAgentStrings('menu-inactive'), 'Subscription not active menu message appears');

  // Connect site on key and id.
  $edit_fields = array(
    'acquia_identifier' => ACQUIA_CONNECTOR_TEST_ID,
    'acquia_key' => ACQUIA_CONNECTOR_TEST_KEY,
  );
  $submit_button = 'Connect';
  $this
    ->drupalPost($this->credentialsPath, $edit_fields, $submit_button);
  $this
    ->drupalGet($this->settingsPath);
  $this
    ->assertText($this
    ->acquiaAgentStrings('subscription'), 'Subscription connected with key and identifier');
  $this
    ->assertLinkByHref($this->setupPath, 0, 'Link to change subscription exists');

  // Connect via automatic setup.
  variable_del('acquia_identifier');
  variable_del('acquia_key');
  $edit_fields = array(
    'email' => ACQUIA_CONNECTOR_TEST_EMAIL,
    'pass' => ACQUIA_CONNECTOR_TEST_PASS,
  );
  $submit_button = 'Next';
  $this
    ->drupalPost($this->setupPath, $edit_fields, $submit_button);
  $this
    ->drupalGet($this->setupPath);
  $this
    ->drupalGet($this->settingsPath);
  $this
    ->assertText($this
    ->acquiaAgentStrings('subscription'), 'Subscription connected with credentials');

  // Confirm menu reports active subscription.
  $this
    ->drupalGet('admin');
  $this
    ->assertText($this
    ->acquiaAgentStrings('menu-active'), 'Subscription active menu message appears');

  // Test dynamic banner.
  $edit_fields = array(
    'acquia_dynamic_banner' => TRUE,
  );
  $submit_button = 'Save settings';
  $this
    ->drupalPost($this->settingsPath, $edit_fields, $submit_button);
  $this
    ->assertFieldChecked('edit-acquia-dynamic-banner', '"Receive updates from Acquia" option stays saved');
}