public function RealTimeNotificationsTest::testScriptsAreIncludedIfUserHasPermission in TMGMT Translator Smartling 8.4
Same name and namespace in other branches
- 8.3 tests/src/Functional/RealTimeNotificationsTest.php \Drupal\Tests\tmgmt_smartling\Functional\RealTimeNotificationsTest::testScriptsAreIncludedIfUserHasPermission()
Permission test.
Firebase scripts are included to the page if user has permission nad feature is enabled.
File
- tests/
src/ Functional/ RealTimeNotificationsTest.php, line 18
Class
- RealTimeNotificationsTest
- Real time notifications tests.
Namespace
Drupal\Tests\tmgmt_smartling\FunctionalCode
public function testScriptsAreIncludedIfUserHasPermission() {
if (!empty($this->smartlingPluginProviderSettings)) {
$this
->setUpSmartlingProviderSettings($this->smartlingPluginProviderSettings);
// Without permission scripts are not included.
$this
->loginAsAdmin();
$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);
$this
->drupalLogout();
// With permission scripts are 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.");
}
}