From 6e8c4a149c085ec2fe74778c61bf941e4fc611bf Mon Sep 17 00:00:00 2001 From: Eric Salter Date: Tue, 10 Mar 2015 13:54:29 -0400 Subject: [PATCH] Remove setVersion() method Removed per request --- src/Monolog/Handler/HipChatHandler.php | 19 ++++--------------- tests/Monolog/Handler/HipChatHandlerTest.php | 20 -------------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/src/Monolog/Handler/HipChatHandler.php b/src/Monolog/Handler/HipChatHandler.php index ee8e4b20..6b0fa985 100644 --- a/src/Monolog/Handler/HipChatHandler.php +++ b/src/Monolog/Handler/HipChatHandler.php @@ -97,6 +97,10 @@ class HipChatHandler extends SocketHandler */ public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text', $host = 'api.hipchat.com', $version = self::API_V1) { + if ($version == self::API_V1 && !$this->validateStringLength($name, static::MAXIMUM_NAME_LENGTH)) { + throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.'); + } + $connectionString = $useSSL ? 'ssl://'.$host.':443' : $host.':80'; parent::__construct($connectionString, $level, $bubble); @@ -106,21 +110,6 @@ class HipChatHandler extends SocketHandler $this->room = $room; $this->format = $format; $this->host = $host; - - $this->setVersion($version); - } - - /** - * Convenience method for setting the API version. Valid values are - * - HipChatHandler::API_V1 - * - HipChatHandler::API_V2 - * @param $version string the API version to use - */ - public function setVersion($version) { - if ($version == self::API_V1 && !$this->validateStringLength($this->name, static::MAXIMUM_NAME_LENGTH)) { - throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.'); - } - $this->version = $version; } diff --git a/tests/Monolog/Handler/HipChatHandlerTest.php b/tests/Monolog/Handler/HipChatHandlerTest.php index bf15e547..6b0e9767 100644 --- a/tests/Monolog/Handler/HipChatHandlerTest.php +++ b/tests/Monolog/Handler/HipChatHandlerTest.php @@ -35,18 +35,6 @@ class HipChatHandlerTest extends TestCase return $content; } - public function testCanSetVersionAfterCreate() { - $this->createHandler(); - $this->handler->setVersion('v2'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v2\/room\/room1\/notification\?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); - - return $content; - } - public function testWriteCustomHostHeader() { $this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar'); @@ -97,14 +85,6 @@ class HipChatHandlerTest extends TestCase $this->assertRegexp('/notify=0&message=test1&message_format=text&color=red$/', $content); } - /** - * @depends testCanSetVersionAfterCreate - */ - public function testWriteContentV2AfterCreate($content) - { - $this->assertRegexp('/notify=0&message=test1&message_format=text&color=red$/', $content); - } - public function testWriteWithComplexMessage() { $this->createHandler();