public function __construct(array $configs)
 {
     foreach ($configs as $name => $config) {
         $check = new GuzzleHttpService($config['url'], $config['headers'], $config['options'], $config['status_code'], $config['content'], null, $config['method'], $config['body']);
         $check->setLabel(sprintf('Guzzle Http Service "%s"', $name));
         $this->checks[sprintf('guzzle_http_service_%s', $name)] = $check;
     }
 }
Example #2
0
 /**
  * @dataProvider checkProvider
  */
 public function testGuzzle4And5Check($content, $actualContent, $actualStatusCode, $resultClass, $method = 'GET', $body = null)
 {
     if (!class_exists('GuzzleHttp\\Client')) {
         $this->markTestSkipped('guzzlehttp/guzzle not installed.');
     }
     $check = new GuzzleHttpService('http://www.example.com/foobar', array(), array(), '200', $content, $this->getMockGuzzle4And5Client($actualStatusCode, $actualContent), $method, $body);
     $result = $check->check();
     $this->assertInstanceOf($resultClass, $result);
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function check()
 {
     $result = parent::check();
     if ($result instanceof Result\Success) {
         return $result;
     }
     $msg = $result->getMessage();
     $msg = preg_replace('=\\/\\/(.+):{1}(.+)(\\@){1}=i', '//', $msg);
     $failure = new Result\Failure($msg, $result->getData());
     return $failure;
 }
 /**
  * @dataProvider checkProvider
  */
 public function testCheck($content, $actualContent, $actualStatusCode, $resultClass, $method = 'GET', $body = null)
 {
     $check = new GuzzleHttpService('http://www.example.com/foobar', array(), array(), 200, $content, $this->getMockClient($actualStatusCode, $actualContent), $method, $body);
     $result = $check->check();
     $this->assertInstanceOf($resultClass, $result);
 }