function BrowserHtmlDebugTrait::initBrowserOutputFile
Same name in other branches
- 9 core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php \Drupal\Tests\BrowserHtmlDebugTrait::initBrowserOutputFile()
- 8.9.x core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php \Drupal\Tests\BrowserHtmlDebugTrait::initBrowserOutputFile()
- 11.x core/tests/Drupal/Tests/BrowserHtmlDebugTrait.php \Drupal\Tests\BrowserHtmlDebugTrait::initBrowserOutputFile()
Creates the directory to store browser output.
Creates the directory to store browser output in if a file to write URLs to has been created by \Drupal\Tests\Listeners\HtmlOutputPrinter.
1 call to BrowserHtmlDebugTrait::initBrowserOutputFile()
- BrowserTestBase::setUp in core/
tests/ Drupal/ Tests/ BrowserTestBase.php
File
-
core/
tests/ Drupal/ Tests/ BrowserHtmlDebugTrait.php, line 140
Class
- BrowserHtmlDebugTrait
- Provides the debug functions for browser tests.
Namespace
Drupal\TestsCode
protected function initBrowserOutputFile() {
$browser_output_file = getenv('BROWSERTEST_OUTPUT_FILE');
$this->htmlOutputEnabled = is_string($browser_output_file) && is_file($browser_output_file);
$this->htmlOutputBaseUrl = getenv('BROWSERTEST_OUTPUT_BASE_URL') ?: $GLOBALS['base_url'];
if ($this->htmlOutputEnabled) {
$this->htmlOutputFile = $browser_output_file;
$this->htmlOutputClassName = str_replace("\\", "_", static::class);
$this->htmlOutputDirectory = DRUPAL_ROOT . '/sites/simpletest/browser_output';
// Do not use the file_system service so this method can be called before
// it is available. Checks !is_dir() twice around mkdir() because a
// concurrent test might have made the directory and caused mkdir() to
// fail. In this case we can still use the directory even though we failed
// to make it.
if (!is_dir($this->htmlOutputDirectory) && !@mkdir($this->htmlOutputDirectory, 0775, TRUE) && !is_dir($this->htmlOutputDirectory)) {
throw new \RuntimeException(sprintf('Unable to create directory: %s', $this->htmlOutputDirectory));
}
if (!file_exists($this->htmlOutputDirectory . '/.htaccess')) {
file_put_contents($this->htmlOutputDirectory . '/.htaccess', "<IfModule mod_expires.c>\nExpiresActive Off\n</IfModule>\n");
}
$this->htmlOutputCounterStorage = $this->htmlOutputDirectory . '/' . $this->htmlOutputClassName . '.counter';
$this->htmlOutputTestId = str_replace('sites/simpletest/', '', $this->siteDirectory);
if (is_file($this->htmlOutputCounterStorage)) {
$this->htmlOutputCounter = max(1, (int) file_get_contents($this->htmlOutputCounterStorage)) + 1;
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.