Inheritance: implements rcrowe\Hippy\Transport\TransportInterface
Beispiel #1
0
 public function testPost()
 {
     $guzzle = new Guzzle('123', 'cog', 'vivalacrowe');
     $message = new Message(true, 'green');
     $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest');
     $entity->shouldReceive('send')->once();
     // Build up the data we are sending to Hipchat
     $data = array('room_id' => $guzzle->getRoom(), 'from' => $guzzle->getFrom(), 'message' => $message->getMessage(), 'message_format' => $message->getMessageFormat(), 'notify' => $message->getNotification(), 'color' => $message->getBackgroundColor(), '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();
     $guzzle->setHttp($http);
     $guzzle->send($message);
 }
Beispiel #2
0
 public function testQueuedMessages()
 {
     $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest');
     $entity->shouldReceive('send')->twice();
     $http = m::mock('Guzzle\\Http\\Client');
     $http->shouldReceive('post')->andReturn($entity)->twice();
     $transport = new Guzzle('123', 'cog', 'vivalacrowe');
     $transport->setHttp($http);
     $hippy = new Hippy($transport);
     $queue = new Queue();
     $queue->add(new Message(true, 'red'));
     $queue->add(new Message(false, 'random'));
     $hippy->send($queue);
 }
Beispiel #3
0
 public function testSendQueue()
 {
     $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest');
     $entity->shouldReceive('send')->twice();
     $http = m::mock('Guzzle\\Http\\Client');
     $http->shouldReceive('post')->andReturn($entity)->twice();
     $transport = new Guzzle('123', 'hippy', 'rcrowe');
     $transport->setHttp($http);
     $task = new PhingTask();
     $project = m::mock('Project');
     $project->shouldReceive('getProperty')->with('hipchat.notify')->andReturn(true)->twice();
     $project->shouldReceive('getProperty')->with('hipchat.background')->andReturn(Message::BACKGROUND_RANDOM)->twice();
     $task->setProject($project);
     $task->setText('test 1');
     $task->setHtml('test 2');
     $task->main($transport);
 }
Beispiel #4
0
 public function testSetHttp()
 {
     $guzzle = new Guzzle(null, null, null);
     $guzzle->setHttp(new Http('https://api.cogpowered.com/v1/'));
     $this->assertEquals($guzzle->getHttp()->getBaseUrl(), 'https://api.cogpowered.com/v1/');
 }
Beispiel #5
0
 public function testSendQueue()
 {
     $entity = m::mock('Guzzle\\Http\\Message\\EntityEnclosingRequest');
     $entity->shouldReceive('send')->times(3);
     $data = array('room_id' => 'egg', 'from' => 'spoon', 'message' => 'hello world', 'message_format' => 'html', 'notify' => false, 'color' => 'yellow', 'format' => 'json');
     $http = m::mock('Guzzle\\Http\\Client');
     $http->shouldReceive('post')->andReturn($entity)->times(3);
     $transport = new Guzzle('123', 'egg', 'spoon');
     $transport->setHttp($http);
     Hippy::init(null, null, null, $transport);
     Hippy::add('test 1');
     Hippy::addHtml('test 2');
     Hippy::add('test 3');
     Hippy::go();
 }