Arreglo a behat para events

This commit is contained in:
Brayan Osmar Pereyra Suxo
2014-01-10 15:32:14 -04:00
parent 61e11ae39f
commit d8d5d1d44f
5 changed files with 82 additions and 19 deletions

View File

@@ -1,8 +1,17 @@
@ProcessMakerMichelangelo @RestAPI
Feature: Testing events
Feature: Events Resources
@1: TEST FOR POST EVENT /----------------------------------------------------------------------
Scenario: Create a event
@1: TEST FOR GET EVENTS /----------------------------------------------------------------------
Scenario: List all the events (result 0 events)
Given that I have a valid access_token
And I request "project/251815090529619a99a2bf4013294414/events"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has 0 record
@2: TEST FOR POST EVENT /----------------------------------------------------------------------
Scenario: Create a new event
Given that I have a valid access_token
And POST this data:
"""
@@ -24,8 +33,15 @@ Feature: Testing events
Then the response status code should be 201
And store "evn_uid" in session array
@3: TEST FOR GET EVENTS /----------------------------------------------------------------------
Scenario: List all the events (result 1 event)
Given that I have a valid access_token
And I request "project/251815090529619a99a2bf4013294414/events"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has 1 record
@2: TEST FOR PUT EVENT /-----------------------------------------------------------------------
@4: TEST FOR PUT EVENT /-----------------------------------------------------------------------
Scenario: Update a event
Given that I have a valid access_token
And PUT this data:
@@ -51,8 +67,8 @@ Feature: Testing events
And the type is "object"
@3: TEST FOR GET EVENT /-----------------------------------------------------------------------
Scenario: Get a event
@5: TEST FOR GET EVENT /-----------------------------------------------------------------------
Scenario: Get a event (with change in "evn_description")
Given that I have a valid access_token
And that I want to get a resource with the key "evn_uid" stored in session array
And I request "project/251815090529619a99a2bf4013294414/event"
@@ -62,11 +78,19 @@ Feature: Testing events
And that "evn_description" is set to "change description"
@4: TEST FOR DELETE EVENT /-----------------------------------------------------------------------
@6: TEST FOR DELETE EVENT /-----------------------------------------------------------------------
Scenario: Delete a event
Given that I have a valid access_token
And that I want to delete 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 the type is "object"
@7: TEST FOR GET EVENTS /----------------------------------------------------------------------
Scenario: List all the events (result 0 events)
Given that I have a valid access_token
And I request "project/251815090529619a99a2bf4013294414/events"
Then the response status code should be 200
And the response charset is "UTF-8"
And the response has 0 record

View File

@@ -1100,13 +1100,12 @@ class RestContext extends BehatContext
public function theResponseHasRecords($quantityOfRecords)
{
$data = $this->_data;
if (!is_array($data)) {
throw new Exception("the Response data is not an array!\n\n" );
}
$currentRecordsCount=count($data);
if($currentRecordsCount!=$quantityOfRecords){
if (!is_array($data)) {
throw new Exception("the Response data is not an array!\n\n" );
}
$currentRecordsCount=count($data);
if($currentRecordsCount!=$quantityOfRecords){
throw new Exception('Records quantity not match ' . $quantityOfRecords . ' (actual: ' . $currentRecordsCount . ")\n\n");
}
}
}
}

View File

@@ -21,6 +21,11 @@ class Event
*/
public function getEvents($sProcessUID, $filter = '', $sEventUID = '')
{
$oProcess = new \Process();
if (!($oProcess->processExists($sProcessUID))) {
throw (new \Exception( 'This process doesn\'t exist!' ));
}
$sDelimiter = \DBAdapter::getStringDelimiter();
$oCriteria = new \Criteria('workflow');
$oCriteria->addSelectColumn(\EventPeer::EVN_UID);
@@ -88,6 +93,12 @@ class Event
if ( ($sProcessUID == '') || (count($dataEvent) == 0) ) {
return false;
}
$oProcess = new \Process();
if (!($oProcess->processExists($sProcessUID))) {
throw (new \Exception( 'This process doesn\'t exist!' ));
}
$dataEvent = array_change_key_case($dataEvent, CASE_UPPER);
if ( $create && (isset($dataEvent['ENV_UID'])) ) {

View File

@@ -15,8 +15,6 @@ class ProcessPermissions
/**
* Get list for ProcessPermissions
* @var string $sProcessUID. Uid for Process
* @var string $filter.
* @var string $sEventUID. Uid for Process
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
@@ -24,14 +22,16 @@ class ProcessPermissions
*
* @return array
*/
public function getProcessPermissions($sProcessUID)
public function getProcessPermissions($sProcessUID, $sPermissionUid = '')
{
G::LoadClass('case');
Cases::verifyTable();
$aObjectsPermissions = array();
//$aObjectsPermissions[] = array('OP_UID' => 'char', 'TASK_TARGET' => 'char', 'GROUP_USER' => 'char', 'TASK_SOURCE' => 'char', 'OBJECT_TYPE' => 'char', 'OBJECT' => 'char', 'PARTICIPATED' => 'char', 'ACTION' => 'char', 'OP_CASE_STATUS' => 'char');
$oCriteria = new \Criteria('workflow');
$oCriteria->add(ObjectPermissionPeer::PRO_UID, $sProcessUID);
if ($sPermissionUid != '') {
$oCriteria->add(ObjectPermissionPeer::OP_UID, $sPermissionUid);
}
$oDataset = ObjectPermissionPeer::doSelectRS($oCriteria);
$oDataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
$oDataset->next();
@@ -155,6 +155,12 @@ class ProcessPermissions
$aObjectsPermissions[] = array_merge($aRow, array('OP_UID' => $aRow['OP_UID'], 'TASK_TARGET' => $sTaskTarget, 'GROUP_USER' => $sUserGroup, 'TASK_SOURCE' => $sTaskSource, 'OBJECT_TYPE' => $sObjectType, 'OBJECT' => $sObject, 'PARTICIPATED' => $sParticipated, 'ACTION' => $sAction, 'OP_CASE_STATUS' => $aRow['OP_CASE_STATUS']));
$oDataset->next();
}
if ($sPermissionUid != '' && empty($aObjectsPermissions)) {
throw (new \Exception( 'This row doesn\'t exist!' ));
} else if ($sPermissionUid != '' && !empty($aObjectsPermissions)) {
return current($aObjectsPermissions);
}
return $aObjectsPermissions;
}
}

View File

@@ -35,5 +35,28 @@ class ProcessPermissions extends Api
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
/**
* @param string $projectUid {@min 1} {@max 32}
* @param string $objectPermissionUid {@min 1} {@max 32}
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return array
*
* @url GET /:projectUid/process-permission/:objectPermissionUid
*/
public function doGetProcessPermission($projectUid, $objectPermissionUid)
{
try {
$processPermissions = new \BusinessModel\ProcessPermissions();
$response = $processPermissions->getProcessPermissions($projectUid, $objectPermissionUid);
return $response;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
}
}