-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathBootstrapper.php
More file actions
68 lines (53 loc) · 1.7 KB
/
Bootstrapper.php
File metadata and controls
68 lines (53 loc) · 1.7 KB
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
59
60
61
62
63
64
65
66
67
<?php
namespace Dms\Common\Testing;
use Dms\Common\Testing\Runner\BrowserTestRunner;
use Dms\Common\Testing\Runner\CliTestRunner;
use Dms\Common\Testing\Runner\TestRunner;
abstract class Bootstrapper
{
private static $template = './Views/test-results.php';
private function __construct()
{
}
public static function run(
$namespace,
$directory,
$configurationPath,
$timeLimit = null
) {
error_reporting(-1);
ini_set('display_errors', 'On');
set_time_limit($timeLimit ?: 0);
@date_default_timezone_set(@date_default_timezone_get());
PhpunitBlacklist::load();
$fullConfigurationPath = $directory . DIRECTORY_SEPARATOR . $configurationPath;
if (PHP_SAPI === 'cli') {
self::runForCli($namespace, $fullConfigurationPath);
} else {
self::runForBrowser($namespace, $fullConfigurationPath);
}
}
public static function runForCli(
$namespace,
$fullConfigurationPath
) {
$testRunner = new CliTestRunner($fullConfigurationPath);
$testRunner->run();
}
public static function runForBrowser(
$namespace,
$fullConfigurationPath
) {
$title = $namespace . ': Automated regression test suite';
$testRunner = new BrowserTestRunner($fullConfigurationPath);
self::loadTestTemplate(self::$template, $title, $testRunner);
}
private static function loadTestTemplate($template, $title, TestRunner $runner)
{
require __DIR__ . '/' . $template;
}
public static function setBrowserTemplate($path)
{
self::$template = $path;
}
}