summaryrefslogtreecommitdiff
path: root/scripts/run-functional-tests.php
blob: 56a0da6d20b78d32d0b116e9fdb82cf229c8a415 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/php
<?php
// $Id$

/**
 * @file
 * This script can be run with browser or from command line.
 * You can provide class names of the tests you wish to run.
 * When this script is run from browser you can select which reporter to use html or xml.
 * For command line: php run_functional_tests.php SearchMatchTest,ProfileModuleTestSingle
 * For browser: http://yoursite.com/sites/all/modules/simpletest/run_all_tests.php?include=SearchMatchTest,ProfileModuleTestSingle&reporter=html
 * If none of these two options are provided all tests will be run.
 */

$tests = NULL;
$reporter = 'text';
$host = 'localhost';
$path = '';
array_shift($_SERVER['argv']); // throw away script name
while ($param = array_shift($_SERVER['argv'])) {
  switch ($param) {
    case '--url':
      $url = array_shift($_SERVER['argv']);
      $parse = parse_url($url);
      $host = $parse['host'];
      $path = $parse['path'];
      break;

    default:
      $tests = explode(',', $param);
      break;
  }
}

$_SERVER['HTTP_HOST'] = $host;
$_SERVER['REMOTE_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_ADDR'] = '127.0.0.1';
$_SERVER['SERVER_SOFTWARE'] = 'Apache';
$_SERVER['SERVER_NAME'] = 'localhost';
$_SERVER['REQUEST_URI'] = $path .'/';
$_SERVER['SCRIPT_NAME'] = $path .'/index.php';
$_SERVER['PHP_SELF'] = $path .'/index.php';
$_SERVER['HTTP_USER_AGENT'] = 'Drupal command line';

chdir(realpath(dirname(__FILE__) . '/..'));
require_once './includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

//load simpletest files
simpletest_load();

// If not in 'safe mode', increase the maximum execution time:
if (!ini_get('safe_mode')) {
  set_time_limit(360);
}

simpletest_run_tests($tests, $reporter);
?>