You are here

public function AcquiaConnectorSpiTest::testAcquiaSpiUiTests in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/AcquiaConnectorSpiTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorSpiTest::testAcquiaSpiUiTests()
  2. 3.x tests/src/Functional/AcquiaConnectorSpiTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorSpiTest::testAcquiaSpiUiTests()

Test Acquia SPI UI.

Throws

\Exception

File

tests/src/Functional/AcquiaConnectorSpiTest.php, line 313

Class

AcquiaConnectorSpiTest
Tests the functionality of the Acquia SPI module.

Namespace

Drupal\Tests\acquia_connector\Functional

Code

public function testAcquiaSpiUiTests() {
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertNoText($this
    ->acquiaSPIStrings('spi-status-text'));

  // Connect site on key and id that will error.
  $edit_fields = [
    'acquia_identifier' => $this->acqtestErrorId,
    'acquia_key' => $this->acqtestErrorKey,
  ];
  $submit_button = 'Connect';
  $this
    ->drupalPostForm($this->credentialsPath, $edit_fields, $submit_button);

  // Even though the credentials are invalid, they should still be set and the
  // connection successful.
  $this
    ->assertText("Connection successful");

  // If name and machine name are empty.
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertText($this
    ->acquiaSPIStrings('spi-not-sent'));
  $this
    ->assertText($this
    ->acquiaSPIStrings('provide-site-name'));
  $edit_fields = [
    'name' => $this->acqtestName,
    'machine_name' => $this->acqtestMachineName,
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->settingsPath, $edit_fields, $submit_button);

  // Send SPI data.
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertText($this
    ->acquiaSPIStrings('spi-status-text'));
  $this
    ->clickLink($this
    ->acquiaSPIStrings('spi-send-text'));
  $this
    ->assertNoText($this
    ->acquiaSPIStrings('spi-data-sent'));
  $this
    ->assertText($this
    ->acquiaSPIStrings('spi-data-sent-error'));

  // Connect site on non-error key and id.
  $this
    ->connectSite();
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->clickLink($this
    ->acquiaSPIStrings('spi-send-text'));
  $this
    ->assertText($this
    ->acquiaSPIStrings('spi-data-sent'));
  $this
    ->assertNoText($this
    ->acquiaSPIStrings('spi-not-sent'));
  $this
    ->assertText('This is the first connection from this site, it may take awhile for it to appear.');

  // Machine name change.
  $edit_fields = [
    'name' => $this->acqtestName,
    'machine_name' => $this->acqtestMachineName . '_change',
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->settingsPath, $edit_fields, $submit_button);
  $this
    ->assertText('A change has been detected in your site environment. Please check the Acquia SPI status on your Status Report page for more information.');
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->clickLink($this
    ->acquiaSPIStrings('confirm-action'));
  $this
    ->assertText('Your site machine name changed from ' . $this->acqtestMachineName . ' to ' . $this->acqtestMachineName . '_change' . '.');

  // Block site.
  $edit_fields = [
    'env_change_action' => 'block',
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->environmentChangePath, $edit_fields, $submit_button);
  $this
    ->assertText($this
    ->acquiaSPIStrings('block-site-message'));
  $this
    ->clickLink($this
    ->acquiaSPIStrings('unblock-site'));

  // Unblock site.
  $edit_fields = [
    'env_change_action[unblock]' => TRUE,
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->environmentChangePath, $edit_fields, $submit_button);
  $this
    ->assertText('Your site has been enabled and is sending data to Acquia Cloud');
  $this
    ->assertText($this
    ->acquiaSPIStrings('spi-data-sent'));
  $this
    ->assertNoText($this
    ->acquiaSPIStrings('spi-not-sent'));

  // Update machine name on existing site.
  $this
    ->clickLink($this
    ->acquiaSPIStrings('spi-send-text'));
  $this
    ->assertText($this
    ->acquiaSPIStrings('change-env-detected'));
  $this
    ->clickLink($this
    ->acquiaSPIStrings('confirm-action'));
  $edit_fields = [
    'env_change_action' => 'update',
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->environmentChangePath, $edit_fields, $submit_button);

  // Name change.
  $edit_fields = [
    'name' => $this->acqtestName . ' change',
    'machine_name' => $this->acqtestMachineName . '_change',
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->settingsPath, $edit_fields, $submit_button);
  $this
    ->drupalGet($this->statusReportUrl);
  $this
    ->assertNoText($this
    ->acquiaSPIStrings('spi-not-sent'));
  $this
    ->clickLink($this
    ->acquiaSPIStrings('spi-send-text'));
  $this
    ->assertText('Site name updated (from ' . $this->acqtestName . ' to ' . $this->acqtestName . ' change).');
}