ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Handler\BrowserConsoleHandlerTest Class Reference

@covers Monolog\Handler\BrowserConsoleHandlerTest 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

@covers Monolog\Handler\BrowserConsoleHandlerTest

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.

28 {
29 $reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript');
30 $reflMethod->setAccessible(true);
31
32 return $reflMethod->invoke(null);
33 }

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

+ Here is the caller graph for this function:

◆ setUp()

Monolog\Handler\BrowserConsoleHandlerTest::setUp ( )
protected

Definition at line 22 of file BrowserConsoleHandlerTest.php.

23 {
25 }
static reset()
Forget all logged records.

References Monolog\Handler\BrowserConsoleHandler\reset().

+ Here is the call graph for this function:

◆ testAutolabel()

Monolog\Handler\BrowserConsoleHandlerTest::testAutolabel ( )

Definition at line 67 of file BrowserConsoleHandlerTest.php.

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) {
78c.log("%c%cfoo%c", "font-weight: normal", "background-color: blue; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
79c.log("%c%cbar%c", "font-weight: normal", "background-color: green; color: white; border-radius: 3px; padding: 0 2px 0 2px", "font-weight: normal");
80c.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);
82EOF;
83
84 $this->assertEquals($expected, $this->generateScript());
85 }
const EOF
How fgetc() reports an End Of File.
Definition: JSMin_lib.php:92
const DEBUG
Detailed debug information.
Definition: Logger.php:32
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19

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

+ Here is the call graph for this function:

◆ testConcurrentHandlers()

Monolog\Handler\BrowserConsoleHandlerTest::testConcurrentHandlers ( )

Definition at line 106 of file BrowserConsoleHandlerTest.php.

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) {
121c.log("%ctest1", "font-weight: normal");
122c.log("%ctest2", "font-weight: normal");
123c.log("%ctest3", "font-weight: normal");
124c.log("%ctest4", "font-weight: normal");
125}})(console);
126EOF;
127
128 $this->assertEquals($expected, $this->generateScript());
129 }

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

+ Here is the call graph for this function:

◆ testContext()

Monolog\Handler\BrowserConsoleHandlerTest::testContext ( )

Definition at line 87 of file BrowserConsoleHandlerTest.php.

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) {
96c.groupCollapsed("%ctest", "font-weight: normal");
97c.log("%c%s", "font-weight: bold", "Context");
98c.log("%s: %o", "foo", "bar");
99c.groupEnd();
100}})(console);
101EOF;
102
103 $this->assertEquals($expected, $this->generateScript());
104 }

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

+ Here is the call graph for this function:

◆ testEscaping()

Monolog\Handler\BrowserConsoleHandlerTest::testEscaping ( )

Definition at line 51 of file BrowserConsoleHandlerTest.php.

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) {
60c.log("%c[foo] %c\"bar\\n[baz]\"%c", "font-weight: normal", "color: red", "font-weight: normal");
61}})(console);
62EOF;
63
64 $this->assertEquals($expected, $this->generateScript());
65 }

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

+ Here is the call graph for this function:

◆ testStyling()

Monolog\Handler\BrowserConsoleHandlerTest::testStyling ( )

Definition at line 35 of file BrowserConsoleHandlerTest.php.

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) {
44c.log("%cfoo%cbar%c", "font-weight: normal", "color: red", "font-weight: normal");
45}})(console);
46EOF;
47
48 $this->assertEquals($expected, $this->generateScript());
49 }

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

+ Here is the call graph for this function:

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