From ebd341d5dfae102c532d7cd82919cce21d0618b2 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 12:34:39 -0400 Subject: [PATCH 1/6] Pruebas de behat para events --- behat.yml.dist | 2 +- features/bootstrap/RestContext.php | 24 +++++++++++ features/processmaker/event.feature | 61 +++++++++++++++++++++++++++ features/processmaker/trigger.feature | 23 ++++++++++ 4 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 features/processmaker/event.feature create mode 100644 features/processmaker/trigger.feature diff --git a/behat.yml.dist b/behat.yml.dist index c22acdb95..a8869196e 100644 --- a/behat.yml.dist +++ b/behat.yml.dist @@ -3,4 +3,4 @@ default: context: parameters: base_url: http://192.168.11.181/api/1.0/michelangelo/ - access_token: ff4bdec9e8e2e3b2fa3fb03bc3a7d287fd0dcf26 + access_token: cd5cff9b2e3ebabf49e276e47e977fab5988c00e diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 8f80c1487..48a90d813 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -173,6 +173,26 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'get'; } + /** + * @Given /^that I want to find a resource with the key "([^"]*)" stored in session array$/ + */ + public function thatIWantToFindAResourceWithTheKeyStoredInSessionArray($varName) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$varName) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$varName; + } + + $this->_restFindQueryStringSuffix = "/" . $varValue; + $this->_restObjectMethod = 'get'; + } + /** * @Given /^that I want to delete a "([^"]*)"$/ * @Given /^that I want to delete an "([^"]*)"$/ @@ -331,6 +351,10 @@ class RestContext extends BehatContext $this->_response = $this->_request->send(); break; case 'GET': + if (isset($this->_restFindQueryStringSuffix) && + $this->_restFindQueryStringSuffix != '') { + $url .= $this->_restFindQueryStringSuffix; + } $this->_request = $this->_client ->get($url, $this->_headers); $this->_response = $this->_request->send(); diff --git a/features/processmaker/event.feature b/features/processmaker/event.feature new file mode 100644 index 000000000..e20147b75 --- /dev/null +++ b/features/processmaker/event.feature @@ -0,0 +1,61 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Testing triggers + + @1: TEST FOR POST EVENT /---------------------------------------------------------------------- + Scenario: Create a event + Given that I have a valid access_token + And POST this data: + """ + { + "evn_description": "DE BEHAT", + "evn_status": "ACTIVE", + "evn_action": "SEND_MESSAGE", + "evn_related_to": "SINGLE", + "tas_uid": "97192372152a5c78f04a794095806311", + "evn_tas_uid_from": "97192372152a5c78f04a794095806311", + "evn_tas_estimated_duration": 1, + "evn_time_unit": "DAYS", + "evn_when": 1, + "evn_when_occurs": "AFTER_TIME", + "tri_uid": "95325847552af0c07792c15098680510" + } + """ + And I request "project/251815090529619a99a2bf4013294414/event" + Then the response status code should be 201 + And store "evn_uid" in session array + + @2: TEST FOR PUT EVENT /----------------------------------------------------------------------- + Scenario: Update a event + Given that I have a valid access_token + And PUT this data: + """ + { + "evn_description": "change description", + "evn_status": "ACTIVE", + "evn_action": "SEND_MESSAGE", + "evn_related_to": "SINGLE", + "tas_uid": "97192372152a5c78f04a794095806311", + "evn_tas_uid_from": "97192372152a5c78f04a794095806311", + "evn_tas_estimated_duration": 1, + "evn_time_unit": "DAYS", + "evn_when": 1, + "evn_when_occurs": "AFTER_TIME", + "tri_uid": "95325847552af0c07792c15098680510" + } + """ + And that I want to update a resource with the key "evn_uid" stored in session array + And I request "project/251815090529619a99a2bf4013294414/event" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + + + @3: TEST FOR GET EVENT /----------------------------------------------------------------------- + Scenario: Get a event + Given that I have a valid access_token + And that I want to find a resource with the key "evn_uid" stored in session array + And I request "project/251815090529619a99a2bf4013294414/event" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the type is "object" + And that "evn_description" is set to "change description" \ No newline at end of file diff --git a/features/processmaker/trigger.feature b/features/processmaker/trigger.feature new file mode 100644 index 000000000..edfd62a31 --- /dev/null +++ b/features/processmaker/trigger.feature @@ -0,0 +1,23 @@ +@ProcessMakerMichelangelo @RestAPI +Feature: Testing triggers + Scenario: List triggers of an project + Given that I have a valid access_token + And I request "project/534152995521df6bb5986c4062665559/triggers" + Then the response status code should be 200 + And the response charset is "UTF-8" + And the content type is "application/json" + And the type is "array" + + + + Scenario: Create a trigger + Given that I have a valid access_token + And POST this data: + """ + { + "tri_title": "nuevo triggerr", + "tri_description": "descripcion" + } + """ + And I request "project/534152995521df6bb5986c4062665559/trigger" + Then the response status code should be 201 \ No newline at end of file From 9abed301de9a9d31a3fa92119520159261f9ebef Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 14:50:37 -0400 Subject: [PATCH 2/6] Arreglo de conflictos --- features/bootstrap/RestContext.php | 85 ++++++++++++++++++------------ 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index 48a90d813..bdabc845d 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -173,26 +173,6 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'get'; } - /** - * @Given /^that I want to find a resource with the key "([^"]*)" stored in session array$/ - */ - public function thatIWantToFindAResourceWithTheKeyStoredInSessionArray($varName) - { - if (file_exists("session.data")) { - $sessionData = json_decode(file_get_contents("session.data")); - } else { - $sessionData = array(); - } - if (!isset($sessionData->$varName) ) { - $varValue = ''; - } else { - $varValue = $sessionData->$varName; - } - - $this->_restFindQueryStringSuffix = "/" . $varValue; - $this->_restObjectMethod = 'get'; - } - /** * @Given /^that I want to delete a "([^"]*)"$/ * @Given /^that I want to delete an "([^"]*)"$/ @@ -244,6 +224,26 @@ class RestContext extends BehatContext $this->_restObjectMethod = 'put'; } + /** + * @Given /^that I want to get a resource with the key "([^"]*)" stored in session array$/ + */ + public function thatIWantToGetAResourceWithTheKeyStoredInSessionArray($varName) + { + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = array(); + } + if (!isset($sessionData->$varName) ) { + $varValue = ''; + } else { + $varValue = $sessionData->$varName; + } + + $this->_restGetQueryStringSuffix = "/" . $varValue; + $this->_restObjectMethod = 'get'; + } + /** * @Given /^that "([^"]*)" header is set to "([^"]*)"$/ * @Given /^that "([^"]*)" header is set to (\d+)$/ @@ -351,9 +351,9 @@ class RestContext extends BehatContext $this->_response = $this->_request->send(); break; case 'GET': - if (isset($this->_restFindQueryStringSuffix) && - $this->_restFindQueryStringSuffix != '') { - $url .= $this->_restFindQueryStringSuffix; + if (isset($this->_restGetQueryStringSuffix) && + $this->_restGetQueryStringSuffix != '') { + $url .= $this->_restGetQueryStringSuffix; } $this->_request = $this->_client ->get($url, $this->_headers); @@ -961,8 +961,8 @@ class RestContext extends BehatContext $this->_headers['Content-Type'] = 'application/json; charset=UTF-8'; $this->_requestBody = $string; } - - + + /** @@ -999,7 +999,25 @@ class RestContext extends BehatContext $sessionData->$varName = $varValue; file_put_contents("session.data", json_encode($sessionData)); } - + + /** + * @Given /^store "([^"]*)" in session array as variable "([^"]*)"$/ + */ + public function storeInAsVariable($varName, $sessionVarName) + { + if (!isset($this->_data->$varName)) { + throw new \Exception("JSON Response does not have '$varName' property\n\n" ); + } + + $varValue = $this->_data->$varName; + if (file_exists("session.data")) { + $sessionData = json_decode(file_get_contents("session.data")); + } else { + $sessionData = new StdClass(); + } + $sessionData->$sessionVarName = $varValue; + file_put_contents("session.data", json_encode($sessionData)); + } /** * @Then /^echo last response$/ @@ -1008,17 +1026,17 @@ class RestContext extends BehatContext { $this->printDebug("$this->_request\n$this->_response"); } - - + + //*********** WEN - + /** * @Given /^POST data from file "([^"]*)"$/ */ public function postDataFromFile($jsonFile) { $filePath = __DIR__ . "/../json/" . $jsonFile; - + if(file_exists($filePath)) { $fileData = file_get_contents($filePath); @@ -1030,14 +1048,14 @@ class RestContext extends BehatContext } // throw new PendingException(); } - + /** * @Given /^PUT data from file "([^"]*)"$/ */ public function putDataFromFile($jsonFile) { $filePath = __DIR__ . "/../json/" . $jsonFile; - + if(file_exists($filePath)) { $fileData = file_get_contents($filePath); @@ -1057,6 +1075,5 @@ class RestContext extends BehatContext { throw new PendingException(); } - -} +} From 8aa5a67f4c21baa8fffa25b69b8e39a3cb7cab2a Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 14:58:59 -0400 Subject: [PATCH 3/6] arreglo conflicto --- features/bootstrap/RestContext.php | 1 - 1 file changed, 1 deletion(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index bdabc845d..24d7a85f3 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1075,5 +1075,4 @@ class RestContext extends BehatContext { throw new PendingException(); } - } From 28ced8f1a067e3e75986b29441eb18c0b7283804 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 15:14:17 -0400 Subject: [PATCH 4/6] arreglo de conflicto --- features/bootstrap/RestContext.php | 1 - 1 file changed, 1 deletion(-) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index b498ca832..bdabc845d 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1077,4 +1077,3 @@ class RestContext extends BehatContext } } - From 67b5c681ab317cc05f0595e96cd7f5fad1500e5e Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 15:19:04 -0400 Subject: [PATCH 5/6] Arreglo de llamado a funcion en behat --- features/processmaker/event.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/features/processmaker/event.feature b/features/processmaker/event.feature index e20147b75..235806870 100644 --- a/features/processmaker/event.feature +++ b/features/processmaker/event.feature @@ -53,7 +53,7 @@ Feature: Testing triggers @3: TEST FOR GET EVENT /----------------------------------------------------------------------- Scenario: Get a event Given that I have a valid access_token - And that I want to find a resource with the key "evn_uid" stored in session array + And that I want to get a resource with the key "evn_uid" stored in session array And I request "project/251815090529619a99a2bf4013294414/event" Then the response status code should be 200 And the response charset is "UTF-8" From 8de51893f16be6449576d9d73afc28ad1d70eaf4 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Tue, 7 Jan 2014 15:22:16 -0400 Subject: [PATCH 6/6] Arreglo para RestContext.php --- features/bootstrap/RestContext.php | 1 + 1 file changed, 1 insertion(+) diff --git a/features/bootstrap/RestContext.php b/features/bootstrap/RestContext.php index bdabc845d..b498ca832 100644 --- a/features/bootstrap/RestContext.php +++ b/features/bootstrap/RestContext.php @@ -1077,3 +1077,4 @@ class RestContext extends BehatContext } } +