behat test, now can save data in session file, and add suffix to endpoints
This commit is contained in:
@@ -10,22 +10,15 @@ Feature: Testing Oauth
|
|||||||
And the "prj_uid" property in row 0 equals "31034744752a5d007364d93044509065"
|
And the "prj_uid" property in row 0 equals "31034744752a5d007364d93044509065"
|
||||||
And the "prj_name" property in row 0 equals "Sample Project #1"
|
And the "prj_name" property in row 0 equals "Sample Project #1"
|
||||||
And the "prj_create_date" property in row 0 equals "2013-12-09 09:13:27"
|
And the "prj_create_date" property in row 0 equals "2013-12-09 09:13:27"
|
||||||
#And the "diagrams" property in row 0 equals "diagrams"
|
|
||||||
|
|
||||||
Scenario: GET project Sample Project #1 process...
|
Scenario: GET project Sample Project #1 process...
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And I request "project/31034744752a5d007364d93044509065"
|
And I request "project/14414793652a5d718b65590036026581"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the response charset is "UTF-8"
|
And the response charset is "UTF-8"
|
||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
And the type is "object"
|
And the type is "object"
|
||||||
And the response has a "diagrams" property
|
And the response has a "diagrams" property
|
||||||
And the "diagrams" property type is "array"
|
|
||||||
And the "dia_uid" property in row 0 of property "diagrams" equals "23643663952a5d0073a6133086723956"
|
|
||||||
And the "prj_uid" property in row 0 of property "diagrams" equals "31034744752a5d007364d93044509065"
|
|
||||||
And the "dia_name" property in row 0 of property "diagrams" equals "Sample Project #1"
|
|
||||||
And the "dia_is_closable" property in row 0 of property "diagrams" equals "0"
|
|
||||||
|
|
||||||
And the "lanesets" property in row 0 of property "diagrams" is "array"
|
And the "lanesets" property in row 0 of property "diagrams" is "array"
|
||||||
And the "lanes" property in row 0 of property "diagrams" is "array"
|
And the "lanes" property in row 0 of property "diagrams" is "array"
|
||||||
And the "activities" property in row 0 of property "diagrams" is "array"
|
And the "activities" property in row 0 of property "diagrams" is "array"
|
||||||
@@ -34,7 +27,7 @@ Feature: Testing Oauth
|
|||||||
And the "flows" property in row 0 of property "diagrams" is "array"
|
And the "flows" property in row 0 of property "diagrams" is "array"
|
||||||
And the "artifacts" property in row 0 of property "diagrams" is "array"
|
And the "artifacts" property in row 0 of property "diagrams" is "array"
|
||||||
|
|
||||||
Scenario: get an activity from process Sample Project #1
|
Scenario: get an activity from some process
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And I request "project/31034744752a5d007364d93044509065/activity/72845150252a5d718be4df5092655350"
|
And I request "project/31034744752a5d007364d93044509065/activity/72845150252a5d718be4df5092655350"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
@@ -42,7 +35,7 @@ Feature: Testing Oauth
|
|||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
And the response is equivalent to this json file "task_72845150252a5d718be4df5092655350.json"
|
And the response is equivalent to this json file "task_72845150252a5d718be4df5092655350.json"
|
||||||
|
|
||||||
Scenario: get an activity from process Sample Project #1
|
Scenario: get an activity from some process
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And I request "project/31034744752a5d007364d93044509065/activity/13508932952a5d718ef56f6044945775"
|
And I request "project/31034744752a5d007364d93044509065/activity/13508932952a5d718ef56f6044945775"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
@@ -50,7 +43,7 @@ Feature: Testing Oauth
|
|||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
And the response is equivalent to this json file "task_13508932952a5d718ef56f6044945775.json"
|
And the response is equivalent to this json file "task_13508932952a5d718ef56f6044945775.json"
|
||||||
|
|
||||||
Scenario: get an activity from process Sample Project #1
|
Scenario: get an activity from some process
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And I request "project/31034744752a5d007364d93044509065/activity/58163453252a5d719253ff9069893664"
|
And I request "project/31034744752a5d007364d93044509065/activity/58163453252a5d719253ff9069893664"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
@@ -60,36 +53,124 @@ Feature: Testing Oauth
|
|||||||
|
|
||||||
Scenario: get a list of input documents
|
Scenario: get a list of input documents
|
||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And I request "project/31034744752a5d007364d93044509065/input-documents"
|
And I request "project/14414793652a5d718b65590036026581/input-documents"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
And the content type is "application/json"
|
And the content type is "application/json"
|
||||||
And the response is equivalent to this json file "task_58163453252a5d719253ff9069893664.json"
|
And the json data is an empty array
|
||||||
|
|
||||||
# Scenario: post an activity
|
#there is an error in :
|
||||||
# Given that I send "data"
|
#message": "Bad Request: [wrapped: Cannot fetch TableMap for undefined table: CONTENT]"
|
||||||
# And I request "project/31034744752a5d007364d93044509065/activity"
|
#source": "InputDocument.php:51 at call stage",
|
||||||
# Then the response status code should be 200
|
# Scenario: post a new input documents
|
||||||
# And the response charset is "UTF-8"
|
# Given that I have a valid access_token
|
||||||
|
# And POST this data:
|
||||||
# Scenario: Creating new Activity with API
|
#"""
|
||||||
# Given that I want to make a new "Process" with:
|
#{
|
||||||
# | name | followers |
|
# "inp_doc_title": "Input Doc #1",
|
||||||
# | everzet | 147 |
|
# "inp_doc_description": "Input Doc #1 - Desc",
|
||||||
# | avalanche123 | 142 |
|
# "out_doc_form_needed": "VIRTUAL",
|
||||||
# | kriswallsmith | 274 |
|
# "inp_doc_original": "ORIGINAL",
|
||||||
# | fabpot | 962 |
|
# "inp_doc_published": "PRIVATE",
|
||||||
# And I want to Insert a new "Process" with:
|
# "inp_doc_versionning": 0,
|
||||||
# """
|
# "inp_doc_destination_path": "",
|
||||||
# {
|
# "inp_doc_tags": "INPUT"
|
||||||
# "id" : 123,
|
#}
|
||||||
# "name" : "john",
|
#"""
|
||||||
# "age" : 12
|
# And I request "project/14414793652a5d718b65590036026581/input-document"
|
||||||
# }
|
|
||||||
# """
|
|
||||||
## And "prj_name" is "my test process"
|
|
||||||
## And "prj_description" is "test for gizzle"
|
|
||||||
## And the request is sent as JSON
|
|
||||||
## When I request "project"
|
|
||||||
# Then the response status code should be 201
|
# Then the response status code should be 201
|
||||||
## And the response should be JSON
|
|
||||||
## And the response has a "prj_id" property
|
# Scenario: modify an input document
|
||||||
|
# Given that I have a valid access_token
|
||||||
|
# And PUT this data:
|
||||||
|
#"""
|
||||||
|
#{
|
||||||
|
# "inp_doc_title": "Input Doc #1",
|
||||||
|
# "inp_doc_description": "Input Doc #1 - Desc",
|
||||||
|
# "out_doc_form_needed": "VIRTUAL",
|
||||||
|
# "inp_doc_original": "ORIGINAL",
|
||||||
|
# "inp_doc_published": "PRIVATE",
|
||||||
|
# "inp_doc_versionning": 0,
|
||||||
|
# "inp_doc_destination_path": "",
|
||||||
|
# "inp_doc_tags": "INPUT"
|
||||||
|
#}
|
||||||
|
#"""
|
||||||
|
# And I request "project/14414793652a5d718b65590036026581/input-document/44915038352b08f590a4105021431900"
|
||||||
|
# Then the response status code should be 200
|
||||||
|
|
||||||
|
Scenario: get an empty list of triggers
|
||||||
|
Given that I have a valid access_token
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/triggers"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the content type is "application/json"
|
||||||
|
And the json data is an empty array
|
||||||
|
|
||||||
|
|
||||||
|
Scenario: post a new trigger
|
||||||
|
Given that I have a valid access_token
|
||||||
|
And POST this data:
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"tri_title": "Trigger #1",
|
||||||
|
"tri_description": "Trigger #1 - Desc",
|
||||||
|
"tri_type": "SCRIPT",
|
||||||
|
"tri_webbot": "print 'hello world!!'; ",
|
||||||
|
"tri_param": "PRIVATE"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/trigger"
|
||||||
|
Then the response status code should be 201
|
||||||
|
And the content type is "application/json"
|
||||||
|
And the type is "object"
|
||||||
|
And that "tri_param" is set to "PRIVATE"
|
||||||
|
And store "tri_uid" in session array
|
||||||
|
|
||||||
|
Scenario: re-post a new trigger, to get an error
|
||||||
|
Given that I have a valid access_token
|
||||||
|
And POST this data:
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"tri_title": "Trigger #1",
|
||||||
|
"tri_description": "Trigger #1 - Desc",
|
||||||
|
"tri_type": "SCRIPT",
|
||||||
|
"tri_webbot": "print 'hello world!!'; ",
|
||||||
|
"tri_param": "PRIVATE"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/trigger"
|
||||||
|
Then the response status code should be 400
|
||||||
|
And the content type is "application/json"
|
||||||
|
And the type is "object"
|
||||||
|
#message: "Bad Request: There is a triggers with the same name in this process"
|
||||||
|
|
||||||
|
Scenario: modify a Trigger
|
||||||
|
Given that I have a valid access_token
|
||||||
|
And PUT this data:
|
||||||
|
"""
|
||||||
|
{
|
||||||
|
"tri_title": "Trigger #1-modified",
|
||||||
|
"tri_description": "Trigger #1 - -modified",
|
||||||
|
"tri_type": "SCRIPT",
|
||||||
|
"tri_webbot": "print 'hello modified world!!'; ",
|
||||||
|
"tri_param": "PRIVATE"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
And that I want to update a resource with the key "tri_uid" stored in session array
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/trigger"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the content type is "application/json"
|
||||||
|
And the type is "object"
|
||||||
|
And that "tri_title" is set to "Trigger #1-modified"
|
||||||
|
|
||||||
|
Scenario: delete a previously created trigger
|
||||||
|
Given that I have a valid access_token
|
||||||
|
And that I want to delete a resource with the key "tri_uid" stored in session array
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/trigger"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the content type is "application/json"
|
||||||
|
|
||||||
|
Scenario: get the empty list of triggers again!
|
||||||
|
Given that I have a valid access_token
|
||||||
|
And I request "project/14414793652a5d718b65590036026581/triggers"
|
||||||
|
Then the response status code should be 200
|
||||||
|
And the json data is an empty array
|
||||||
|
|
||||||
|
|||||||
@@ -184,6 +184,46 @@ class RestContext extends BehatContext
|
|||||||
$this->_restObjectMethod = 'delete';
|
$this->_restObjectMethod = 'delete';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^that I want to delete a resource with the key "([^"]*)" stored in session array$/
|
||||||
|
*/
|
||||||
|
public function thatIWantToDeleteAResourceWithTheKeyStoredInSessionArray($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->_restDeleteQueryStringSuffix = "/" . $varValue;
|
||||||
|
$this->_restObjectMethod = 'delete';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^that I want to update a resource with the key "([^"]*)" stored in session array$/
|
||||||
|
*/
|
||||||
|
public function thatIWantToUpdateAResourceWithTheKeyStoredInSessionArray($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->_restUpdateQueryStringSuffix = "/" . $varValue;
|
||||||
|
$this->_restObjectMethod = 'put';
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^that "([^"]*)" header is set to "([^"]*)"$/
|
* @Given /^that "([^"]*)" header is set to "([^"]*)"$/
|
||||||
* @Given /^that "([^"]*)" header is set to (\d+)$/
|
* @Given /^that "([^"]*)" header is set to (\d+)$/
|
||||||
@@ -307,6 +347,10 @@ class RestContext extends BehatContext
|
|||||||
$this->_response = $this->_request->send();
|
$this->_response = $this->_request->send();
|
||||||
break;
|
break;
|
||||||
case 'PUT' :
|
case 'PUT' :
|
||||||
|
if (isset($this->_restUpdateQueryStringSuffix) &&
|
||||||
|
$this->_restUpdateQueryStringSuffix != '') {
|
||||||
|
$url .= $this->_restUpdateQueryStringSuffix;
|
||||||
|
}
|
||||||
$putFields = is_object($this->_restObject)
|
$putFields = is_object($this->_restObject)
|
||||||
? (array)$this->_restObject
|
? (array)$this->_restObject
|
||||||
: $this->_restObject;
|
: $this->_restObject;
|
||||||
@@ -327,6 +371,10 @@ class RestContext extends BehatContext
|
|||||||
$this->_response = $this->_request->send();
|
$this->_response = $this->_request->send();
|
||||||
break;
|
break;
|
||||||
case 'DELETE':
|
case 'DELETE':
|
||||||
|
if (isset($this->_restDeleteQueryStringSuffix) &&
|
||||||
|
$this->_restDeleteQueryStringSuffix != '') {
|
||||||
|
$url .= $this->_restDeleteQueryStringSuffix;
|
||||||
|
}
|
||||||
$this->_request = $this->_client
|
$this->_request = $this->_client
|
||||||
->delete($url, $this->_headers);
|
->delete($url, $this->_headers);
|
||||||
$this->_response = $this->_request->send();
|
$this->_response = $this->_request->send();
|
||||||
@@ -490,6 +538,18 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^the json data is an empty array$/
|
||||||
|
*/
|
||||||
|
public function theJsonDataIsAnEmptyArray()
|
||||||
|
{
|
||||||
|
$data = $this->_data;
|
||||||
|
if (is_array($data) && count($data) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
throw new Exception("Response is not an empty array\n\n" .
|
||||||
|
$this->echoLastResponse());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^the type is "([^"]*)"$/
|
* @Given /^the type is "([^"]*)"$/
|
||||||
@@ -882,6 +942,27 @@ class RestContext extends BehatContext
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^POST this data:$/
|
||||||
|
*/
|
||||||
|
public function postThisData(PyStringNode $string)
|
||||||
|
{
|
||||||
|
$this->_restObjectMethod = 'post';
|
||||||
|
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
||||||
|
$this->_requestBody = $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^PUT this data:$/
|
||||||
|
*/
|
||||||
|
public function putThisData(PyStringNode $string)
|
||||||
|
{
|
||||||
|
$this->_restObjectMethod = 'put';
|
||||||
|
$this->_headers['Content-Type'] = 'application/json; charset=UTF-8';
|
||||||
|
$this->_requestBody = $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Given /^I want to Insert a new "([^"]*)" with:$/
|
* @Given /^I want to Insert a new "([^"]*)" with:$/
|
||||||
*/
|
*/
|
||||||
@@ -898,6 +979,26 @@ class RestContext extends BehatContext
|
|||||||
//print "************$string ***********";
|
//print "************$string ***********";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Given /^store "([^"]*)" in session array$/
|
||||||
|
*/
|
||||||
|
public function storeIn($varName)
|
||||||
|
{
|
||||||
|
if (!isset($this->_data->$varName)) {
|
||||||
|
throw new \Exception("JSON Response does not have '$varName' property\n\n"
|
||||||
|
. $this->echoLastResponse());
|
||||||
|
}
|
||||||
|
|
||||||
|
$varValue = $this->_data->$varName;
|
||||||
|
if (file_exists("session.data")) {
|
||||||
|
$sessionData = json_decode(file_get_contents("session.data"));
|
||||||
|
} else {
|
||||||
|
$sessionData = new StdClass();
|
||||||
|
}
|
||||||
|
$sessionData->$varName = $varValue;
|
||||||
|
file_put_contents("session.data", json_encode($sessionData));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Then /^echo last response$/
|
* @Then /^echo last response$/
|
||||||
*/
|
*/
|
||||||
@@ -906,3 +1007,4 @@ class RestContext extends BehatContext
|
|||||||
$this->printDebug("$this->_request\n$this->_response");
|
$this->printDebug("$this->_request\n$this->_response");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user