You are here

public function SettingsTest::testJavaScriptAndDrupalSettings in Acquia Lift Connector 8

File

src/Tests/SettingsTest.php, line 128
Contains \Drupal\acquia_lift\Tests\SettingsTest.

Class

SettingsTest
Test Acquia Lift Settings.

Namespace

Drupal\acquia_lift\Tests

Code

public function testJavaScriptAndDrupalSettings() {
  $this
    ->setValidSettings();

  // Assert drupalSettings with identity query parameters on a non-node page.
  $this
    ->drupalGet('page-not-found', [
    'query' => [
      'my_identity_parameter' => 'an_identity',
    ],
  ]);
  $drupalSettings = $this
    ->getDrupalSettings();
  $this
    ->assertRaw('acquia_lift.js', '[testJavaScriptAndDrupalSettings]: With valid settings, acquia_lift.js is loaded on the home page.');
  $this
    ->assertEqual('account_name_1', $drupalSettings['acquia_lift']['credential']['account_name'], '[testJavaScriptAndDrupalSettings]: JavaScript settings contain credential.account_name.');
  $this
    ->assertEqual('Page not found', $drupalSettings['acquia_lift']['pageContext']['content_title'], '[testJavaScriptAndDrupalSettings]: JavaScript settings contain pageContext.content_page.content_title');
  $this
    ->assertEqual('an_identity', $drupalSettings['acquia_lift']['identity']['identity'], '[testJavaScriptAndDrupalSettings]: JavaScript settings contain identity.identity.');

  // Assert drupalSettings with identity query parameters on a node page.
  $this
    ->drupalGet('node/90210', [
    'query' => [
      'my_identity_parameter' => 'an_identity',
    ],
  ]);
  $drupalSettings = $this
    ->getDrupalSettings();
  $this
    ->assertRaw('acquia_lift.js', '[testJavaScriptAndDrupalSettings]: With valid settings, acquia_lift.js is loaded on the node page.');
  $this
    ->assertEqual('account_name_1', $drupalSettings['acquia_lift']['credential']['account_name'], '[testJavaScriptAndDrupalSettings]: JavaScript settings contain credential.account_name.');
  $this
    ->assertEqual(90210, $drupalSettings['acquia_lift']['pageContext']['post_id'], '[testJavaScriptAndDrupalSettings]: JavaScript settings contain pageContext.post_id.');
  $this
    ->assertEqual('an_identity', $drupalSettings['acquia_lift']['identity']['identity'], '[testJavaScriptAndDrupalSettings]: JavaScript settings contain identity.identity.');
}