public function AcquiaConnectorSpiTest::testAcquiaSpiSendTests in Acquia Connector 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/AcquiaConnectorSpiTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorSpiTest::testAcquiaSpiSendTests()
- 3.x tests/src/Functional/AcquiaConnectorSpiTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorSpiTest::testAcquiaSpiSendTests()
Test Acquia SPI send.
File
- tests/
src/ Functional/ AcquiaConnectorSpiTest.php, line 489
Class
- AcquiaConnectorSpiTest
- Tests the functionality of the Acquia SPI module.
Namespace
Drupal\Tests\acquia_connector\FunctionalCode
public function testAcquiaSpiSendTests() {
// Connect site on invalid credentials.
$edit_fields = [
'acquia_identifier' => $this->acqtestErrorId,
'acquia_key' => $this->acqtestErrorKey,
];
$submit_button = 'Connect';
$this
->drupalPostForm($this->credentialsPath, $edit_fields, $submit_button);
// Attempt to send something.
$client = \Drupal::service('acquia_connector.client');
// Connect site on valid credentials.
$this
->connectSite();
// Check that result is an array.
$spi = new SpiController(\Drupal::service('acquia_connector.client'), \Drupal::service('config.factory'), \Drupal::service('path_alias.manager'));
$spi_data = $spi
->get();
unset($spi_data['spi_def_update']);
$result = $client
->sendNspi($this->acqtestId, $this->acqtestKey, $spi_data);
$this
->assertIsArray($result, 'SPI update result is an array');
// Trigger a validation error on response.
$spi_data['test_validation_error'] = TRUE;
unset($spi_data['spi_def_update']);
$result = $client
->sendNspi($this->acqtestId, $this->acqtestKey, $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 = $client
->sendNspi($this->acqtestId, $this->acqtestKey, $spi_data);
$this
->assertNotEmpty($result['body']['update_spi_definition'], 'SPI result array has expected "update_spi_definition" key.');
}