Merged in darojas/processmaker (pull request #414)

Arreglo en errores en BEHAT y adicion de validaciones para inputDocuments and outputDocuments
This commit is contained in:
Erik Amaru Ortiz
2014-04-23 17:29:06 -04:00
4 changed files with 98 additions and 124 deletions

View File

@@ -15,14 +15,6 @@ Scenario: Returns a list of the generated documents for a given cases
And the type is "array"
And the response has 1 records
Scenario: Returns a generated document for a given case
Given I request "cases/33125846153383cecdf64f1079330191/output-document/75468909953383d0bc42f96046736849"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Scenario: Generate or regenerates an output documents for a given case
Given POST this data:
"""
@@ -37,11 +29,15 @@ Scenario: Generate or regenerates an output documents for a given case
And the type is "array"
And store "app_doc_uid" in session array as variable "app_doc_uid_0"
Scenario: Returns a generated document for a given case
Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_0"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "object"
Scenario: Delete an uploaded or generated document from a case.
And that I want to delete a resource with the key "app_doc_uid_0" stored in session array
Given I request "output-document"
Given that I want to delete a resource with the key "app_doc_uid_0" stored in session array
And I request "cases/33125846153383cecdf64f1079330191/output-document"
Then the response status code should be 200
And the content type is "application/json"
And the response charset is "UTF-8"

View File

@@ -39,40 +39,25 @@ Scenario: Returns a list of the generated documents for a given cases
And the response charset is "UTF-8"
And the type is "array"
And the response has 6 records
And the "app_doc_filename" property in row 0 equals "output document new version.pdf"
And the "app_doc_filename" property in row 1 equals "output document with pdf security.pdf"
And the "app_doc_filename" property in row 2 equals "output document only pdf.pdf"
And the "app_doc_filename" property in row 3 equals "output document only doc.doc"
And the "app_doc_filename" property in row 4 equals "output document with versioning.pdf"
And the "app_doc_filename" property in row 5 equals "output document old version.pdf"
Scenario Outline: Returns an generated document for a given case
Given I request "cases/33125846153383cecdf64f1079330191/output-document/app_doc_uid" with the key "app_doc_uid" stored in session array as variable "app_doc_uid_<app_doc_uid_number>"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "Object"
And the "app_doc_uid" property equals "<app_doc_uid>"
And the type is "array"
And the "app_doc_filename" property equals "<app_doc_filename>"
And the "doc_uid" property equals "<doc_uid>"
And the "app_doc_version" property equals "<app_doc_version>"
And the "app_doc_create_date" property equals "<app_doc_create_date>"
And the "app_doc_create_user" property equals "<app_doc_create_user>"
And the "app_doc_type" property equals "<app_doc_type>"
And the "app_doc_index" property equals "<app_doc_index>"
And the "app_doc_link" property equals "<app_doc_link>"
Examples:
| test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_version | app_doc_create_date | app_doc_create_user | app_doc_type | app_doc_index | app_doc_link |
| Get Output "output document new version.pdf" | 1 | output document new version.pdf | 3391282325331ee81c84715031595672 | 1 | 2014-03-26 12:29:30 | , Administrator (admin) | OUTPUT BOTH | 1 | cases/cases_ShowOutputDocument?a=3000248055333006ab56a01005891659&v=1&ext=pdf&random=1256696859 |
| Get Output "output document old version.pdf" | 2 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | 1 | 2014-03-26 12:29:33 | , Administrator (admin) | OUTPUT BOTH | 2 | cases/cases_ShowOutputDocument?a=8865432395333006d75d824038425476&v=1&ext=pdf&random=1838956992 |
| Get Output "output document only doc.doc" | 3 | output document only doc.doc | 2087233055331ef4127d238097105696 | 1 | 2014-03-26 12:29:35 | , Administrator (admin) | OUTPUT DOC | 3 | cases/cases_ShowOutputDocument?a=4447256265333006fe6fb00061503934&v=1&ext=doc&random=949245639 |
| Get Output "output document only pdf.pdf" | 4 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | 1 | 2014-03-26 12:29:38 | , Administrator (admin) | OUTPUT PDF | 4 | cases/cases_ShowOutputDocument?a=828039615533300724fdcb6091842678&v=1&ext=pdf&random=401448562 |
| Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf | 8594478445331eff2d30767061922215 | 1 | 2014-03-26 12:29:40 | , Administrator (admin) | OUTPUT BOTH | 5 | cases/cases_ShowOutputDocument?a=25293137553330074713ab9073501576&v=1&ext=pdf&random=324546362 |
| Get Output "output document with versioning.pdf" | 6 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | 1 | 2014-03-26 12:29:42 | , Administrator (admin) | OUTPUT BOTH | 6 | cases/cases_ShowOutputDocument?a=354826487533300769e65e0027827984&v=1&ext=pdf&random=1682978530 |
| test_description | app_doc_uid_number | app_doc_filename | doc_uid | app_doc_create_user | app_doc_type |
| Get Output "output document only doc.doc" | 1 | output document only doc.doc | 2087233055331ef4127d238097105696 | , Administrator (admin) | OUTPUT DOC |
| Get Output "output document with versioning.pdf" | 2 | output document with versioning.pdf | 5961108155331efc976cee7011445347 | , Administrator (admin) | OUTPUT BOTH |
| Get Output "output document only pdf.pdf" | 3 | output document only pdf.pdf | 7074907425331ef837aa8b2055964905 | , Administrator (admin) | OUTPUT PDF |
| Get Output "output document old version.pdf" | 4 | output document old version.pdf | 7385645355331ee70ea6a87029841722 | , Administrator (admin) | OUTPUT BOTH |
| Get Output "output document with pdf security.pdf" | 5 | output document with pdf security.pdf| 8594478445331eff2d30767061922215 | , Administrator (admin) | OUTPUT BOTH |
Scenario Outline: Delete an uploaded or generated document from a case.
@@ -91,6 +76,3 @@ Scenario Outline: Delete an uploaded or generated document from a case.
| 3 |
| 4 |
| 5 |

View File

@@ -14,10 +14,6 @@ class InputDocument
public function getCasesInputDocuments($applicationUid, $userUid)
{
try {
$oApplication = \ApplicationPeer::retrieveByPk($applicationUid);
if (!is_object($oApplication)) {
throw (new \Exception("The Application with app_uid: '$applicationUid' doesn't exist!"));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');
@@ -62,10 +58,6 @@ class InputDocument
public function getCasesInputDocument($applicationUid, $userUid, $inputDocumentUid)
{
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!'));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');
@@ -90,6 +82,10 @@ class InputDocument
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
$docrow['app_doc_link'] = 'cases/' . $row['DOWNLOAD_LINK'];
if ($docrow['app_doc_uid'] == $inputDocumentUid) {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, $row['DOC_VERSION'] );
if (is_null( $oAppDocument )) {
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
}
$result = $docrow;
}
}
@@ -183,10 +179,10 @@ class InputDocument
//Triggers
$arrayTrigger = $case->loadTriggers($taskUid, "INPUT_DOCUMENT", $inputDocumentUid, "AFTER");
//Add Input Document
$_FILES["form"]["name"] = '';
$_FILES["form"]["error"] = '';
$_FILES["form"]["tmp_name"] = '';
if ($_FILES["form"]["error"] == '') {
if (empty($_FILES)) {
throw (new \Exception('This document filename doesn\'t exist!'));
}
if (!$_FILES["form"]["error"]) {
$_FILES["form"]["error"] = 0;
}
if (isset($_FILES) && isset($_FILES["form"]) && count($_FILES["form"]) > 0) {
@@ -226,4 +222,3 @@ class InputDocument
}
}
}

View File

@@ -104,13 +104,14 @@ class OutputDocument
public function removeOutputDocument($applicationDocumentUid)
{
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 );
$oAppDocumentVersion = new \AppDocument();
$lastDocVersion = $oAppDocumentVersion->getLastAppDocVersion($applicationDocumentUid);
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, $lastDocVersion);
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!'));
}
\G::LoadClass('wsBase');
$ws = new \wsBase();
$ws->removeDocument($applicationDocumentUid);
$aFields = array ('APP_DOC_UID' => $applicationDocumentUid,'DOC_VERSION' => $lastDocVersion,'APP_DOC_STATUS' => 'DELETED');
$oAppDocument->update( $aFields );
} catch (\Exception $e) {
throw $e;
}