You are here

function SimpletestPhpunitRunCommandTest::testSimpletestPhpUnitRunCommand in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/tests/src/Unit/SimpletestPhpunitRunCommandTest.php \Drupal\Tests\simpletest\Unit\SimpletestPhpunitRunCommandTest::testSimpletestPhpUnitRunCommand()

File

core/modules/simpletest/tests/src/Unit/SimpletestPhpunitRunCommandTest.php, line 23
Contains \Drupal\Tests\simpletest\Unit\SimpletestPhpunitRunCommandTest.

Class

SimpletestPhpunitRunCommandTest
Tests simpletest_run_phpunit_tests() handles PHPunit fatals correctly.

Namespace

Drupal\Tests\simpletest\Unit

Code

function testSimpletestPhpUnitRunCommand() {
  include_once __DIR__ . '/../../fixtures/simpletest_phpunit_run_command_test.php';
  $app_root = __DIR__ . '/../../../../../..';
  include_once "{$app_root}/core/modules/simpletest/simpletest.module";
  $container = new ContainerBuilder();
  $container
    ->set('app.root', $app_root);
  $file_system = $this
    ->prophesize('Drupal\\Core\\File\\FileSystemInterface');
  $file_system
    ->realpath('public://simpletest')
    ->willReturn(sys_get_temp_dir());
  $container
    ->set('file_system', $file_system
    ->reveal());
  \Drupal::setContainer($container);
  $test_id = basename(tempnam(sys_get_temp_dir(), 'xxx'));
  foreach ([
    'pass',
    'fail',
  ] as $status) {
    putenv('SimpletestPhpunitRunCommandTestWillDie=' . $status);
    $ret = simpletest_run_phpunit_tests($test_id, [
      'Drupal\\Tests\\simpletest\\Unit\\SimpletestPhpunitRunCommandTestWillDie',
    ]);
    $this
      ->assertSame($ret[0]['status'], $status);
  }
  unlink(simpletest_phpunit_xml_filepath($test_id));
}