1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13:
14: namespace Jyxo\Beholder\TestCase;
15:
16: 17: 18: 19: 20: 21: 22: 23: 24:
25: class XmlRpc extends \Jyxo\Beholder\TestCase
26: {
27: 28: 29: 30: 31:
32: private $url;
33:
34: 35: 36: 37: 38:
39: private $method;
40:
41: 42: 43: 44: 45:
46: private $params = array();
47:
48: 49: 50: 51: 52:
53: private $options = array();
54:
55: 56: 57: 58: 59:
60: private $timeout;
61:
62: 63: 64: 65: 66: 67: 68: 69: 70: 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: 85: 86: 87:
88: public function run()
89: {
90:
91: if (!extension_loaded('xmlrpc')) {
92: return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Extension xmlrpc missing');
93: }
94:
95:
96: if (!extension_loaded('curl')) {
97: return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::NOT_APPLICABLE, 'Extension curl missing');
98: }
99:
100:
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:
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:
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:
121: return new \Jyxo\Beholder\Result(\Jyxo\Beholder\Result::SUCCESS, $this->url);
122: }
123: }
124: