ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Monolog\Handler\BrowserConsoleHandlerTest Class Reference

Monolog More...

+ Inheritance diagram for Monolog\Handler\BrowserConsoleHandlerTest:
+ Collaboration diagram for Monolog\Handler\BrowserConsoleHandlerTest:

Public Member Functions

 testStyling ()
 
 testEscaping ()
 
 testAutolabel ()
 
 testContext ()
 
 testConcurrentHandlers ()
 

Protected Member Functions

 setUp ()
 
 generateScript ()
 
- Protected Member Functions inherited from Monolog\TestCase
 getRecord ($level=Logger::WARNING, $message='test', $context=array())
 
 getMultipleRecords ()
 
 getIdentityFormatter ()
 

Detailed Description

Monolog

Definition at line 20 of file BrowserConsoleHandlerTest.php.

Member Function Documentation

◆ generateScript()

Monolog\Handler\BrowserConsoleHandlerTest::generateScript ( )
protected

Definition at line 27 of file BrowserConsoleHandlerTest.php.

Referenced by Monolog\Handler\BrowserConsoleHandlerTest\testAutolabel(), Monolog\Handler\BrowserConsoleHandlerTest\testConcurrentHandlers(), Monolog\Handler\BrowserConsoleHandlerTest\testContext(), Monolog\Handler\BrowserConsoleHandlerTest\testEscaping(), and Monolog\Handler\BrowserConsoleHandlerTest\testStyling().

28  {
29  $reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript');
30  $reflMethod->setAccessible(true);
31 
32  return $reflMethod->invoke(null);
33  }
+ Here is the caller graph for this function:

◆ setUp()

Monolog\Handler\BrowserConsoleHandlerTest::setUp ( )
protected

Definition at line 22 of file BrowserConsoleHandlerTest.php.

References Monolog\Handler\BrowserConsoleHandler\reset().

23  {
25  }
static reset()
Forget all logged records.
+ Here is the call graph for this function:

◆ testAutolabel()

Monolog\Handler\BrowserConsoleHandlerTest::testAutolabel ( )

Definition at line 67 of file BrowserConsoleHandlerTest.php.

References $handler, Monolog\Logger\DEBUG, EOF, Monolog\Handler\BrowserConsoleHandlerTest\generateScript(), Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

68  {
69  $handler = new BrowserConsoleHandler();
70  $handler->setFormatter($this->getIdentityFormatter());
71 
72  $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
73  $handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}'));
74  $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}'));
75 
76  $expected = <<<EOF
77 (function (c) {if (c && c.groupCollapsed) {
78 c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
79 c.log("%c%cbar%c", "font-weight: normal", "background-color: green; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
80 c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
81 }})(console);
82 EOF;
83 
84  $this->assertEquals($expected, $this->generateScript());
85  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

◆ testConcurrentHandlers()

Monolog\Handler\BrowserConsoleHandlerTest::testConcurrentHandlers ( )

Definition at line 106 of file BrowserConsoleHandlerTest.php.

References Monolog\Logger\DEBUG, EOF, Monolog\Handler\BrowserConsoleHandlerTest\generateScript(), Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

107  {
108  $handler1 = new BrowserConsoleHandler();
109  $handler1->setFormatter($this->getIdentityFormatter());
110 
111  $handler2 = new BrowserConsoleHandler();
112  $handler2->setFormatter($this->getIdentityFormatter());
113 
114  $handler1->handle($this->getRecord(Logger::DEBUG, 'test1'));
115  $handler2->handle($this->getRecord(Logger::DEBUG, 'test2'));
116  $handler1->handle($this->getRecord(Logger::DEBUG, 'test3'));
117  $handler2->handle($this->getRecord(Logger::DEBUG, 'test4'));
118 
119  $expected = <<<EOF
120 (function (c) {if (c && c.groupCollapsed) {
121 c.log("%ctest1", "font-weight: normal");
122 c.log("%ctest2", "font-weight: normal");
123 c.log("%ctest3", "font-weight: normal");
124 c.log("%ctest4", "font-weight: normal");
125 }})(console);
126 EOF;
127 
128  $this->assertEquals($expected, $this->generateScript());
129  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

◆ testContext()

Monolog\Handler\BrowserConsoleHandlerTest::testContext ( )

Definition at line 87 of file BrowserConsoleHandlerTest.php.

References $handler, array, Monolog\Logger\DEBUG, EOF, Monolog\Handler\BrowserConsoleHandlerTest\generateScript(), Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

88  {
89  $handler = new BrowserConsoleHandler();
90  $handler->setFormatter($this->getIdentityFormatter());
91 
92  $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar')));
93 
94  $expected = <<<EOF
95 (function (c) {if (c && c.groupCollapsed) {
96 c.groupCollapsed("%ctest", "font-weight: normal");
97 c.log("%c%s", "font-weight: bold", "Context");
98 c.log("%s: %o", "foo", "bar");
99 c.groupEnd();
100 }})(console);
101 EOF;
102 
103  $this->assertEquals($expected, $this->generateScript());
104  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
Create styles array
The data for the language used.
$handler
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

◆ testEscaping()

Monolog\Handler\BrowserConsoleHandlerTest::testEscaping ( )

Definition at line 51 of file BrowserConsoleHandlerTest.php.

References $handler, Monolog\Logger\DEBUG, EOF, Monolog\Handler\BrowserConsoleHandlerTest\generateScript(), Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

52  {
53  $handler = new BrowserConsoleHandler();
54  $handler->setFormatter($this->getIdentityFormatter());
55 
56  $handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}"));
57 
58  $expected = <<<EOF
59 (function (c) {if (c && c.groupCollapsed) {
60 c.log("%c[foo] %c\"bar\\n[baz]\"%c", "font-weight: normal", "color: red", "font-weight: normal");
61 }})(console);
62 EOF;
63 
64  $this->assertEquals($expected, $this->generateScript());
65  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

◆ testStyling()

Monolog\Handler\BrowserConsoleHandlerTest::testStyling ( )

Definition at line 35 of file BrowserConsoleHandlerTest.php.

References $handler, Monolog\Logger\DEBUG, EOF, Monolog\Handler\BrowserConsoleHandlerTest\generateScript(), Monolog\TestCase\getIdentityFormatter(), and Monolog\TestCase\getRecord().

36  {
37  $handler = new BrowserConsoleHandler();
38  $handler->setFormatter($this->getIdentityFormatter());
39 
40  $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}'));
41 
42  $expected = <<<EOF
43 (function (c) {if (c && c.groupCollapsed) {
44 c.log("%cfoo%cbar%c", "font-weight: normal", "color: red", "font-weight: normal");
45 }})(console);
46 EOF;
47 
48  $this->assertEquals($expected, $this->generateScript());
49  }
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19
$handler
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
+ Here is the call graph for this function:

The documentation for this class was generated from the following file: