public static function text($msg, $notify = false, $background = Message::BACKGROUND_YELLOW) { if (static::$client === null) { throw new RuntimeException('Must call init first'); } $message = new Message($notify, $background); $message->setText($msg); static::$client->send($message); }
public function testSendTextMessage() { $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest'); $entity->shouldReceive('send')->once(); $data = array('room_id' => 'egg', 'from' => 'spoon', 'message' => 'hello world', 'message_format' => 'text', 'notify' => false, 'color' => 'yellow', 'format' => 'json'); $http = m::mock('Guzzle\\Http\\Client'); $http->shouldReceive('post')->with('rooms/message?format=json&auth_token=123', array('Content-type' => 'application/x-www-form-urlencoded'), http_build_query($data))->andReturn($entity)->once(); $transport = new Guzzle('123', 'egg', 'spoon'); $transport->setHttp($http); Hippy::init(null, null, null, $transport); Hippy::text('hello world'); }