Overview

Namespaces

  • Jyxo
    • Beholder
      • TestCase
    • Gettext
      • Parser
    • Input
      • Chain
      • Filter
      • Validator
    • Mail
      • Email
        • Attachment
      • Parser
      • Sender
    • Rpc
      • Json
      • Xml
    • Shell
    • Spl
    • Svn
    • Time
    • Webdav
  • PHP

Classes

  • FileSystem
  • HttpResponse
  • Imap
  • JsonRpc
  • Memcached
  • Mysql
  • Pgsql
  • PhpExtension
  • PhpVersion
  • PhpZend
  • Smtp
  • Webdav
  • XmlRpc
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  1: <?php
  2: 
  3: /**
  4:  * Jyxo PHP Library
  5:  *
  6:  * LICENSE
  7:  *
  8:  * This source file is subject to the new BSD license that is bundled
  9:  * with this package in the file license.txt.
 10:  * It is also available through the world-wide-web at this URL:
 11:  * https://github.com/jyxo/php/blob/master/license.txt
 12:  */
 13: 
 14: namespace Jyxo\Beholder\TestCase;
 15: 
 16: /**
 17:  * Tests XML-RPC server availability.
 18:  *
 19:  * @category Jyxo
 20:  * @package Jyxo\Beholder
 21:  * @copyright Copyright (c) 2005-2011 Jyxo, s.r.o.
 22:  * @license https://github.com/jyxo/php/blob/master/license.txt
 23:  * @author Jaroslav HanslĂ­k
 24:  */
 25: class XmlRpc extends \Jyxo\Beholder\TestCase
 26: {
 27:     /**
 28:      * XML-RPC server URL.
 29:      *
 30:      * @var string
 31:      */
 32:     private $url;
 33: 
 34:     /**
 35:      * Method name.
 36:      *
 37:      * @var string
 38:      */
 39:     private $method;
 40: 
 41:     /**
 42:      * Method parameters.
 43:      *
 44:      * @var string
 45:      */
 46:     private $params = array();
 47: 
 48:     /**
 49:      * Request options.
 50:      *
 51:      * @var array
 52:      */
 53:     private $options = array();
 54: 
 55:     /**
 56:      * Timeout.
 57:      *
 58:      * @var integer
 59:      */
 60:     private $timeout;
 61: 
 62:     /**
 63:      * Constructor.
 64:      *
 65:      * @param string $description Test description
 66:      * @param string $url Server URL
 67:      * @param string $method Method name
 68:      * @param array $params Method parameters
 69:      * @param array $options Request options
 70:      * @param integer $timeout Timeout
 71:      */
 72:     public function __construct($description, $url, $method, array $params, array $options = array(), $timeout = 2)
 73:     {
 74:         parent::__construct($description);
 75: 
 76:         $this->url = (string) $url;
 77:         $this->method = (string) $method;
 78:         $this->params = $params;
 79:         $this->options = $options;
 80:         $this->timeout = (int) $timeout;
 81:     }
 82: 
 83:     /**
 84:      * Performs the test.
 85:      *
 86:      * @return \Jyxo\Beholder\Result
 87:      */
 88:     public function run()
 89:     {
 90:         // The xmlrpc extension is required
 91:         if (!extension_loaded('xmlrpc')) {
 92:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Extension xmlrpc missing');
 93:         }
 94: 
 95:         // The curl extension is required
 96:         if (!extension_loaded('curl')) {
 97:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Extension curl missing');
 98:         }
 99: 
100:         // The \Jyxo\Rpc\Xml\Client class is required
101:         if (!class_exists('\Jyxo\Rpc\Xml\Client')) {
102:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Class \Jyxo\Rpc\Xml\Client missing');
103:         }
104: 
105:         // Create the RPC client
106:         $rpc = new \Jyxo\Rpc\Xml\Client();
107:         foreach ($this->options as $name => $value) {
108:             $rpc->setOption($name, $value);
109:         }
110:         $rpc->setUrl($this->url)
111:             ->setTimeout($this->timeout);
112: 
113:         // Send the request
114:         try {
115:             $rpc->send($this->method, $this->params);
116:         } catch (\Exception $e) {
117:             return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::FAILURE, $this->url);
118:         }
119: 
120:         // OK
121:         return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::SUCCESS, $this->url);
122:     }
123: }
124: 
Jyxo PHP Library API documentation generated by ApiGen 2.3.0