@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
4 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | try{ |
7 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/',array('username' => 'admin','password'=>'asdf')); |
|
7 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password'=>'asdf')); |
|
8 | 8 | $SugarAPI->login(); |
9 | 9 | |
10 | 10 | $Accounts = $SugarAPI->filterRecords('Accounts')->setData(array('max_num'=> 5)); |
@@ -1,23 +1,23 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | |
4 | -require_once __DIR__ . '/../vendor/autoload.php'; |
|
4 | +require_once __DIR__.'/../vendor/autoload.php'; |
|
5 | 5 | |
6 | 6 | try{ |
7 | - $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/',array('username' => 'admin','password'=>'asdf')); |
|
7 | + $SugarAPI = new \SugarAPI\SDK\SugarAPI('instances.this/Ent/7700/', array('username' => 'admin', 'password'=>'asdf')); |
|
8 | 8 | $SugarAPI->login(); |
9 | 9 | $EP = $SugarAPI->filterRecords('Accounts'); |
10 | 10 | $response = $EP->execute()->getResponse(); |
11 | 11 | print_r($EP->getRequest()); |
12 | 12 | if ($response->getStatus()=='200'){ |
13 | 13 | $recordList = $response->getBody(false); |
14 | - $max=count($recordList->records); |
|
14 | + $max = count($recordList->records); |
|
15 | 15 | echo "found $max records from Filter Records request. <br>"; |
16 | - $number = rand(0,$max); |
|
16 | + $number = rand(0, $max); |
|
17 | 17 | $randomRecord = $recordList->records[$number]; |
18 | 18 | echo "Choose random record #$number, with ID: ".$randomRecord->id." <br>"; |
19 | 19 | |
20 | - $getRecord = $SugarAPI->getRecord('Accounts',$randomRecord->id)->execute(array( |
|
20 | + $getRecord = $SugarAPI->getRecord('Accounts', $randomRecord->id)->execute(array( |
|
21 | 21 | 'fields' => 'name' |
22 | 22 | )); |
23 | 23 | $response = $getRecord->getResponse(); |
@@ -90,7 +90,7 @@ |
||
90 | 90 | /** |
91 | 91 | * Always make sure to destroy Curl Resource |
92 | 92 | */ |
93 | - public function __destruct() { |
|
93 | + public function __destruct(){ |
|
94 | 94 | if ($this->status!==self::STATUS_CLOSED){ |
95 | 95 | curl_close($this->CurlRequest); |
96 | 96 | } |
@@ -90,7 +90,7 @@ |
||
90 | 90 | /** |
91 | 91 | * Always make sure to destroy Curl Resource |
92 | 92 | */ |
93 | - public function __destruct() { |
|
93 | + public function __destruct(){ |
|
94 | 94 | if ($this->status!==self::STATUS_CLOSED){ |
95 | 95 | curl_close($this->CurlRequest); |
96 | 96 | } |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | protected $accessToken; |
117 | 117 | |
118 | 118 | |
119 | - public function __construct($baseUrl,array $options = array()){ |
|
119 | + public function __construct($baseUrl, array $options = array()){ |
|
120 | 120 | $this->baseUrl = $baseUrl; |
121 | 121 | |
122 | - if (!empty($options)) { |
|
122 | + if (!empty($options)){ |
|
123 | 123 | $this->setOptions($options); |
124 | - }elseif(!$this->requiresOptions()){ |
|
124 | + }elseif (!$this->requiresOptions()){ |
|
125 | 125 | $this->configureURL(); |
126 | 126 | } |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * @inheritdoc |
149 | 149 | */ |
150 | - public function setAuth($accessToken) { |
|
150 | + public function setAuth($accessToken){ |
|
151 | 151 | $this->accessToken = $accessToken; |
152 | 152 | return $this; |
153 | 153 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @inheritdoc |
157 | 157 | */ |
158 | - public function setUrl($url) { |
|
158 | + public function setUrl($url){ |
|
159 | 159 | $this->Url = $url; |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * @inheritdoc |
165 | 165 | */ |
166 | - public function setRequest(RequestInterface $Request) { |
|
166 | + public function setRequest(RequestInterface $Request){ |
|
167 | 167 | $this->Request = $Request; |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * @inheritdoc |
173 | 173 | */ |
174 | - public function setResponse(ResponseInterface $Response) { |
|
174 | + public function setResponse(ResponseInterface $Response){ |
|
175 | 175 | $this->Response = $Response; |
176 | 176 | return $this; |
177 | 177 | } |
@@ -219,13 +219,13 @@ discard block |
||
219 | 219 | * @throws InvalidURLException |
220 | 220 | */ |
221 | 221 | public function execute($data = NULL){ |
222 | - $data = ($data === NULL?$this->Data:$data); |
|
222 | + $data = ($data===NULL?$this->Data:$data); |
|
223 | 223 | $this->configureData($data); |
224 | - if ($this->verifyOptions() && is_object($this->Request)) { |
|
224 | + if ($this->verifyOptions() && is_object($this->Request)){ |
|
225 | 225 | $this->configureRequest(); |
226 | 226 | $this->Request->send(); |
227 | 227 | }else{ |
228 | - throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
|
228 | + throw new InvalidRequestException(get_called_class(), "Request property not configured"); |
|
229 | 229 | } |
230 | 230 | return $this; |
231 | 231 | } |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @inheritdoc |
235 | 235 | */ |
236 | - public function authRequired() { |
|
236 | + public function authRequired(){ |
|
237 | 237 | return $this->_AUTH_REQUIRED; |
238 | 238 | } |
239 | 239 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @throws RequiredDataException |
244 | 244 | */ |
245 | 245 | protected function configureRequest(){ |
246 | - if ($this->verifyUrl()) { |
|
246 | + if ($this->verifyUrl()){ |
|
247 | 247 | $this->Request->setURL($this->Url); |
248 | 248 | } |
249 | - if ($this->verifyData() && !empty($this->Data)) { |
|
249 | + if ($this->verifyData() && !empty($this->Data)){ |
|
250 | 250 | $this->Request->setBody($this->Data); |
251 | 251 | } |
252 | 252 | $this->configureAuth(); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * Configures the authentication header on the Request object |
257 | 257 | */ |
258 | 258 | protected function configureAuth(){ |
259 | - if ($this->authRequired()) { |
|
259 | + if ($this->authRequired()){ |
|
260 | 260 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
261 | 261 | } |
262 | 262 | } |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | * @var $data |
267 | 267 | */ |
268 | 268 | protected function configureData($data){ |
269 | - if (!empty($this->_REQUIRED_DATA)&&is_array($data)){ |
|
269 | + if (!empty($this->_REQUIRED_DATA) && is_array($data)){ |
|
270 | 270 | $data = $this->configureDefaultData($data); |
271 | 271 | } |
272 | 272 | $this->setData($data); |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @return array |
279 | 279 | */ |
280 | 280 | protected function configureDefaultData(array $data){ |
281 | - foreach($this->_REQUIRED_DATA as $property => $value){ |
|
281 | + foreach ($this->_REQUIRED_DATA as $property => $value){ |
|
282 | 282 | if (!isset($data[$property]) && $value!==NULL){ |
283 | 283 | $data[$property] = $value; |
284 | 284 | } |
@@ -293,18 +293,18 @@ discard block |
||
293 | 293 | */ |
294 | 294 | protected function configureURL(){ |
295 | 295 | $url = $this->_URL; |
296 | - if ($this->requiresOptions()) { |
|
296 | + if ($this->requiresOptions()){ |
|
297 | 297 | $urlParts = explode("/", $this->_URL); |
298 | 298 | $o = 0; |
299 | - foreach ($urlParts as $key => $part) { |
|
300 | - if (strpos($part, "$") !== FALSE) { |
|
301 | - if (isset($this->Options[$o])) { |
|
299 | + foreach ($urlParts as $key => $part){ |
|
300 | + if (strpos($part, "$")!==FALSE){ |
|
301 | + if (isset($this->Options[$o])){ |
|
302 | 302 | $urlParts[$key] = $this->Options[$o]; |
303 | 303 | $o++; |
304 | 304 | } |
305 | 305 | } |
306 | 306 | } |
307 | - $url = implode($urlParts,"/"); |
|
307 | + $url = implode($urlParts, "/"); |
|
308 | 308 | } |
309 | 309 | $url = $this->baseUrl.$url; |
310 | 310 | $this->setUrl($url); |
@@ -316,9 +316,9 @@ discard block |
||
316 | 316 | * @throws InvalidURLException |
317 | 317 | */ |
318 | 318 | protected function verifyUrl(){ |
319 | - $UrlArray = explode("?",$this->Url); |
|
320 | - if (strpos($UrlArray[0],"$") !== FALSE){ |
|
321 | - throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
|
319 | + $UrlArray = explode("?", $this->Url); |
|
320 | + if (strpos($UrlArray[0], "$")!==FALSE){ |
|
321 | + throw new InvalidURLException(get_called_class(), "Configured URL is ".$this->Url); |
|
322 | 322 | } |
323 | 323 | return true; |
324 | 324 | } |
@@ -329,11 +329,11 @@ discard block |
||
329 | 329 | * @throws RequiredOptionsException |
330 | 330 | */ |
331 | 331 | protected function verifyOptions(){ |
332 | - $urlVarCount = substr_count($this->_URL,"$"); |
|
332 | + $urlVarCount = substr_count($this->_URL, "$"); |
|
333 | 333 | $optionCount = 0; |
334 | 334 | $optionCount += count($this->Options); |
335 | 335 | if ($urlVarCount>$optionCount){ |
336 | - throw new RequiredOptionsException(get_called_class(),"URL requires $urlVarCount options, only $optionCount provided."); |
|
336 | + throw new RequiredOptionsException(get_called_class(), "URL requires $urlVarCount options, only $optionCount provided."); |
|
337 | 337 | } |
338 | 338 | return true; |
339 | 339 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws RequiredDataException |
345 | 345 | */ |
346 | 346 | protected function verifyData(){ |
347 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
347 | + if (isset($this->_DATA_TYPE) || !empty($this->_DATA_TYPE)){ |
|
348 | 348 | $this->verifyDataType(); |
349 | 349 | } |
350 | 350 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | * @throws RequiredDataException |
360 | 360 | */ |
361 | 361 | protected function verifyDataType(){ |
362 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
363 | - throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
|
362 | + if (gettype($this->Data)!==$this->_DATA_TYPE){ |
|
363 | + throw new RequiredDataException(get_called_class(), "Valid DataType is {$this->_DATA_TYPE}"); |
|
364 | 364 | } |
365 | 365 | return true; |
366 | 366 | } |
@@ -372,13 +372,13 @@ discard block |
||
372 | 372 | */ |
373 | 373 | protected function verifyRequiredData(){ |
374 | 374 | $errors = array(); |
375 | - foreach($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
375 | + foreach ($this->_REQUIRED_DATA as $property => $defaultValue){ |
|
376 | 376 | if (!isset($this->Data[$property])){ |
377 | 377 | $errors[] = $property; |
378 | 378 | } |
379 | 379 | } |
380 | 380 | if (count($errors)>0){ |
381 | - throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
|
381 | + throw new RequiredDataException(get_called_class(), "Missing data for ".implode(",", $errors)); |
|
382 | 382 | } |
383 | 383 | return true; |
384 | 384 | } |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return bool |
389 | 389 | */ |
390 | 390 | protected function requiresOptions(){ |
391 | - return strpos($this->_URL,"$") === FALSE?FALSE:TRUE; |
|
391 | + return strpos($this->_URL, "$")===FALSE?FALSE:TRUE; |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | } |
395 | 395 | \ No newline at end of file |
@@ -119,9 +119,9 @@ discard block |
||
119 | 119 | public function __construct($baseUrl,array $options = array()){ |
120 | 120 | $this->baseUrl = $baseUrl; |
121 | 121 | |
122 | - if (!empty($options)) { |
|
122 | + if (!empty($options)){ |
|
123 | 123 | $this->setOptions($options); |
124 | - }elseif(!$this->requiresOptions()){ |
|
124 | + } elseif(!$this->requiresOptions()){ |
|
125 | 125 | $this->configureURL(); |
126 | 126 | } |
127 | 127 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | /** |
148 | 148 | * @inheritdoc |
149 | 149 | */ |
150 | - public function setAuth($accessToken) { |
|
150 | + public function setAuth($accessToken){ |
|
151 | 151 | $this->accessToken = $accessToken; |
152 | 152 | return $this; |
153 | 153 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | /** |
156 | 156 | * @inheritdoc |
157 | 157 | */ |
158 | - public function setUrl($url) { |
|
158 | + public function setUrl($url){ |
|
159 | 159 | $this->Url = $url; |
160 | 160 | return $this; |
161 | 161 | } |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | /** |
164 | 164 | * @inheritdoc |
165 | 165 | */ |
166 | - public function setRequest(RequestInterface $Request) { |
|
166 | + public function setRequest(RequestInterface $Request){ |
|
167 | 167 | $this->Request = $Request; |
168 | 168 | return $this; |
169 | 169 | } |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | /** |
172 | 172 | * @inheritdoc |
173 | 173 | */ |
174 | - public function setResponse(ResponseInterface $Response) { |
|
174 | + public function setResponse(ResponseInterface $Response){ |
|
175 | 175 | $this->Response = $Response; |
176 | 176 | return $this; |
177 | 177 | } |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | public function execute($data = NULL){ |
222 | 222 | $data = ($data === NULL?$this->Data:$data); |
223 | 223 | $this->configureData($data); |
224 | - if ($this->verifyOptions() && is_object($this->Request)) { |
|
224 | + if ($this->verifyOptions() && is_object($this->Request)){ |
|
225 | 225 | $this->configureRequest(); |
226 | 226 | $this->Request->send(); |
227 | - }else{ |
|
227 | + } else{ |
|
228 | 228 | throw new InvalidRequestException(get_called_class(),"Request property not configured"); |
229 | 229 | } |
230 | 230 | return $this; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | /** |
234 | 234 | * @inheritdoc |
235 | 235 | */ |
236 | - public function authRequired() { |
|
236 | + public function authRequired(){ |
|
237 | 237 | return $this->_AUTH_REQUIRED; |
238 | 238 | } |
239 | 239 | |
@@ -243,10 +243,10 @@ discard block |
||
243 | 243 | * @throws RequiredDataException |
244 | 244 | */ |
245 | 245 | protected function configureRequest(){ |
246 | - if ($this->verifyUrl()) { |
|
246 | + if ($this->verifyUrl()){ |
|
247 | 247 | $this->Request->setURL($this->Url); |
248 | 248 | } |
249 | - if ($this->verifyData() && !empty($this->Data)) { |
|
249 | + if ($this->verifyData() && !empty($this->Data)){ |
|
250 | 250 | $this->Request->setBody($this->Data); |
251 | 251 | } |
252 | 252 | $this->configureAuth(); |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * Configures the authentication header on the Request object |
257 | 257 | */ |
258 | 258 | protected function configureAuth(){ |
259 | - if ($this->authRequired()) { |
|
259 | + if ($this->authRequired()){ |
|
260 | 260 | $this->Request->addHeader('OAuth-Token', $this->accessToken); |
261 | 261 | } |
262 | 262 | } |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | */ |
294 | 294 | protected function configureURL(){ |
295 | 295 | $url = $this->_URL; |
296 | - if ($this->requiresOptions()) { |
|
296 | + if ($this->requiresOptions()){ |
|
297 | 297 | $urlParts = explode("/", $this->_URL); |
298 | 298 | $o = 0; |
299 | - foreach ($urlParts as $key => $part) { |
|
300 | - if (strpos($part, "$") !== FALSE) { |
|
301 | - if (isset($this->Options[$o])) { |
|
299 | + foreach ($urlParts as $key => $part){ |
|
300 | + if (strpos($part, "$") !== FALSE){ |
|
301 | + if (isset($this->Options[$o])){ |
|
302 | 302 | $urlParts[$key] = $this->Options[$o]; |
303 | 303 | $o++; |
304 | 304 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @throws RequiredDataException |
345 | 345 | */ |
346 | 346 | protected function verifyData(){ |
347 | - if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)) { |
|
347 | + if (isset($this->_DATA_TYPE)||!empty($this->_DATA_TYPE)){ |
|
348 | 348 | $this->verifyDataType(); |
349 | 349 | } |
350 | 350 | if (!empty($this->_REQUIRED_DATA)){ |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @throws RequiredDataException |
360 | 360 | */ |
361 | 361 | protected function verifyDataType(){ |
362 | - if (gettype($this->Data) !== $this->_DATA_TYPE) { |
|
362 | + if (gettype($this->Data) !== $this->_DATA_TYPE){ |
|
363 | 363 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
364 | 364 | } |
365 | 365 | return true; |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * Whether or not Authentication is Required |
45 | 45 | * @var bool |
46 | 46 | */ |
47 | - protected $_AUTH_REQUIRED = true; |
|
47 | + protected $_AUTH_REQUIRED = TRUE; |
|
48 | 48 | |
49 | 49 | /** |
50 | 50 | * The URL for the EntryPoint |
@@ -320,7 +320,7 @@ discard block |
||
320 | 320 | if (strpos($UrlArray[0],"$") !== FALSE){ |
321 | 321 | throw new InvalidURLException(get_called_class(),"Configured URL is ".$this->Url); |
322 | 322 | } |
323 | - return true; |
|
323 | + return TRUE; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | if ($urlVarCount>$optionCount){ |
336 | 336 | throw new RequiredOptionsException(get_called_class(),"URL requires $urlVarCount options, only $optionCount provided."); |
337 | 337 | } |
338 | - return true; |
|
338 | + return TRUE; |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | if (!empty($this->_REQUIRED_DATA)){ |
351 | 351 | $this->verifyRequiredData(); |
352 | 352 | } |
353 | - return true; |
|
353 | + return TRUE; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | if (gettype($this->Data) !== $this->_DATA_TYPE) { |
363 | 363 | throw new RequiredDataException(get_called_class(),"Valid DataType is {$this->_DATA_TYPE}"); |
364 | 364 | } |
365 | - return true; |
|
365 | + return TRUE; |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | if (count($errors)>0){ |
381 | 381 | throw new RequiredDataException(get_called_class(),"Missing data for ".implode(",",$errors)); |
382 | 382 | } |
383 | - return true; |
|
383 | + return TRUE; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -37,15 +37,15 @@ discard block |
||
37 | 37 | */ |
38 | 38 | public function testConfigureAPIUrl() |
39 | 39 | { |
40 | - $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('localhost')); |
|
41 | - $this->assertEquals('https://localhost/rest/v10/',Helpers::configureAPIURL('https://localhost')); |
|
42 | - $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('localhost/rest/v10')); |
|
43 | - $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('localhost/rest/v10/')); |
|
44 | - $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('http://localhost/rest/v10/')); |
|
45 | - $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('http://localhost/')); |
|
46 | - $this->assertEquals('https://localhost/rest/v10/',Helpers::configureAPIURL('https://localhost/rest/v10')); |
|
47 | - $this->assertEquals('https://localhost/rest/v10/',Helpers::configureAPIURL('https://localhost/rest/v10/')); |
|
48 | - $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('http://localhost/rest/v10/rest/v10/rest/v10')); |
|
40 | + $this->assertEquals('http://localhost/rest/v10/', Helpers::configureAPIURL('localhost')); |
|
41 | + $this->assertEquals('https://localhost/rest/v10/', Helpers::configureAPIURL('https://localhost')); |
|
42 | + $this->assertEquals('http://localhost/rest/v10/', Helpers::configureAPIURL('localhost/rest/v10')); |
|
43 | + $this->assertEquals('http://localhost/rest/v10/', Helpers::configureAPIURL('localhost/rest/v10/')); |
|
44 | + $this->assertEquals('http://localhost/rest/v10/', Helpers::configureAPIURL('http://localhost/rest/v10/')); |
|
45 | + $this->assertEquals('http://localhost/rest/v10/', Helpers::configureAPIURL('http://localhost/')); |
|
46 | + $this->assertEquals('https://localhost/rest/v10/', Helpers::configureAPIURL('https://localhost/rest/v10')); |
|
47 | + $this->assertEquals('https://localhost/rest/v10/', Helpers::configureAPIURL('https://localhost/rest/v10/')); |
|
48 | + $this->assertEquals('http://localhost/rest/v10/', Helpers::configureAPIURL('http://localhost/rest/v10/rest/v10/rest/v10')); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | /** |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | */ |
56 | 56 | public function testGetSDKVersion() |
57 | 57 | { |
58 | - $this->assertEquals('1.0',Helpers::getSDKVersion()); |
|
58 | + $this->assertEquals('1.0', Helpers::getSDKVersion()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -12,21 +12,17 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class HelpersTest extends \PHPUnit_Framework_TestCase { |
14 | 14 | |
15 | - public static function setUpBeforeClass() |
|
16 | - { |
|
15 | + public static function setUpBeforeClass(){ |
|
17 | 16 | } |
18 | 17 | |
19 | - public static function tearDownAfterClass() |
|
20 | - { |
|
18 | + public static function tearDownAfterClass(){ |
|
21 | 19 | } |
22 | 20 | |
23 | - public function setUp() |
|
24 | - { |
|
21 | + public function setUp(){ |
|
25 | 22 | parent::setUp(); |
26 | 23 | } |
27 | 24 | |
28 | - public function tearDown() |
|
29 | - { |
|
25 | + public function tearDown(){ |
|
30 | 26 | parent::tearDown(); |
31 | 27 | } |
32 | 28 | |
@@ -35,8 +31,7 @@ discard block |
||
35 | 31 | * @covers ::configureAPIURL |
36 | 32 | * @group default |
37 | 33 | */ |
38 | - public function testConfigureAPIUrl() |
|
39 | - { |
|
34 | + public function testConfigureAPIUrl(){ |
|
40 | 35 | $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('localhost')); |
41 | 36 | $this->assertEquals('https://localhost/rest/v10/',Helpers::configureAPIURL('https://localhost')); |
42 | 37 | $this->assertEquals('http://localhost/rest/v10/',Helpers::configureAPIURL('localhost/rest/v10')); |
@@ -53,8 +48,7 @@ discard block |
||
53 | 48 | * @covers ::getSDKVersion |
54 | 49 | * @group default |
55 | 50 | */ |
56 | - public function testGetSDKVersion() |
|
57 | - { |
|
51 | + public function testGetSDKVersion(){ |
|
58 | 52 | $this->assertEquals('1.0',Helpers::getSDKVersion()); |
59 | 53 | } |
60 | 54 |
@@ -57,15 +57,15 @@ |
||
57 | 57 | 'client_id' => 'sugar', |
58 | 58 | 'client_secret' => '', |
59 | 59 | 'platform' => 'api' |
60 | - ),$this->SugarAPI->getCredentials()); |
|
60 | + ), $this->SugarAPI->getCredentials()); |
|
61 | 61 | $this->SugarAPI->setCredentials(array('password' => 'asdf')); |
62 | - $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials()); |
|
62 | + $this->assertEquals($this->credentials, $this->SugarAPI->getCredentials()); |
|
63 | 63 | $this->SugarAPI->setCredentials(array()); |
64 | - $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials()); |
|
64 | + $this->assertEquals($this->credentials, $this->SugarAPI->getCredentials()); |
|
65 | 65 | $this->SugarAPI->setCredentials($this->credentials); |
66 | - $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials()); |
|
67 | - $this->SugarAPI->setCredentials(array('foo' => 'bar' )); |
|
68 | - $this->assertEquals($this->credentials,$this->SugarAPI->getCredentials()); |
|
66 | + $this->assertEquals($this->credentials, $this->SugarAPI->getCredentials()); |
|
67 | + $this->SugarAPI->setCredentials(array('foo' => 'bar')); |
|
68 | + $this->assertEquals($this->credentials, $this->SugarAPI->getCredentials()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
@@ -13,12 +13,10 @@ discard block |
||
13 | 13 | class SugarAPITest extends \PHPUnit_Framework_TestCase { |
14 | 14 | |
15 | 15 | |
16 | - public static function setUpBeforeClass() |
|
17 | - { |
|
16 | + public static function setUpBeforeClass(){ |
|
18 | 17 | } |
19 | 18 | |
20 | - public static function tearDownAfterClass() |
|
21 | - { |
|
19 | + public static function tearDownAfterClass(){ |
|
22 | 20 | } |
23 | 21 | |
24 | 22 | protected $SugarAPI; |
@@ -31,14 +29,12 @@ discard block |
||
31 | 29 | ); |
32 | 30 | |
33 | 31 | |
34 | - public function setUp() |
|
35 | - { |
|
32 | + public function setUp(){ |
|
36 | 33 | $this->SugarAPI = new SugarAPI(); |
37 | 34 | parent::setUp(); |
38 | 35 | } |
39 | 36 | |
40 | - public function tearDown() |
|
41 | - { |
|
37 | + public function tearDown(){ |
|
42 | 38 | unset($this->SugarAPI); |
43 | 39 | parent::tearDown(); |
44 | 40 | } |
@@ -48,8 +44,7 @@ discard block |
||
48 | 44 | * @covers ::setCredentials |
49 | 45 | * @group sugarapi |
50 | 46 | */ |
51 | - public function testSetCredentials() |
|
52 | - { |
|
47 | + public function testSetCredentials(){ |
|
53 | 48 | $this->SugarAPI->setCredentials(array('username' => 'admin')); |
54 | 49 | $this->assertEquals(array( |
55 | 50 | 'username' => 'admin', |
@@ -50,16 +50,16 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function testConstructor(){ |
52 | 52 | $Stub = new EntryPointStub($this->url); |
53 | - $this->assertEquals('',$Stub->getUrl()); |
|
54 | - $this->assertEquals(array(),$Stub->getOptions()); |
|
53 | + $this->assertEquals('', $Stub->getUrl()); |
|
54 | + $this->assertEquals(array(), $Stub->getOptions()); |
|
55 | 55 | $this->assertEmpty($Stub->getData()); |
56 | 56 | $this->assertEmpty($Stub->getRequest()); |
57 | 57 | $this->assertEmpty($Stub->getResponse()); |
58 | 58 | |
59 | 59 | unset($Stub); |
60 | - $Stub = new EntryPointStub($this->url,$this->options); |
|
61 | - $this->assertEquals($this->url.'foo',$Stub->getUrl()); |
|
62 | - $this->assertEquals($this->options,$Stub->getOptions()); |
|
60 | + $Stub = new EntryPointStub($this->url, $this->options); |
|
61 | + $this->assertEquals($this->url.'foo', $Stub->getUrl()); |
|
62 | + $this->assertEquals($this->options, $Stub->getOptions()); |
|
63 | 63 | $this->assertEmpty($Stub->getData()); |
64 | 64 | $this->assertEmpty($Stub->getRequest()); |
65 | 65 | $this->assertEmpty($Stub->getResponse()); |
@@ -79,11 +79,11 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function testSetOptions($Stub){ |
81 | 81 | $Stub->setOptions(array()); |
82 | - $this->assertEquals($this->url.'$test',$Stub->getUrl()); |
|
83 | - $this->assertEquals(array(),$Stub->getOptions()); |
|
82 | + $this->assertEquals($this->url.'$test', $Stub->getUrl()); |
|
83 | + $this->assertEquals(array(), $Stub->getOptions()); |
|
84 | 84 | $Stub->setOptions($this->options); |
85 | - $this->assertEquals($this->url.'foo',$Stub->getUrl()); |
|
86 | - $this->assertEquals($this->options,$Stub->getOptions()); |
|
85 | + $this->assertEquals($this->url.'foo', $Stub->getUrl()); |
|
86 | + $this->assertEquals($this->options, $Stub->getOptions()); |
|
87 | 87 | |
88 | 88 | return $Stub; |
89 | 89 | } |
@@ -98,13 +98,13 @@ discard block |
||
98 | 98 | */ |
99 | 99 | public function testSetData($Stub){ |
100 | 100 | $Stub->setData(array()); |
101 | - $this->assertEquals(array(),$Stub->getData()); |
|
101 | + $this->assertEquals(array(), $Stub->getData()); |
|
102 | 102 | $Stub->setData('string'); |
103 | - $this->assertEquals('string',$Stub->getData()); |
|
103 | + $this->assertEquals('string', $Stub->getData()); |
|
104 | 104 | $class = new \stdClass(); |
105 | 105 | $class->foo = 'bar'; |
106 | 106 | $Stub->setData($class); |
107 | - $this->assertEquals($class,$Stub->getData()); |
|
107 | + $this->assertEquals($class, $Stub->getData()); |
|
108 | 108 | unset($class); |
109 | 109 | $Stub->setData($this->data); |
110 | 110 | return $Stub; |
@@ -126,22 +126,22 @@ discard block |
||
126 | 126 | $DELETE = new DELETE(); |
127 | 127 | $GETFile = new GETFile(); |
128 | 128 | $Stub->setRequest($POST); |
129 | - $this->assertEquals($POST,$Stub->getRequest()); |
|
129 | + $this->assertEquals($POST, $Stub->getRequest()); |
|
130 | 130 | unset($POST); |
131 | 131 | $Stub->setRequest($POSTFile); |
132 | - $this->assertEquals($POSTFile,$Stub->getRequest()); |
|
132 | + $this->assertEquals($POSTFile, $Stub->getRequest()); |
|
133 | 133 | unset($POSTFile); |
134 | 134 | $Stub->setRequest($PUT); |
135 | - $this->assertEquals($PUT,$Stub->getRequest()); |
|
135 | + $this->assertEquals($PUT, $Stub->getRequest()); |
|
136 | 136 | unset($PUT); |
137 | 137 | $Stub->setRequest($DELETE); |
138 | - $this->assertEquals($DELETE,$Stub->getRequest()); |
|
138 | + $this->assertEquals($DELETE, $Stub->getRequest()); |
|
139 | 139 | unset($DELETE); |
140 | 140 | $Stub->setRequest($GETFile); |
141 | - $this->assertEquals($GETFile,$Stub->getRequest()); |
|
141 | + $this->assertEquals($GETFile, $Stub->getRequest()); |
|
142 | 142 | unset($GETFile); |
143 | 143 | $Stub->setRequest($GET); |
144 | - $this->assertEquals($GET,$Stub->getRequest()); |
|
144 | + $this->assertEquals($GET, $Stub->getRequest()); |
|
145 | 145 | return $Stub; |
146 | 146 | } |
147 | 147 | |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public function testSetAuth($Stub){ |
157 | 157 | $Stub->setAuth('1234'); |
158 | - $this->assertEquals(true,$Stub->authRequired()); |
|
158 | + $this->assertEquals(true, $Stub->authRequired()); |
|
159 | 159 | return $Stub; |
160 | 160 | } |
161 | 161 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | $this->assertEquals(array( |
182 | 182 | 'foo' => 'bar', |
183 | 183 | 'bar' => 'foo' |
184 | - ),$Stub->getData()); |
|
185 | - $this->assertEquals($this->url.'foo?foo=bar&bar=foo',$Stub->getRequest()->getUrl()); |
|
186 | - $this->assertEquals(array('OAuth-Token: 1234'),$Stub->getRequest()->getHeaders()); |
|
184 | + ), $Stub->getData()); |
|
185 | + $this->assertEquals($this->url.'foo?foo=bar&bar=foo', $Stub->getRequest()->getUrl()); |
|
186 | + $this->assertEquals(array('OAuth-Token: 1234'), $Stub->getRequest()->getHeaders()); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -18,12 +18,10 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class AbstractEntryPointTest extends \PHPUnit_Framework_TestCase { |
20 | 20 | |
21 | - public static function setUpBeforeClass() |
|
22 | - { |
|
21 | + public static function setUpBeforeClass(){ |
|
23 | 22 | } |
24 | 23 | |
25 | - public static function tearDownAfterClass() |
|
26 | - { |
|
24 | + public static function tearDownAfterClass(){ |
|
27 | 25 | } |
28 | 26 | |
29 | 27 | protected $Stub; |
@@ -33,13 +31,11 @@ discard block |
||
33 | 31 | 'foo' => 'bar' |
34 | 32 | ); |
35 | 33 | |
36 | - public function setUp() |
|
37 | - { |
|
34 | + public function setUp(){ |
|
38 | 35 | parent::setUp(); |
39 | 36 | } |
40 | 37 | |
41 | - public function tearDown() |
|
42 | - { |
|
38 | + public function tearDown(){ |
|
43 | 39 | parent::tearDown(); |
44 | 40 | } |
45 | 41 |
@@ -155,7 +155,7 @@ |
||
155 | 155 | */ |
156 | 156 | public function testSetAuth($Stub){ |
157 | 157 | $Stub->setAuth('1234'); |
158 | - $this->assertEquals(true,$Stub->authRequired()); |
|
158 | + $this->assertEquals(TRUE,$Stub->authRequired()); |
|
159 | 159 | return $Stub; |
160 | 160 | } |
161 | 161 |