You are here

UiPhpUnitOutputTest.php in SimpleTest 8.3

File

src/Tests/UiPhpUnitOutputTest.php
View source
<?php

namespace Drupal\simpletest\Tests;

use Drupal\simpletest\WebTestBase;
use Drupal\Tests\simpletest\Functional\SimpletestPhpunitBrowserTest;

/**
 * Test PHPUnit output for the Simpletest UI.
 *
 * @group simpletest
 * @group legacy
 *
 * @see \Drupal\Tests\Listeners\SimpletestUiPrinter
 */
class UiPhpUnitOutputTest extends WebTestBase {

  /**
   * Modules to enable.
   *
   * @var string[]
   */
  public static $modules = [
    'simpletest',
  ];

  /**
   * Tests that PHPUnit output in the Simpletest UI looks good.
   */
  public function testOutput() {
    require_once __DIR__ . '/../../tests/fixtures/simpletest_phpunit_browsertest.php';
    $phpunit_junit_file = $this->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 <br> tags for the HTML output by
    // SimpletestUiPrinter.
    $this
      ->assertEqual($output[20], 'HTML output was generated<br />');

    // Check that URLs are printed as HTML links.
    $this
      ->assertIdentical(strpos($output[21], '<a href="http'), 0);
  }

}

Classes

Namesort descending Description
UiPhpUnitOutputTest Test PHPUnit output for the Simpletest UI.