You are here

function simpletest_phpunit_command in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/simpletest/simpletest.module \simpletest_phpunit_command()

Returns the command to run PHPUnit.

Return value

string The command that can be run through exec().

1 call to simpletest_phpunit_command()
simpletest_phpunit_run_command in core/modules/simpletest/simpletest.module
Executes the PHPUnit command.

File

core/modules/simpletest/simpletest.module, line 314
Provides testing functionality.

Code

function simpletest_phpunit_command() {

  // Load the actual autoloader being used and determine its filename using
  // reflection. We can determine the vendor directory based on that filename.
  $autoloader = (require \Drupal::root() . '/autoload.php');
  $reflector = new ReflectionClass($autoloader);
  $vendor_dir = dirname(dirname($reflector
    ->getFileName()));

  // Don't use the committed version in composer's bin dir if running on
  // windows.
  if (substr(PHP_OS, 0, 3) == 'WIN') {
    $php_executable_finder = new PhpExecutableFinder();
    $php = $php_executable_finder
      ->find();
    $phpunit_bin = escapeshellarg($php) . ' -f ' . escapeshellarg($vendor_dir . '/phpunit/phpunit/composer/bin/phpunit') . ' --';
  }
  else {
    $phpunit_bin = $vendor_dir . '/phpunit/phpunit/phpunit';
  }
  return $phpunit_bin;
}