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

Commit afacb54

Browse files
committed
Добавлен скелет для юнит тестов
1 parent 28ff737 commit afacb54

File tree

3 files changed

+45
-16
lines changed

3 files changed

+45
-16
lines changed

events.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,14 @@ function GgrachAddDebugBar(&$content) {
1212
global $USER, $APPLICATION;
1313

1414
if (
15-
strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false) {
16-
return;
17-
}
18-
19-
if ($APPLICATION->GetProperty("save_kernel") == "Y") {
20-
return;
21-
}
22-
23-
if(!\is_object($USER))
24-
{
25-
return;
26-
}
27-
28-
if(!$USER->IsAdmin())
29-
{
15+
strpos($APPLICATION->GetCurDir(), "/bitrix/") !== false ||
16+
$APPLICATION->GetProperty("save_kernel") == "Y" ||
17+
!\is_object($USER) ||
18+
!$USER->IsAdmin()
19+
) {
3020
return;
3121
}
3222

3323
$logData = \GGrach\BitrixDebugger\Representer\DebugBarRepresenter::render(DD());
34-
$content = \str_replace('</body>', $logData . '</body>', $content);
24+
$content = \str_replace(['</body>', '</ body>', '</ body >', '</body >'], $logData . '</body>', $content);
3525
}

phpunit.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit bootstrap="bitrix/modules/main/include/prolog_before.php">
3+
<testsuites>
4+
<testsuite name="Notice raw">
5+
<file>tests/NoticeRawTest.php</file>
6+
</testsuite>
7+
</testsuites>
8+
</phpunit>

tests/NoticeRawTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
use PHPUnit\Framework\TestCase;
4+
5+
class NoticeRawTest extends TestCase {
6+
7+
public function testNotice() {
8+
$stack = [];
9+
$this->assertSame(0, count($stack));
10+
11+
array_push($stack, 'foo');
12+
$this->assertSame('foo', $stack[count($stack) - 1]);
13+
$this->assertSame(1, count($stack));
14+
15+
$this->assertSame('foo', array_pop($stack));
16+
$this->assertSame(0, count($stack));
17+
}
18+
19+
public function testErrors() {
20+
21+
}
22+
23+
public function testSuccess() {
24+
25+
}
26+
27+
public function testWarning() {
28+
29+
}
30+
31+
}

0 commit comments

Comments
 (0)