You are here

public function AcquiaConnectorSpiTest::testAcquiaSpiUpdateResponseTests 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::testAcquiaSpiUpdateResponseTests()
  2. 3.x tests/src/Functional/AcquiaConnectorSpiTest.php \Drupal\Tests\acquia_connector\Functional\AcquiaConnectorSpiTest::testAcquiaSpiUpdateResponseTests()

Test Acquia SPI update response.

File

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

Class

AcquiaConnectorSpiTest
Tests the functionality of the Acquia SPI module.

Namespace

Drupal\Tests\acquia_connector\Functional

Code

public function testAcquiaSpiUpdateResponseTests() {
  $this
    ->connectSite();
  $edit_fields = [
    'name' => $this->acqtestName,
    'machine_name' => $this->acqtestMachineName,
  ];
  $submit_button = 'Save configuration';
  $this
    ->drupalPostForm($this->settingsPath, $edit_fields, $submit_button);
  $def_timestamp = \Drupal::state()
    ->get('acquia_spi_data.def_timestamp', 0);
  $this
    ->assertNotEqual($def_timestamp, 0, 'SPI definition timestamp set');
  $def_vars = \Drupal::state()
    ->get('acquia_spi_data.def_vars', []);
  $this
    ->assertNotEmpty($def_vars, 'SPI definition variable set');
  \Drupal::state()
    ->set('acquia_spi_data.def_waived_vars', [
    'test_variable_3',
  ]);

  // Test that new variables are in SPI data.
  $spi = new SpiController(\Drupal::service('acquia_connector.client'), \Drupal::service('config.factory'), \Drupal::service('path_alias.manager'));
  $spi_data = $spi
    ->get();
  $vars = Json::decode($spi_data['system_vars']);
  $this
    ->assertNotEmpty($vars['test_variable_1'], 'New variables included in SPI data');
  $this
    ->assertArrayNotHasKey('test_variable_3', $vars, 'test_variable_3 not included in SPI data');
}