Beispiel #1
0
 public function testMultipleSuccessfulMessages()
 {
     // times(4) didn't work with the mock object
     // I'll just do it manually for now
     $times_called = 0;
     $response = m::mock('Guzzle\\Http\\Message\\Response');
     $response->shouldReceive('getStatusCode')->andReturnUsing(function () use(&$times_called) {
         $times_called++;
         return 201;
     });
     $request = m::mock('Guzzle\\Http\\Message\\Request');
     $request->shouldReceive('send')->andReturn($response);
     $http = new Http('https://' . $this->config['subdomain'] . '.campfirenow.com/room/' . $this->config['room']);
     $http = m::mock($http);
     $http->shouldReceive('post')->withAnyArgs()->andReturn($request);
     $campfire = new Campfire($this->config, $http);
     $campfire->queue('Test 1');
     $campfire->queue('Test 2');
     $campfire->queue('Test 3');
     $this->assertTrue($campfire->send('Hello world'));
     $this->assertEquals($times_called, 4);
 }
Beispiel #2
0
 /**
  * Kicks everything off
  *
  * @return void
  */
 public function main()
 {
     $campfire = new Campfire(array('subdomain' => $this->getSubdomain(), 'room' => $this->getRoom(), 'key' => $this->getKey()));
     try {
         $campfire->send($this->getMsg());
     } catch (Exception $ex) {
         $msg = 'Failed to send message to Campfire: ' . $ex->getMessage();
         // Do we want this error to halt the rest of the build file
         if ($this->haltOnFailure) {
             throw new BuildException($msg);
         } else {
             $this->log($msg, Project::MSG_ERR);
             return;
         }
     }
     $this->log('Successfully sent message to Campfire', Project::MSG_INFO);
 }