mirror of
https://github.com/Seldaek/monolog.git
synced 2025-07-31 18:30:15 +02:00
added support for Pushover API priority brought up by SteveEdson in issue #187; the priority levels can be adjusted either through the handler's constructor or setters
This commit is contained in:
@@ -29,6 +29,7 @@ class PushoverHandlerTest extends TestCase
|
||||
public function testWriteHeader()
|
||||
{
|
||||
$this->createHandler();
|
||||
$this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
|
||||
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
@@ -48,7 +49,7 @@ class PushoverHandlerTest extends TestCase
|
||||
|
||||
public function testWriteWithComplexTitle()
|
||||
{
|
||||
$this->createHandler('myToken', 'myUser', 'Backup finished - SQL1');
|
||||
$this->createHandler('myToken', 'myUser', 'Backup finished - SQL1', Logger::EMERGENCY);
|
||||
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
@@ -59,6 +60,7 @@ class PushoverHandlerTest extends TestCase
|
||||
public function testWriteWithComplexMessage()
|
||||
{
|
||||
$this->createHandler();
|
||||
$this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
|
||||
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.'));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
@@ -70,6 +72,7 @@ class PushoverHandlerTest extends TestCase
|
||||
{
|
||||
$message = str_pad('test', 520, 'a');
|
||||
$this->createHandler();
|
||||
$this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications
|
||||
$this->handler->handle($this->getRecord(Logger::CRITICAL, $message));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
@@ -79,6 +82,26 @@ class PushoverHandlerTest extends TestCase
|
||||
$this->assertRegexp('/message=' . $expectedMessage . '&title/', $content);
|
||||
}
|
||||
|
||||
public function testWriteWithHighPriority()
|
||||
{
|
||||
$this->createHandler();
|
||||
$this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1'));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
|
||||
$this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=1$/', $content);
|
||||
}
|
||||
|
||||
public function testWriteWithEmergencyPriority()
|
||||
{
|
||||
$this->createHandler();
|
||||
$this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1'));
|
||||
fseek($this->res, 0);
|
||||
$content = fread($this->res, 1024);
|
||||
|
||||
$this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=2$/', $content);
|
||||
}
|
||||
|
||||
private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog')
|
||||
{
|
||||
$constructorArgs = array($token, $user, $title);
|
||||
|
Reference in New Issue
Block a user