Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit 6084506

Browse files
committed
Улучшен скелет для юнит тестов
1 parent afacb54 commit 6084506

File tree

5 files changed

+67
-50
lines changed

5 files changed

+67
-50
lines changed

initializer.php

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,53 +22,8 @@
2222
* include 'BitrixDebugger/initializer.php';
2323
*
2424
*/
25-
use Bitrix\Main\Page\Asset;
26-
27-
if (\php_sapi_name() !== 'cli') {
28-
29-
$ggrachDebuggerRootPath = str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__);
30-
31-
\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
32-
"\GGrach\BitrixDebugger\Debugger\Debugger" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/Debugger.php",
33-
"\GGrach\BitrixDebugger\Debugger\DebuggerShowModable" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/DebuggerShowModable.php",
34-
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Contract/ShowModableContract.php",
35-
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebuggerConfigurator.php",
36-
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebugBarConfigurator.php",
37-
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Cache/RuntimeCache.php",
38-
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
39-
"\GGrach\BitrixDebugger\Representer\DebugBarRepresenter" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Representer/DebugBarRepresenter.php",
40-
"\GGrach\Writer\FileWriter" => $ggrachDebuggerRootPath . "/src/Writer/FileWriter.php",
41-
"\GGrach\Writer\Contract\WritableContract" => $ggrachDebuggerRootPath . "/src/Writer/Contract/WritableContract.php"
42-
]);
43-
44-
$ggrachDebuggerConfigurator = new \GGrach\BitrixDebugger\Configurator\DebuggerConfigurator();
45-
$ggrachDebugBarConfigurator = new \GGrach\BitrixDebugger\Configurator\DebugBarConfigurator();
46-
47-
$ggrachDebuggerConfigurator->setLogPath('error', __DIR__ . '/logs/error.log');
48-
$ggrachDebuggerConfigurator->setLogPath('warning', __DIR__ . '/logs/warning.log');
49-
$ggrachDebuggerConfigurator->setLogPath('success', __DIR__ . '/logs/success.log');
50-
$ggrachDebuggerConfigurator->setLogPath('notice', __DIR__ . '/logs/notice.log');
51-
52-
$GLOBALS["DD"] = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
53-
54-
/*
55-
* code - отображать дебаг-данные в коде
56-
* debug_bar - отображать дебаг-данные в debug_bar
57-
*/
58-
$GLOBALS["DD"]->setShowModes(['code', 'debug_bar']);
59-
60-
function DD() {
61-
return $GLOBALS["DD"];
62-
}
63-
64-
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GLOBALS["DD"])) {
65-
66-
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
67-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/general.css');
68-
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
69-
70-
include 'functions.php';
71-
72-
include 'events.php';
73-
}
25+
if (\php_sapi_name() === 'cli') {
26+
include 'initializers/cli.php';
27+
} else {
28+
include 'initializers/server.php';
7429
}

initializers/cli.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?
2+
// Укажите ваш DOCUMENT_ROOT
3+
$_SERVER['DOCUMENT_ROOT'] = '/home/c/cq01452/public_html';
4+
5+
if (!empty($_SERVER['DOCUMENT_ROOT'])) {
6+
7+
$_SERVER['DOCUMENT_ROOT'] = rtrim($_SERVER['DOCUMENT_ROOT'], '/');
8+
9+
include 'server.php';
10+
}

initializers/server.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?
2+
3+
use Bitrix\Main\Page\Asset;
4+
5+
$_SERVER['DOCUMENT_ROOT'] = '';
6+
7+
$ggrachDebuggerRootPath = realpath(str_replace($_SERVER['DOCUMENT_ROOT'], '', __DIR__ . '/../'));
8+
$ggrachPathLogFolder = __DIR__ . $ggrachDebuggerRootPath . '/logs';
9+
10+
\Bitrix\Main\Loader::registerAutoLoadClasses(null, [
11+
"\GGrach\BitrixDebugger\Debugger\Debugger" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/Debugger.php",
12+
"\GGrach\BitrixDebugger\Debugger\DebuggerShowModable" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Debugger/DebuggerShowModable.php",
13+
"\GGrach\BitrixDebugger\Contract\ShowModableContract" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Contract/ShowModableContract.php",
14+
"\GGrach\BitrixDebugger\Configurator\DebuggerConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebuggerConfigurator.php",
15+
"\GGrach\BitrixDebugger\Configurator\DebugBarConfigurator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Configurator/DebugBarConfigurator.php",
16+
"\GGrach\BitrixDebugger\Cache\RuntimeCache" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Cache/RuntimeCache.php",
17+
"\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Validator/ShowModeDebuggerValidator.php",
18+
"\GGrach\BitrixDebugger\Representer\DebugBarRepresenter" => $ggrachDebuggerRootPath . "/src/BitrixDebugger/Representer/DebugBarRepresenter.php",
19+
"\GGrach\Writer\FileWriter" => $ggrachDebuggerRootPath . "/src/Writer/FileWriter.php",
20+
"\GGrach\Writer\Contract\WritableContract" => $ggrachDebuggerRootPath . "/src/Writer/Contract/WritableContract.php"
21+
]);
22+
23+
$ggrachDebuggerConfigurator = new \GGrach\BitrixDebugger\Configurator\DebuggerConfigurator();
24+
$ggrachDebugBarConfigurator = new \GGrach\BitrixDebugger\Configurator\DebugBarConfigurator();
25+
26+
$ggrachDebuggerConfigurator->setLogPath('error', $ggrachPathLogFolder . '/error.log');
27+
$ggrachDebuggerConfigurator->setLogPath('warning', $ggrachPathLogFolder . '/warning.log');
28+
$ggrachDebuggerConfigurator->setLogPath('success', $ggrachPathLogFolder . '/success.log');
29+
$ggrachDebuggerConfigurator->setLogPath('notice', $ggrachPathLogFolder . '/notice.log');
30+
31+
$GLOBALS["DD"] = new \GGrach\BitrixDebugger\Debugger\Debugger($ggrachDebuggerConfigurator, $ggrachDebugBarConfigurator);
32+
33+
/*
34+
* code - отображать дебаг-данные в коде
35+
* debug_bar - отображать дебаг-данные в debug_bar
36+
*/
37+
$GLOBALS["DD"]->setShowModes(['code', 'debug_bar']);
38+
39+
function DD() {
40+
return $GLOBALS["DD"];
41+
}
42+
43+
if (\GGrach\BitrixDebugger\Validator\ShowModeDebuggerValidator::needShowInDebugBar($GLOBALS["DD"])) {
44+
45+
Asset::getInstance()->addJs($ggrachDebuggerRootPath . "/assets/DebugBar/js/initializer.js");
46+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/general.css');
47+
Asset::getInstance()->addCss($ggrachDebuggerRootPath . '/assets/DebugBar/css/themes/' . $ggrachDebugBarConfigurator->getColorTheme() . '/theme.css');
48+
include '../functions.php';
49+
include '../events.php';
50+
}

phpunit.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--Bootstrap указываем относительно папки local/php_interface/BitrixDebugger чтобы выйти в DOCUMENT_ROOT-->
23
<phpunit bootstrap="bitrix/modules/main/include/prolog_before.php">
34
<testsuites>
45
<testsuite name="Notice raw">
5-
<file>tests/NoticeRawTest.php</file>
6+
<file>../../../../NoticeRawTest.php</file>
67
</testsuite>
78
</testsuites>
89
</phpunit>

tests/NoticeRawTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
class NoticeRawTest extends TestCase {
66

77
public function testNotice() {
8+
// @todo
89
$stack = [];
910
$this->assertSame(0, count($stack));
1011

0 commit comments

Comments
 (0)