modifying the build.xml for behat
This commit is contained in:
@@ -46,10 +46,10 @@
|
|||||||
<target name="lint" description="Perform syntax check of sourcecode files">
|
<target name="lint" description="Perform syntax check of sourcecode files">
|
||||||
<apply executable="php" failonerror="true">
|
<apply executable="php" failonerror="true">
|
||||||
<arg value="-l" />
|
<arg value="-l" />
|
||||||
|
<arg value="-R" />
|
||||||
|
|
||||||
<fileset dir="${basedir}/workflow/engine/src">
|
<fileset dir="${basedir}/workflow/engine/src">
|
||||||
<include name="*.php" />
|
<include name="*.php" />
|
||||||
<modified />
|
|
||||||
</fileset>
|
</fileset>
|
||||||
|
|
||||||
</apply>
|
</apply>
|
||||||
@@ -87,7 +87,7 @@
|
|||||||
<arg value="xml" />
|
<arg value="xml" />
|
||||||
<arg value="codesize" /> <!-- ${basedir}/build/phpmd.xml" /> !-->
|
<arg value="codesize" /> <!-- ${basedir}/build/phpmd.xml" /> !-->
|
||||||
<arg value="--reportfile" />
|
<arg value="--reportfile" />
|
||||||
<arg value="${basedir}/build/logs/pmd.xml" />
|
<arg value="${basedir}/build/logs/phpmd.xml" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ Feature: Testing Oauth
|
|||||||
Given that I have a valid access_token
|
Given that I have a valid access_token
|
||||||
And I request "projects"
|
And I request "projects"
|
||||||
Then the response status code should be 200
|
Then the response status code should be 200
|
||||||
|
And the response time should at least be 100 milliseconds
|
||||||
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 "array"
|
And the type is "array"
|
||||||
|
|||||||
@@ -131,8 +131,7 @@ class RestContext extends BehatContext
|
|||||||
{
|
{
|
||||||
$data = json_encode($this->_data);
|
$data = json_encode($this->_data);
|
||||||
if ($data !== $response)
|
if ($data !== $response)
|
||||||
throw new Exception("Response value does not match '$response'\n\n"
|
throw new Exception("Response value does not match '$response'\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -303,8 +302,7 @@ class RestContext extends BehatContext
|
|||||||
$access_token = $this->getParameter('access_token');
|
$access_token = $this->getParameter('access_token');
|
||||||
if (strlen($access_token)<= 10) {
|
if (strlen($access_token)<= 10) {
|
||||||
throw new PendingException();
|
throw new PendingException();
|
||||||
throw new Exception ('Access token is not valid, please review behat.yml'
|
throw new Exception ("Access token is not valid, please review behat.yml\n\n" );
|
||||||
. "\n\n" . $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
$this->access_token = $access_token;
|
$this->access_token = $access_token;
|
||||||
}
|
}
|
||||||
@@ -420,8 +418,7 @@ class RestContext extends BehatContext
|
|||||||
$message = 'unknown error';
|
$message = 'unknown error';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
throw new Exception ('Error parsing JSON, ' . $message
|
throw new Exception ("Error parsing JSON, $message \n\n" );
|
||||||
. "\n\n" . $this->echoLastResponse());
|
|
||||||
break;
|
break;
|
||||||
case 'application/xml':
|
case 'application/xml':
|
||||||
$this->_type = 'xml';
|
$this->_type = 'xml';
|
||||||
@@ -446,7 +443,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseIsJson()
|
public function theResponseIsJson()
|
||||||
{
|
{
|
||||||
if ($this->_type != 'json') {
|
if ($this->_type != 'json') {
|
||||||
throw new Exception("Response was not JSON\n\n" . $this->echoLastResponse());
|
throw new Exception("Response was not JSON\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -457,7 +454,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseIsXml()
|
public function theResponseIsXml()
|
||||||
{
|
{
|
||||||
if ($this->_type != 'xml') {
|
if ($this->_type != 'xml') {
|
||||||
throw new Exception("Response was not XML\n\n" . $this->echoLastResponse());
|
throw new Exception("Response was not XML\n\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -467,7 +464,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseContentTypeIs($contentType)
|
public function theResponseContentTypeIs($contentType)
|
||||||
{
|
{
|
||||||
if ($this->_contentType != $contentType) {
|
if ($this->_contentType != $contentType) {
|
||||||
throw new Exception("Response Content Type was not $contentType\n\n" . $this->echoLastResponse());
|
throw new Exception("Response Content Type was not $contentType\n\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -477,7 +474,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseCharsetIs($charset)
|
public function theResponseCharsetIs($charset)
|
||||||
{
|
{
|
||||||
if (strtoupper($this->_charset) != strtoupper($charset)) {
|
if (strtoupper($this->_charset) != strtoupper($charset)) {
|
||||||
throw new Exception("Response charset was not $charset\n\n" . $this->echoLastResponse());
|
throw new Exception("Response charset was not $charset\n\n" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,8 +484,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseLanguageIs($language)
|
public function theResponseLanguageIs($language)
|
||||||
{
|
{
|
||||||
if ($this->_language != $language) {
|
if ($this->_language != $language) {
|
||||||
throw new Exception("Response Language was not $language\n\n"
|
throw new Exception("Response Language was not $language\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -498,14 +494,13 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseHeaderShouldBe($header, $value)
|
public function theResponseHeaderShouldBe($header, $value)
|
||||||
{
|
{
|
||||||
if (!$this->_response->hasHeader($header)) {
|
if (!$this->_response->hasHeader($header)) {
|
||||||
throw new Exception("Response header $header was not found\n\n"
|
throw new Exception("Response header $header was not found\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if ((string)$this->_response->getHeader($header) !== $value) {
|
if ((string)$this->_response->getHeader($header) !== $value) {
|
||||||
throw new Exception("Response header $header ("
|
throw new Exception("Response header $header ("
|
||||||
. (string)$this->_response->getHeader($header)
|
. (string)$this->_response->getHeader($header)
|
||||||
. ") does not match `$value`\n\n"
|
. ") does not match '$value'\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,7 +529,7 @@ class RestContext extends BehatContext
|
|||||||
if ($diff < $milliSeconds) {
|
if ($diff < $milliSeconds) {
|
||||||
throw new Exception("Response time $diff is "
|
throw new Exception("Response time $diff is "
|
||||||
. "quicker than $milliSeconds\n\n"
|
. "quicker than $milliSeconds\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,8 +542,7 @@ class RestContext extends BehatContext
|
|||||||
if (is_array($data) && count($data) == 0) {
|
if (is_array($data) && count($data) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
throw new Exception("Response is not an empty array\n\n" .
|
throw new Exception("Response is not an empty array\n\n" );
|
||||||
$this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -572,8 +566,7 @@ class RestContext extends BehatContext
|
|||||||
if (is_null($data)) return;
|
if (is_null($data)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception("Response is not of type '$type'\n\n" .
|
throw new Exception("Response is not of type '$type'\n\n" );
|
||||||
$this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -583,8 +576,7 @@ class RestContext extends BehatContext
|
|||||||
{
|
{
|
||||||
$data = $this->_data;
|
$data = $this->_data;
|
||||||
if (isset($this->{$property}) ) {
|
if (isset($this->{$property}) ) {
|
||||||
throw new Exception("The property $property is not defined in the Response\n\n" .
|
throw new Exception("The property $property is not defined in the Response\n\n" );
|
||||||
$this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
$theProperty = $data->{$property};
|
$theProperty = $data->{$property};
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
@@ -602,8 +594,7 @@ class RestContext extends BehatContext
|
|||||||
if (is_null($theProperty)) return;
|
if (is_null($theProperty)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception("The property $property in Response is not of type '$type'\n\n" .
|
throw new Exception("The property $property in Response is not of type '$type'\n\n");
|
||||||
$this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,8 +604,7 @@ class RestContext extends BehatContext
|
|||||||
{
|
{
|
||||||
$data = $this->_data;
|
$data = $this->_data;
|
||||||
if ($data !== $sample) {
|
if ($data !== $sample) {
|
||||||
throw new Exception("Response value does not match '$sample'\n\n"
|
throw new Exception("Response value does not match '$sample'\n\n" );
|
||||||
. $this->echoLastResponse() );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -642,7 +632,7 @@ class RestContext extends BehatContext
|
|||||||
public function theResponseIsJsonWithType($type)
|
public function theResponseIsJsonWithType($type)
|
||||||
{
|
{
|
||||||
if ($this->_type != 'json') {
|
if ($this->_type != 'json') {
|
||||||
throw new Exception("Response was not JSON\n\n" . $this->echoLastResponse());
|
throw new Exception("Response was not JSON\n\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = $this->_data;
|
$data = $this->_data;
|
||||||
@@ -662,8 +652,7 @@ class RestContext extends BehatContext
|
|||||||
if (is_null($data)) return;
|
if (is_null($data)) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception("Response was JSON\n but not of type '$type'\n\n" .
|
throw new Exception("Response was JSON\n but not of type '$type'\n\n" );
|
||||||
$this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -679,9 +668,7 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
if (!isset($data->$propertyName)) {
|
if (!isset($data->$propertyName)) {
|
||||||
throw new Exception("Property '"
|
throw new Exception("Property '$propertyName' is not set!\n\n");
|
||||||
. $propertyName . "' is not set!\n\n"
|
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -695,15 +682,13 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
if (!isset($data->$propertyName)) {
|
if (!isset($data->$propertyName)) {
|
||||||
throw new Exception("Property '"
|
throw new Exception("Property '$propertyName' is not set!\n\n" );
|
||||||
. $propertyName . "' is not set!\n\n"
|
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if ($data->$propertyName != $propertyValue) {
|
if ($data->$propertyName != $propertyValue) {
|
||||||
throw new \Exception('Property value mismatch! (given: '
|
throw new \Exception('Property value mismatch! (given: '
|
||||||
. $propertyValue . ', match: '
|
. $propertyValue . ', match: '
|
||||||
. $data->$propertyName . ")\n\n"
|
. $data->$propertyName . ")\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Response was not JSON\n\n"
|
throw new Exception("Response was not JSON\n\n"
|
||||||
@@ -729,23 +714,21 @@ class RestContext extends BehatContext
|
|||||||
$data = $this->_data;
|
$data = $this->_data;
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
if (!is_array($data)) {
|
if (!is_array($data)) {
|
||||||
throw new Exception("the Response data is not an array!\n\n"
|
throw new Exception("the Response data is not an array!\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if (is_array($data) && !isset($data[$row])) {
|
if (is_array($data) && !isset($data[$row])) {
|
||||||
throw new Exception("the Response data is an array, but the row '$row' does not exists!\n\n"
|
throw new Exception("the Response data is an array, but the row '$row' does not exists!\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if (!isset($data[$row]->$propertyName)) {
|
if (!isset($data[$row]->$propertyName)) {
|
||||||
throw new Exception("Property '"
|
throw new Exception("Property '"
|
||||||
. $propertyName . "' is not set!\n\n"
|
. $propertyName . "' is not set!\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
if ($data[$row]->$propertyName != $propertyValue) {
|
if ($data[$row]->$propertyName != $propertyValue) {
|
||||||
throw new \Exception('Property value mismatch! (given: '
|
throw new \Exception('Property value mismatch! (given: '
|
||||||
. $propertyValue . ', match: '
|
. $propertyValue . ', match: '
|
||||||
. $data[$row]->$propertyName . ")\n\n"
|
. $data[$row]->$propertyName . ")\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Response was not JSON\n\n"
|
throw new Exception("Response was not JSON\n\n"
|
||||||
@@ -793,17 +776,15 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
if (!is_array($data)) {
|
if (!is_array($data)) {
|
||||||
throw new Exception("the $propertyParent in Response data is not an array!\n\n"
|
throw new Exception("the $propertyParent in Response data is not an array!\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if (is_array($data) && !isset($data[$row])) {
|
if (is_array($data) && !isset($data[$row])) {
|
||||||
throw new Exception("the Response data is an array, but the row '$row' does not exists!\n\n"
|
throw new Exception("the Response data is an array, but the row '$row' does not exists!\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if (!isset($data[$row]->$propertyName)) {
|
if (!isset($data[$row]->$propertyName)) {
|
||||||
throw new Exception("Property '"
|
throw new Exception("Property '"
|
||||||
. $propertyName . "' is not set!\n\n"
|
. $propertyName . "' is not set!\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
if (is_array($data[$row]->$propertyName)) {
|
if (is_array($data[$row]->$propertyName)) {
|
||||||
throw new Exception("$propertyName is an array and we expected a value\n\n"
|
throw new Exception("$propertyName is an array and we expected a value\n\n"
|
||||||
@@ -813,7 +794,7 @@ class RestContext extends BehatContext
|
|||||||
throw new \Exception('Property value mismatch! (given: '
|
throw new \Exception('Property value mismatch! (given: '
|
||||||
. $propertyValue . ', match: '
|
. $propertyValue . ', match: '
|
||||||
. $data[$row]->$propertyName . ")\n\n"
|
. $data[$row]->$propertyName . ")\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Response was not JSON\n\n"
|
throw new Exception("Response was not JSON\n\n"
|
||||||
@@ -843,16 +824,13 @@ class RestContext extends BehatContext
|
|||||||
|
|
||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
if (!is_array($data)) {
|
if (!is_array($data)) {
|
||||||
throw new Exception("the property $propertyParent in Response data is not an array!\n\n"
|
throw new Exception("the property $propertyParent in Response data is not an array!\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if (is_array($data) && !isset($data[$row])) {
|
if (is_array($data) && !isset($data[$row])) {
|
||||||
throw new Exception("the Response data is an array, but the row '$row' does not exists!\n\n"
|
throw new Exception("the Response data is an array, but the row '$row' does not exists!\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if (!isset($data[$row]->$propertyName)) {
|
if (!isset($data[$row]->$propertyName)) {
|
||||||
throw new Exception("Property '$propertyName' is not set in $propertyParent!\n\n"
|
throw new Exception("Property '$propertyName' is not set in $propertyParent!\n\n");
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
if ($propertyType == 'array' && is_array($data[$row]->$propertyName)) {
|
if ($propertyType == 'array' && is_array($data[$row]->$propertyName)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -880,8 +858,7 @@ class RestContext extends BehatContext
|
|||||||
if (!empty($data)) {
|
if (!empty($data)) {
|
||||||
if (!isset($data->$propertyName)) {
|
if (!isset($data->$propertyName)) {
|
||||||
throw new Exception("Property '"
|
throw new Exception("Property '"
|
||||||
. $propertyName . "' is not set!\n\n"
|
. $propertyName . "' is not set!\n\n");
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
// check our type
|
// check our type
|
||||||
switch (strtolower($typeString)) {
|
switch (strtolower($typeString)) {
|
||||||
@@ -889,8 +866,7 @@ class RestContext extends BehatContext
|
|||||||
if (!is_numeric($data->$propertyName)) {
|
if (!is_numeric($data->$propertyName)) {
|
||||||
throw new Exception("Property '"
|
throw new Exception("Property '"
|
||||||
. $propertyName . "' is not of the correct type: "
|
. $propertyName . "' is not of the correct type: "
|
||||||
. $typeString . "!\n\n"
|
. $typeString . "!\n\n");
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -909,7 +885,7 @@ class RestContext extends BehatContext
|
|||||||
if ((string)$this->_response->getStatusCode() !== $httpStatus) {
|
if ((string)$this->_response->getStatusCode() !== $httpStatus) {
|
||||||
throw new \Exception('HTTP code does not match ' . $httpStatus .
|
throw new \Exception('HTTP code does not match ' . $httpStatus .
|
||||||
' (actual: ' . $this->_response->getStatusCode() . ")\n\n"
|
' (actual: ' . $this->_response->getStatusCode() . ")\n\n"
|
||||||
. $this->echoLastResponse());
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -922,8 +898,7 @@ class RestContext extends BehatContext
|
|||||||
$fileData = file_get_contents(__DIR__ . "/../json/" . $jsonFile);
|
$fileData = file_get_contents(__DIR__ . "/../json/" . $jsonFile);
|
||||||
$fileJson = json_decode($fileData);
|
$fileJson = json_decode($fileData);
|
||||||
if ($this->_data != $fileJson) {
|
if ($this->_data != $fileJson) {
|
||||||
throw new \Exception("JSON Response does not match json file: $jsonFile\n\n"
|
throw new \Exception("JSON Response does not match json file: $jsonFile\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -985,8 +960,7 @@ class RestContext extends BehatContext
|
|||||||
public function storeIn($varName)
|
public function storeIn($varName)
|
||||||
{
|
{
|
||||||
if (!isset($this->_data->$varName)) {
|
if (!isset($this->_data->$varName)) {
|
||||||
throw new \Exception("JSON Response does not have '$varName' property\n\n"
|
throw new \Exception("JSON Response does not have '$varName' property\n\n" );
|
||||||
. $this->echoLastResponse());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$varValue = $this->_data->$varName;
|
$varValue = $this->_data->$varName;
|
||||||
|
|||||||
Reference in New Issue
Block a user