ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
Monolog\Handler\FlowdockHandlerTest Class Reference
+ Inheritance diagram for Monolog\Handler\FlowdockHandlerTest:
+ Collaboration diagram for Monolog\Handler\FlowdockHandlerTest:

Public Member Functions

 setUp ()
 
 testWriteHeader ()
 
 testWriteContent ($content)
 @depends testWriteHeader More...
 

Private Member Functions

 createHandler ($token='myToken')
 

Private Attributes

 $res
 
 $handler
 

Additional Inherited Members

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

Detailed Description

Member Function Documentation

◆ createHandler()

Monolog\Handler\FlowdockHandlerTest::createHandler (   $token = 'myToken')
private

Definition at line 62 of file FlowdockHandlerTest.php.

63 {
64 $constructorArgs = array($token, Logger::DEBUG);
65 $this->res = fopen('php://memory', 'a');
66 $this->handler = $this->getMock(
67 '\Monolog\Handler\FlowdockHandler',
68 array('fsockopen', 'streamSetTimeout', 'closeSocket'),
69 $constructorArgs
70 );
71
72 $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString');
73 $reflectionProperty->setAccessible(true);
74 $reflectionProperty->setValue($this->handler, 'localhost:1234');
75
76 $this->handler->expects($this->any())
77 ->method('fsockopen')
78 ->will($this->returnValue($this->res));
79 $this->handler->expects($this->any())
80 ->method('streamSetTimeout')
81 ->will($this->returnValue(true));
82 $this->handler->expects($this->any())
83 ->method('closeSocket')
84 ->will($this->returnValue(true));
85
86 $this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com'));
87 }
const DEBUG
Detailed debug information.
Definition: Logger.php:32

References Monolog\Logger\DEBUG.

Referenced by Monolog\Handler\FlowdockHandlerTest\testWriteHeader().

+ Here is the caller graph for this function:

◆ setUp()

Monolog\Handler\FlowdockHandlerTest::setUp ( )

Definition at line 34 of file FlowdockHandlerTest.php.

35 {
36 if (!extension_loaded('openssl')) {
37 $this->markTestSkipped('This test requires openssl to run');
38 }
39 }

◆ testWriteContent()

Monolog\Handler\FlowdockHandlerTest::testWriteContent (   $content)

@depends testWriteHeader

Definition at line 56 of file FlowdockHandlerTest.php.

57 {
58 $this->assertRegexp('/"source":"test_source"/', $content);
59 $this->assertRegexp('/"from_address":"source@test\.com"/', $content);
60 }

◆ testWriteHeader()

Monolog\Handler\FlowdockHandlerTest::testWriteHeader ( )

Definition at line 41 of file FlowdockHandlerTest.php.

42 {
43 $this->createHandler();
44 $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
45 fseek($this->res, 0);
46 $content = fread($this->res, 1024);
47
48 $this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
49
50 return $content;
51 }
const CRITICAL
Critical conditions.
Definition: Logger.php:64
getRecord($level=Logger::WARNING, $message='test', $context=array())
Definition: TestCase.php:19

References Monolog\Handler\FlowdockHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().

+ Here is the call graph for this function:

Field Documentation

◆ $handler

Monolog\Handler\FlowdockHandlerTest::$handler
private

Definition at line 32 of file FlowdockHandlerTest.php.

◆ $res

Monolog\Handler\FlowdockHandlerTest::$res
private

Definition at line 27 of file FlowdockHandlerTest.php.


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