-
Notifications
You must be signed in to change notification settings - Fork 8
/
cli.php
63 lines (52 loc) · 1.61 KB
/
cli.php
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
<?php
use Bitrix\Main\Event;
use Bitrix\Main\EventManager;
use WS\BUnit\Config;
$DOCUMENT_ROOT = $_SERVER["DOCUMENT_ROOT"];
define("NO_KEEP_STATISTIC", true);
define("NOT_CHECK_PERMISSIONS",true);
define('CHK_EVENT', true);
@set_time_limit(0);
$time = microtime(true);
require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_admin_before.php");
global $USER;
$USER->Authorize(1);
CModule::IncludeModule('ws.bunit');
$configFile = $DOCUMENT_ROOT . BX_ROOT . "/php_interface/bunit/config.php";
if (file_exists($configFile)) {
$fInclude = function () use ($configFile) {
global $APPLICATION;
global $USER;
global $DB;
include $configFile;
};
$fInclude();
}
$em = EventManager::getInstance();
$event = new Event("ws.bunit", "OnConfigure");
$config = Config::getDefaultConfig();
$event->setParameter("config", $config);
$em->send($event);
try {
$console = new \WS\BUnit\Console\Console($argv, $config);
$console->getWriter()
->setColor(0)
->printLine("xUnit framework for CMS Bitrix. Worksolutions company https://worksolutions.ru");
$console->getCommand()->execute();
} catch (Exception $e) {
$console->getWriter()
->setColor(\WS\BUnit\Console\Formatter\Output::COLOR_RED)
->printLine($e->getMessage());
}
$console->getWriter()
->setColor(0)
->printLine(
"--------------------------------------------------"
)
->printLine(
sprintf(
"Time: %0.3f sec, maximum memory usage: %0.2f Mb",
microtime(true) - $time,
memory_get_peak_usage()/1024/1024
)
);