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] 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