You are here

public function RealTimeNotificationsTest::testScriptsAreIncludedIfUserHasPermissionAndAtLeastOneProviderHasDisabledFeature in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 tests/src/Functional/RealTimeNotificationsTest.php \Drupal\Tests\tmgmt_smartling\Functional\RealTimeNotificationsTest::testScriptsAreIncludedIfUserHasPermissionAndAtLeastOneProviderHasDisabledFeature()

At least one provider has enabled feature test.

Firebase scripts are included to the page if user has permission and at least one provider has disabled feature.

File

tests/src/Functional/RealTimeNotificationsTest.php, line 81

Class

RealTimeNotificationsTest
Real time notifications tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testScriptsAreIncludedIfUserHasPermissionAndAtLeastOneProviderHasDisabledFeature() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    $this->smartlingPluginProviderSettings['settings[enable_notifications]'] = FALSE;
    $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $this->smartlingPluginProviderSettings['settings[enable_notifications]'] = TRUE;
    $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
    $this
      ->loginAsAdmin([
      'see smartling messages',
    ]);
    $output = $this
      ->drupalGet('/admin/tmgmt/translators');
    $this
      ->assertTrue(strpos($output, 'https://www.gstatic.com/firebasejs/5.2.0/firebase-app.js') !== FALSE);
    $this
      ->assertTrue(strpos($output, 'https://www.gstatic.com/firebasejs/5.2.0/firebase-auth.js') !== FALSE);
    $this
      ->assertTrue(strpos($output, 'https://www.gstatic.com/firebasejs/5.2.0/firebase-database.js') !== FALSE);
    $this
      ->assertTrue(strpos($output, '/modules/contrib/tmgmt_smartling/js/notifications.js') !== FALSE);
    $this
      ->assertTrue(strpos($output, '/modules/contrib/tmgmt_smartling/css/notifications.css') !== FALSE);
  }
  else {
    $this
      ->fail("Smartling settings file for simpletests not found.");
  }
}