You are here

public function RealTimeNotificationsTest::testScriptsAreNotIncludedIfUserHasPermissionAndFeatureIsDisabled 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::testScriptsAreNotIncludedIfUserHasPermissionAndFeatureIsDisabled()

Disabled feature test.

Firebase scripts are not included to the page if user has permission and feature is disabled.

File

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

Class

RealTimeNotificationsTest
Real time notifications tests.

Namespace

Drupal\Tests\tmgmt_smartling\Functional

Code

public function testScriptsAreNotIncludedIfUserHasPermissionAndFeatureIsDisabled() {
  if (!empty($this->smartlingPluginProviderSettings)) {
    $this->smartlingPluginProviderSettings['settings[enable_notifications]'] = FALSE;
    $this
      ->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);

    // With permission but with disabled feature scripts are not included.
    $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.");
  }
}