diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index b4776d5..f8d6ae8 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -317,6 +317,7 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun // this variable. if ($base_url) { putenv('SIMPLETEST_BASE_URL=' . $base_url); + putenv('BROWSERTEST_OUTPUT_DIRECTORY=' . \Drupal::service('file_system')->realpath('public://simpletest')); } $phpunit_bin = simpletest_phpunit_command(); @@ -324,6 +325,8 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun $phpunit_bin, '--log-junit', escapeshellarg($phpunit_file), + '--printer', + '\\\Drupal\\\Tests\\\Listeners\\\SimpletestUiPrinter', ); // Optimized for running a single test. @@ -357,6 +360,7 @@ function simpletest_phpunit_run_command(array $unescaped_test_classnames, $phpun putenv('SIMPLETEST_DB='); if ($base_url) { putenv('SIMPLETEST_BASE_URL='); + putenv('BROWSERTEST_OUTPUT_DIRECTORY='); } return $ret; } diff --git a/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php b/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php new file mode 100644 index 0000000..324bf1d --- /dev/null +++ b/core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php @@ -0,0 +1,43 @@ +container->get('file_system')->realpath('public://phpunit_junit.xml'); + // Prepare the default browser test output directory in the child site. + $this->container->get('file_system')->mkdir('public://simpletest'); + $status = 0; + $output = []; + simpletest_phpunit_run_command([SimpletestPhpunitBrowserTest::class], $phpunit_junit_file, $status, $output); + + // Check that there are
tags for the HTML output by + // SimpletestUiPrinter. + $this->assertEqual($output[18], 'HTML output was generated
'); + // Check that URLs are printed as HTML links. + $this->assertIdentical(strpos($output[19], '$0', $buffer); + // Make the output readable in HTML by breaking up lines properly. + $buffer = nl2br($buffer); + + print $buffer; + } + +}