SimpletestUiPrinter.php 645 B

1234567891011121314151617181920212223242526
  1. <?php
  2. namespace Drupal\Tests\Listeners;
  3. use Drupal\Component\Utility\Html;
  4. /**
  5. * Defines a class for providing html output links in the Simpletest UI.
  6. */
  7. class SimpletestUiPrinter extends HtmlOutputPrinter {
  8. /**
  9. * {@inheritdoc}
  10. */
  11. public function write($buffer) {
  12. $buffer = Html::escape($buffer);
  13. // Turn HTML output URLs into clickable link <a> tags.
  14. $url_pattern = '@https?://[^\s]+@';
  15. $buffer = preg_replace($url_pattern, '<a href="$0" target="_blank" title="$0">$0</a>', $buffer);
  16. // Make the output readable in HTML by breaking up lines properly.
  17. $buffer = nl2br($buffer);
  18. print $buffer;
  19. }
  20. }