diff --git a/core/modules/simpletest/src/BrowserTestBase.php b/core/modules/simpletest/src/BrowserTestBase.php index bcc3cd5..70ea1f9 100644 --- a/core/modules/simpletest/src/BrowserTestBase.php +++ b/core/modules/simpletest/src/BrowserTestBase.php @@ -36,7 +36,6 @@ * Note that this class does not yet have feature parity with WebTestBase, so * WebTestBase should be used where possible. In particular, this class does * not yet have the following features: - * - verbose output - see https://www.drupal.org/node/2469721 * - ajax form emulation - see https://www.drupal.org/node/2469713 * * Tests extending BrowserTestBase must exist in the @@ -227,41 +226,6 @@ protected $preserveGlobalState = FALSE; /** - * Class name for verbose logging. - * - * @var string - */ - protected $verboseClassName; - - /** - * Directory name for verbose logging. - * - * @var string - */ - protected $verboseDirectory; - - /** - * Counter storage for verbose logging. - * - * @var string - */ - protected $verboseCounterStorage; - - /** - * Counter for verbose logging. - * - * @var int - */ - protected $verboseCounter = 1; - - /** - * Verbose output enabled. - * - * @var bool - */ - protected $verboseOutput = FALSE; - - /** * Initializes Mink sessions. */ protected function initMink() { @@ -403,15 +367,6 @@ protected function setUp() { } } } - - $verbose_directory = getenv('SIMPLETEST_VERBOSE_DIRECTORY'); - $this->verboseOutput = (bool) $verbose_directory; - $this->verboseClassName = str_replace("\\", "_", get_called_class()); - $this->verboseDirectory = rtrim($verbose_directory, '/'); - $this->verboseCounterStorage = $this->verboseDirectory . '/' . $this->verboseClassName . '.counter'; - if (is_file($this->verboseCounterStorage)) { - $this->verboseCounter = max(1, (int) file_get_contents($this->verboseCounterStorage)); - } } /** @@ -550,14 +505,6 @@ protected function drupalGet($path, array $options = array()) { // Ensure that any changes to variables in the other thread are picked up. $this->refreshVariables(); - if ($this->verboseOutput) { - $verbose = 'GET request to: ' . $url . - '
' . Html::escape(var_export(array_map(function($headers) {
- return implode(';', array_map('trim', $headers));
- }, $this->getSession()->getResponseHeaders()), TRUE)) . '';
- }
-
}
diff --git a/core/modules/simpletest/src/DebugBrowserTestBase.php b/core/modules/simpletest/src/DebugBrowserTestBase.php
new file mode 100644
index 0000000..b0d55ed
--- /dev/null
+++ b/core/modules/simpletest/src/DebugBrowserTestBase.php
@@ -0,0 +1,181 @@
+verboseOutput = (bool) $verbose_directory;
+ $this->verboseClassName = str_replace("\\", "_", get_called_class());
+ $this->verboseDirectory = rtrim($verbose_directory, '/');
+ $this->verboseCounterStorage = $this->verboseDirectory . '/' . $this->verboseClassName . '.counter';
+ $this->verboseTestId = str_replace('sites/simpletest/', '', $this->siteDirectory);
+ if (is_file($this->verboseCounterStorage)) {
+ $this->verboseCounter = max(1, (int) file_get_contents($this->verboseCounterStorage)) + 1;
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function drupalGet($path, array $options = array()) {
+ $out = parent::drupalGet($path, $options);
+ // The URL generator service is not necessarily available yet; e.g., in
+ // interactive installer tests.
+ if ($this->container->has('url_generator')) {
+ if (UrlHelper::isExternal($path)) {
+ $url = Url::fromUri($path, $options)->toString();
+ }
+ else {
+ // This is needed for language prefixing.
+ $options['path_processing'] = TRUE;
+ $url = Url::fromUri('base:/' . $path, $options)->toString();
+ }
+ }
+ else {
+ $url = $this->getAbsoluteUrl($path);
+ }
+ if ($this->verboseOutput) {
+ $verbose = 'GET request to: ' . $url .
+ '' . Html::escape(var_export(array_map(function($headers) {
+ return implode(';', array_map('trim', $headers));
+ }, $this->getSession()->getResponseHeaders()), TRUE)) . '';
+ }
+
+}
diff --git a/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
index d660b1f..e78e40c 100644
--- a/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
+++ b/core/modules/simpletest/tests/src/Functional/BrowserTestBaseTest.php
@@ -7,14 +7,14 @@
namespace Drupal\Tests\simpletest\Functional;
-use Drupal\simpletest\BrowserTestBase;
+use Drupal\simpletest\DebugBrowserTestBase;
/**
* Tests BrowserTestBase functionality.
*
* @group simpletest
*/
-class BrowserTestBaseTest extends BrowserTestBase {
+class BrowserTestBaseTest extends DebugBrowserTestBase {
/**
* Modules to enable.
diff --git a/core/tests/Drupal/Tests/Listeners/VerbosePrinter.php b/core/tests/Drupal/Tests/Listeners/VerbosePrinter.php
index ea3483b..723bf5f 100644
--- a/core/tests/Drupal/Tests/Listeners/VerbosePrinter.php
+++ b/core/tests/Drupal/Tests/Listeners/VerbosePrinter.php
@@ -17,7 +17,7 @@ class VerbosePrinter extends \PHPUnit_TextUI_ResultPrinter {
*/
public function __construct($out, $verbose, $colors, $debug, $numberOfColumns) {
parent::__construct($out, $verbose, $colors, $debug, $numberOfColumns);
- if ($verbose_directory = getenv('SIMPLETEST_VERBOSE_DIRECTORY')) {
+ if ($verbose_directory = getenv('BROWSERTEST_OUTPUT_DIRECTORY')) {
// Initialize verbose debugging.
$this->directory = rtrim($verbose_directory, '/');
// Check if directory exists.
@@ -48,9 +48,9 @@ public function printResult(\PHPUnit_Framework_TestResult $result) {
if (!$this->directory) {
$this->writeWithColor('bg-yellow, fg-black', 'No verbose output was generated');
$this->writeNewLine();
- $this->write('To generate verbose output for functional tests, set the SIMPLETEST_VERBOSE_DIRECTORY environment variable.');
+ $this->write('To generate verbose output for functional tests, set the BROWSERTEST_OUTPUT_DIRECTORY environment variable.');
$this->writeNewLine();
- $this->write('e.g export SIMPLETEST_VERBOSE_DIRECTORY="/path/to/webroot/sites/default/files/simpletest/verbose".');
+ $this->write('e.g export BROWSERTEST_OUTPUT_DIRECTORY="/path/to/webroot/sites/default/files/simpletest/verbose".');
$this->writeNewLine();
return;
}