@@ -70,6 +70,26 @@ public function getJobs($offset = 0, $count = 10, array $extraOptions = array())
7070 return $ this ->_doRequest ("tests/? " . http_build_query ($ queryData ), "GET " );
7171 }
7272
73+ public function createLabTest ($ name , $ baseUrl , $ extras = array ())
74+ {
75+ $ postData = array_merge (array (
76+ 'test[name] ' => $ name ,
77+ 'test[url] ' => $ baseUrl
78+ ), $ extras );
79+ return $ this ->_doRequest ("lab/ " , "POST " , $ postData );
80+ }
81+
82+ public function modifyLabTestSteps ($ labTestID , array $ steps )
83+ {
84+ $ processedSteps = array ();
85+
86+ for ($ i = 0 ; $ i < sizeof ($ steps ); $ i ++) {
87+ $ processedSteps [] = "steps[][order]= " . $ i . "&steps[][cmd]= " . $ steps [$ i ]['cmd ' ] . "&steps[][locator]= " . $ steps [$ i ]['locator ' ] . "&steps[][value]= " . $ steps [$ i ]['value ' ];
88+ }
89+
90+ return $ this ->_doRequest ("lab/ " . $ labTestID . "/steps " , "POST " , implode ('& ' , $ processedSteps ));
91+ }
92+
7393 public function deleteJob ($ sessionID )
7494 {
7595 if (empty ($ sessionID ))
@@ -198,7 +218,7 @@ public function deleteStorageFile($appUrl)
198218 return $ this ->_doRequest ("storage/ " . str_replace ("tb:// " , "" , $ appUrl ), "DELETE " );
199219 }
200220
201- private function _doRequest ($ path , $ method = 'POST ' , array $ data = array () )
221+ private function _doRequest ($ path , $ method = 'POST ' , $ data )
202222 {
203223 $ curl = curl_init ();
204224 curl_setopt ($ curl , CURLOPT_URL , "https://api.testingbot.com/v1/ " . $ path );
@@ -207,7 +227,14 @@ private function _doRequest($path, $method = 'POST', array $data = array())
207227 curl_setopt ($ curl , CURLOPT_USERPWD , $ this ->_key . ": " . $ this ->_secret );
208228 if (!empty ($ data ))
209229 {
210- curl_setopt ($ curl , CURLOPT_POSTFIELDS , http_build_query ($ data ));
230+ if (is_array ($ data ))
231+ {
232+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , http_build_query ($ data ));
233+ }
234+ else
235+ {
236+ curl_setopt ($ curl , CURLOPT_POSTFIELDS , $ data );
237+ }
211238 }
212239
213240 $ response = curl_exec ($ curl );
0 commit comments