view core/modules/simpletest/src/Tests/UiPhpUnitOutputTest.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children af1871eacc83
line wrap: on
line 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
 *
 * @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[19], 'HTML output was generated<br />');
    // Check that URLs are printed as HTML links.
    $this->assertIdentical(strpos($output[20], '<a href="http'), 0);
  }

}