WebprofilerTestBase.php in Devel 8.2
File
webprofiler/tests/src/FunctionalJavascript/WebprofilerTestBase.php
View source
<?php
namespace Drupal\Tests\webprofiler\FunctionalJavascript;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
use PHPUnit_Framework_AssertionFailedError;
abstract class WebprofilerTestBase extends JavascriptTestBase {
protected function waitForToolbar() {
$session = $this
->getSession();
$token = $this
->getToken();
$page = $session
->getPage();
$toolbar = $page
->findById('webprofiler' . $token);
$this
->assertTrue($toolbar
->hasClass('sf-toolbar'), 'Toolbar loader is present in page');
$session
->wait(1000, 'null !== document.getElementById(\'sfToolbarMainContent-' . $token . '\')');
return $token;
}
protected function getToken() {
$token = $this
->getSession()
->getResponseHeader('X-Debug-Token');
if (NULL === $token) {
throw new PHPUnit_Framework_AssertionFailedError();
}
return $token;
}
protected function loginForToolbar() {
$admin_user = $this
->drupalCreateUser([
'view webprofiler toolbar',
]);
$this
->drupalLogin($admin_user);
}
protected function loginForDashboard() {
$admin_user = $this
->drupalCreateUser([
'view webprofiler toolbar',
'access webprofiler',
]);
$this
->drupalLogin($admin_user);
}
protected function flushCache() {
$module_handler = \Drupal::moduleHandler();
$module_handler
->invokeAll('cache_flush');
}
}