|
| createHandler ($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1') |
|
◆ createHandler()
Monolog\Handler\HipChatHandlerTest::createHandler |
( |
|
$token = 'myToken' , |
|
|
|
$room = 'room1' , |
|
|
|
$name = 'Monolog' , |
|
|
|
$notify = false , |
|
|
|
$host = 'api.hipchat.com' , |
|
|
|
$version = 'v1' |
|
) |
| |
|
private |
Definition at line 239 of file HipChatHandlerTest.php.
References $name, PHPMailer\PHPMailer\$token, $version, Monolog\Logger\DEBUG, and Monolog\TestCase\getIdentityFormatter().
Referenced by Monolog\Handler\HipChatHandlerTest\testHandleBatch(), Monolog\Handler\HipChatHandlerTest\testRoomSpaces(), Monolog\Handler\HipChatHandlerTest\testWriteContentV1WithoutName(), Monolog\Handler\HipChatHandlerTest\testWriteContentV2WithoutName(), Monolog\Handler\HipChatHandlerTest\testWriteCustomHostHeader(), Monolog\Handler\HipChatHandlerTest\testWriteHeader(), Monolog\Handler\HipChatHandlerTest\testWriteTruncatesLongMessage(), Monolog\Handler\HipChatHandlerTest\testWriteV2(), Monolog\Handler\HipChatHandlerTest\testWriteV2Notify(), Monolog\Handler\HipChatHandlerTest\testWriteWithComplexMessage(), and Monolog\Handler\HipChatHandlerTest\testWriteWithErrorLevelsAndColors().
242 $this->res =
fopen(
'php://memory',
'a');
243 $this->handler = $this->getMock(
244 '\Monolog\Handler\HipChatHandler',
245 array(
'fsockopen',
'streamSetTimeout',
'closeSocket'),
249 $reflectionProperty = new \ReflectionProperty(
'\Monolog\Handler\SocketHandler',
'connectionString');
250 $reflectionProperty->setAccessible(
true);
251 $reflectionProperty->setValue($this->handler,
'localhost:1234');
253 $this->handler->expects($this->any())
254 ->method(
'fsockopen')
255 ->will($this->returnValue($this->res));
256 $this->handler->expects($this->any())
257 ->method(
'streamSetTimeout')
258 ->will($this->returnValue(
true));
259 $this->handler->expects($this->any())
260 ->method(
'closeSocket')
261 ->will($this->returnValue(
true));
const DEBUG
Detailed debug information.
◆ provideBatchRecords()
Monolog\Handler\HipChatHandlerTest::provideBatchRecords |
( |
| ) |
|
Definition at line 205 of file HipChatHandlerTest.php.
References Monolog\Logger\CRITICAL, Monolog\Logger\DEBUG, Monolog\Logger\NOTICE, and Monolog\Logger\WARNING.
210 array(
'level' =>
Logger::WARNING,
'message' =>
'Oh bugger!',
'level_name' =>
'warning',
'datetime' =>
new \
DateTime()),
211 array(
'level' =>
Logger::NOTICE,
'message' =>
'Something noticeable happened.',
'level_name' =>
'notice',
'datetime' =>
new \
DateTime()),
212 array(
'level' =>
Logger::CRITICAL,
'message' =>
'Everything is broken!',
'level_name' =>
'critical',
'datetime' =>
new \
DateTime()),
218 array(
'level' =>
Logger::WARNING,
'message' =>
'Oh bugger!',
'level_name' =>
'warning',
'datetime' =>
new \
DateTime()),
219 array(
'level' =>
Logger::NOTICE,
'message' =>
'Something noticeable happened.',
'level_name' =>
'notice',
'datetime' =>
new \
DateTime()),
225 array(
'level' =>
Logger::DEBUG,
'message' =>
'Just debugging.',
'level_name' =>
'debug',
'datetime' =>
new \
DateTime()),
226 array(
'level' =>
Logger::NOTICE,
'message' =>
'Something noticeable happened.',
'level_name' =>
'notice',
'datetime' =>
new \
DateTime()),
232 array(
'level' =>
Logger::DEBUG,
'message' =>
'Just debugging.',
'level_name' =>
'debug',
'datetime' =>
new \
DateTime()),
const NOTICE
Uncommon events.
const DEBUG
Detailed debug information.
const WARNING
Exceptional occurrences that are not errors.
const CRITICAL
Critical conditions.
◆ provideLevelColors()
Monolog\Handler\HipChatHandlerTest::provideLevelColors |
( |
| ) |
|
◆ testCreateWithTooLongName()
Monolog\Handler\HipChatHandlerTest::testCreateWithTooLongName |
( |
| ) |
|
InvalidArgumentException
Definition at line 269 of file HipChatHandlerTest.php.
271 $hipChatHandler =
new HipChatHandler(
'token',
'room',
'SixteenCharsHere');
◆ testCreateWithTooLongNameV2()
Monolog\Handler\HipChatHandlerTest::testCreateWithTooLongNameV2 |
( |
| ) |
|
◆ testHandleBatch()
Monolog\Handler\HipChatHandlerTest::testHandleBatch |
( |
|
$records, |
|
|
|
$expectedColor |
|
) |
| |
◆ testRoomSpaces()
Monolog\Handler\HipChatHandlerTest::testRoomSpaces |
( |
| ) |
|
Definition at line 75 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
77 $this->
createHandler(
'myToken',
'room name',
'Monolog',
false,
'hipchat.foo.bar',
'v2');
80 $content = fread($this->res, 1024);
82 $this->assertRegexp(
'/POST \/v2\/room\/room%20name\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteContent()
Monolog\Handler\HipChatHandlerTest::testWriteContent |
( |
|
$content | ) |
|
testWriteHeader
Definition at line 90 of file HipChatHandlerTest.php.
92 $this->assertRegexp(
'/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content);
◆ testWriteContentNotify()
Monolog\Handler\HipChatHandlerTest::testWriteContentNotify |
( |
|
$content | ) |
|
testWriteCustomHostHeader
Definition at line 110 of file HipChatHandlerTest.php.
112 $this->assertRegexp(
'/notify=1&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content);
◆ testWriteContentV1WithoutName()
Monolog\Handler\HipChatHandlerTest::testWriteContentV1WithoutName |
( |
| ) |
|
Definition at line 95 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
97 $this->
createHandler(
'myToken',
'room1', null,
false,
'hipchat.foo.bar',
'v1');
100 $content = fread($this->res, 1024);
102 $this->assertRegexp(
'/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=$/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteContentV2()
Monolog\Handler\HipChatHandlerTest::testWriteContentV2 |
( |
|
$content | ) |
|
testWriteV2
Definition at line 118 of file HipChatHandlerTest.php.
120 $this->assertRegexp(
'/notify=false&message=test1&message_format=text&color=red&from=Monolog$/', $content);
◆ testWriteContentV2Notify()
Monolog\Handler\HipChatHandlerTest::testWriteContentV2Notify |
( |
|
$content | ) |
|
testWriteV2Notify
Definition at line 126 of file HipChatHandlerTest.php.
128 $this->assertRegexp(
'/notify=true&message=test1&message_format=text&color=red&from=Monolog$/', $content);
◆ testWriteContentV2WithoutName()
Monolog\Handler\HipChatHandlerTest::testWriteContentV2WithoutName |
( |
| ) |
|
Definition at line 131 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
133 $this->
createHandler(
'myToken',
'room1', null,
false,
'hipchat.foo.bar',
'v2');
135 fseek($this->res, 0);
136 $content = fread($this->res, 1024);
138 $this->assertRegexp(
'/notify=false&message=test1&message_format=text&color=red$/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteCustomHostHeader()
Monolog\Handler\HipChatHandlerTest::testWriteCustomHostHeader |
( |
| ) |
|
Definition at line 39 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
41 $this->
createHandler(
'myToken',
'room1',
'Monolog',
true,
'hipchat.foo.bar');
44 $content = fread($this->res, 1024);
46 $this->assertRegexp(
'/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteHeader()
Monolog\Handler\HipChatHandlerTest::testWriteHeader |
( |
| ) |
|
Definition at line 27 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
32 $content = fread($this->res, 1024);
34 $this->assertRegexp(
'/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: api.hipchat.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteTruncatesLongMessage()
Monolog\Handler\HipChatHandlerTest::testWriteTruncatesLongMessage |
( |
| ) |
|
Definition at line 153 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
157 fseek($this->res, 0);
158 $content = fread($this->res, 12000);
160 $this->assertRegexp(
'/message='.str_repeat(
'abcde', 1900).
'\+%5Btruncated%5D/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteV2()
Monolog\Handler\HipChatHandlerTest::testWriteV2 |
( |
| ) |
|
Definition at line 51 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
53 $this->
createHandler(
'myToken',
'room1',
'Monolog',
false,
'hipchat.foo.bar',
'v2');
56 $content = fread($this->res, 1024);
58 $this->assertRegexp(
'/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteV2Notify()
Monolog\Handler\HipChatHandlerTest::testWriteV2Notify |
( |
| ) |
|
Definition at line 63 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
65 $this->
createHandler(
'myToken',
'room1',
'Monolog',
true,
'hipchat.foo.bar',
'v2');
68 $content = fread($this->res, 1024);
70 $this->assertRegexp(
'/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteWithComplexMessage()
Monolog\Handler\HipChatHandlerTest::testWriteWithComplexMessage |
( |
| ) |
|
Definition at line 143 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), Monolog\Logger\CRITICAL, and Monolog\TestCase\getRecord().
147 fseek($this->res, 0);
148 $content = fread($this->res, 1024);
150 $this->assertRegexp(
'/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
const CRITICAL
Critical conditions.
◆ testWriteWithErrorLevelsAndColors()
Monolog\Handler\HipChatHandlerTest::testWriteWithErrorLevelsAndColors |
( |
|
$level, |
|
|
|
$expectedColor |
|
) |
| |
provideLevelColors
Definition at line 166 of file HipChatHandlerTest.php.
References Monolog\Handler\HipChatHandlerTest\createHandler(), and Monolog\TestCase\getRecord().
169 $this->handler->handle($this->
getRecord($level,
'Backup of database "example" finished in 16 minutes.'));
170 fseek($this->res, 0);
171 $content = fread($this->res, 1024);
173 $this->assertRegexp(
'/color='.$expectedColor.
'/', $content);
createHandler($token='myToken', $room='room1', $name='Monolog', $notify=false, $host='api.hipchat.com', $version='v1')
getRecord($level=Logger::WARNING, $message='test', $context=array())
◆ $handler
Monolog\Handler\HipChatHandlerTest::$handler |
|
private |
◆ $res
Monolog\Handler\HipChatHandlerTest::$res |
|
private |
The documentation for this class was generated from the following file: