Merged in darojas/processmaker (pull request #379)

Se elimina la clase Cases que se creo por error. Se agregan validaciones en Input Documents y Cases. Se agregan unit test para OUTPUT DOCUMENTS, PROCESS CATEGORY, INPUTDOCUMENTS y se agregan validaciones para OUTPUT DOCUMENTS y PROCESS CATEGORY.
This commit is contained in:
Erik Amaru Ortiz
2014-04-08 13:17:06 -04:00
8 changed files with 164 additions and 531 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -321,7 +321,7 @@ class Cases
$array['app_name'] = $array['caseName'];
$array['app_status'] = $array['caseStatus'];
$array['app_init_usr_uid'] = $array['caseCreatorUser'];
$array['app_init_usr_username'] = $array['caseCreatorUserName'];
$array['app_init_usr_username'] = trim($array['caseCreatorUserName']);
$array['pro_uid'] = $array['processId'];
$array['pro_name'] = $array['processName'];
$array['app_create_date'] = $array['createDate'];
@@ -412,7 +412,7 @@ class Cases
$array['app_name'] = $array['caseName'];
$array['app_status'] = $array['caseStatus'];
$array['app_init_usr_uid'] = $array['caseCreatorUser'];
$array['app_init_usr_username'] = $array['caseCreatorUserName'];
$array['app_init_usr_username'] = trim($array['caseCreatorUserName']);
$array['pro_uid'] = $array['processId'];
$array['pro_name'] = $array['processName'];
$array['app_create_date'] = $array['createDate'];
@@ -529,6 +529,14 @@ class Cases
if ($variables) {
$variables = array_shift($variables);
}
$oProcesses = new \Processes();
if (! $oProcesses->processExists($processUid)) {
throw (new \Exception( 'Invalid value specified for \'pro_uid\''));
}
$oTask = new \Task();
if (! $oTask->taskExists($taskUid)) {
throw (new \Exception( 'Invalid value specified for \'tas_uid\''));
}
$fields = $ws->newCase($processUid, $userUid, $taskUid, $variables);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {
@@ -570,6 +578,14 @@ class Cases
} elseif ($variables == null) {
$variables = array(array());
}
$oProcesses = new \Processes();
if (! $oProcesses->processExists($processUid)) {
throw (new \Exception( 'Invalid value specified for \'pro_uid\''));
}
$user = new \Users();
if (! $user->userExists( $userUid )) {
throw (new \Exception( 'Invalid value specified for \'usr_uid\''));
}
$fields = $ws->newCaseImpersonate($processUid, $userUid, $variables, $taskUid);
$array = json_decode(json_encode($fields), true);
if ($array ["status_code"] != 0) {

View File

@@ -14,6 +14,10 @@ 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');
@@ -32,7 +36,7 @@ class InputDocument
$docrow['app_doc_filename'] = $row['APP_DOC_FILENAME'];
$docrow['doc_uid'] = $row['DOC_UID'];
$docrow['app_doc_version'] = $row['DOC_VERSION'];
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
$docrow['app_doc_create_date'] = $row['CREATE_DATE'];
$docrow['app_doc_create_user'] = $row['CREATED_BY'];
$docrow['app_doc_type'] = $row['TYPE'];
$docrow['app_doc_index'] = $row['APP_DOC_INDEX'];
@@ -60,7 +64,7 @@ class InputDocument
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!'));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
@@ -109,7 +113,7 @@ class InputDocument
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $inputDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This input document with id: '.$inputDocumentUid.' doesn\'t exist!'));
throw (new \Exception('This input document with inp_doc_uid: '.$inputDocumentUid.' doesn\'t exist!'));
}
\G::LoadClass('wsBase');
$ws = new \wsBase();

View File

@@ -56,6 +56,10 @@ class OutputDocument
public function getCasesOutputDocument($applicationUid, $userUid, $applicationDocumentUid)
{
try {
$oAppDocument = \AppDocumentPeer::retrieveByPK( $applicationDocumentUid, 1 );
if (is_null( $oAppDocument ) || $oAppDocument->getAppDocStatus() == 'DELETED') {
throw (new \Exception('This output document with id: '.$applicationDocumentUid.' doesn\'t exist!'));
}
$sApplicationUID = $applicationUid;
$sUserUID = $userUid;
\G::LoadClass('case');

View File

@@ -282,7 +282,10 @@ class ProcessCategory
public function addCategory($cat_name)
{
try {
require_once 'classes/model/ProcessCategory.php';
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "ProcessCategory.php");
if ($cat_name == '') {
throw (new \Exception( 'cat_name. Process Category name can\'t be null'));
}
$catName = trim( $cat_name );
if ($this->existsName( $cat_name )) {
throw (new \Exception( 'cat_name. Duplicate Process Category name'));
@@ -312,7 +315,7 @@ class ProcessCategory
public function updateCategory($cat_uid, $cat_name)
{
try {
require_once 'classes/model/ProcessCategory.php';
require_once (PATH_TRUNK . "workflow" . PATH_SEP . "engine" . PATH_SEP . "classes". PATH_SEP . "model" . PATH_SEP . "ProcessCategory.php");
$catUID = $cat_uid;
$catName = trim( $cat_name );
if ($this->existsName( $cat_name )) {

View File

@@ -177,14 +177,12 @@ class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
* Test error for incorrect value of input document in array
*
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::removeInputDocument
* @depends testAddInputDocument
* @param array $aResponse
* @expectedException Exception
* @expectedExceptionMessage This input document with id: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesInputDocumentErrorIncorrectApplicationValueArray(array $aResponse)
public function testRemoveInputDocumentErrorIncorrectApplicationValueArray()
{
$this->oInputDocument->removeInputDocument('12345678912345678912345678912345678');
}

View File

@@ -101,6 +101,20 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
return $aResponse;
}
/**
* Test error for incorrect value of application in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocuments
* @expectedException Exception
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocumentsErrorIncorrectApplicationValueArray()
{
$this->oOutputDocument->getCasesOutputDocuments('12345678912345678912345678912345678', self::$usrUid);
}
/**
* Test get OutputDocuments
*
@@ -116,6 +130,38 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_array($response));
}
/**
* Test error for incorrect value of application in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
* @depends testAddCasesOutputDocument
* @param array $aResponse
* @expectedException Exception
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocumentErrorIncorrectApplicationValueArray(array $aResponse)
{
$this->oOutputDocument->getCasesOutputDocument('12345678912345678912345678912345678', self::$usrUid, $aResponse["app_doc_uid"]);
}
/**
* Test error for incorrect value of output document in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
* @depends testAddCasesOutputDocument
* @param array $aResponse
* @expectedException Exception
* @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetCasesOutputDocumentErrorIncorrectOutputDocumentValueArray(array $aResponse)
{
$this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], self::$usrUid, '12345678912345678912345678912345678');
}
/**
* Test get OutputDocument
*
@@ -131,6 +177,20 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_object($response));
}
/**
* Test error for incorrect value of output document in array
*
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::removeOutputDocument
* @expectedException Exception
* @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testRemoveOutputDocumentErrorIncorrectOutputDocumentValueArray()
{
$this->oOutputDocument->removeOutputDocument('12345678912345678912345678912345678');
}
/**
* Test remove OutputDocument
*

View File

@@ -40,6 +40,20 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
}
}
/**
* Test error for incorrect value of category name in array
*
* @covers \BusinessModel\ProcessCategory::addCategory
* @expectedException Exception
* @expectedExceptionMessage cat_name. Process Category name can't be null
*
* @copyright Colosa - Bolivia
*/
public function testAddCategoryErrorIncorrectValue()
{
$this->oCategory->addCategory('');
}
/**
* Test add Category
*
@@ -55,6 +69,34 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
return $aResponse;
}
/**
* Test error for incorrect value of category name in array
*
* @covers \BusinessModel\ProcessCategory::addCategory
* @expectedException Exception
* @expectedExceptionMessage cat_name. Duplicate Process Category name
*
* @copyright Colosa - Bolivia
*/
public function testAddCategoryErrorDuplicateValue()
{
$this->oCategory->addCategory('New Category Test');
}
/**
* Test error for incorrect value of category name in array
*
* @covers \BusinessModel\ProcessCategory::updateCategory
* @expectedException Exception
* @expectedExceptionMessage cat_name. Duplicate Process Category name
*
* @copyright Colosa - Bolivia
*/
public function testUpdateCategoryErrorDuplicateValue()
{
$this->oCategory->addCategory('New Category Test');
}
/**
* Test put Category
*
@@ -70,6 +112,20 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_object($response));
}
/**
* Test error for incorrect value of category id
*
* @covers \BusinessModel\ProcessCategory::getCategory
* @expectedException Exception
* @expectedExceptionMessage The Category with cat_uid: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testGetErrorValue()
{
$this->oCategory->getCategory('12345678912345678912345678912345678');
}
/**
* Test get Category
*
@@ -85,6 +141,19 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(is_object($response));
}
/**
* Test error for incorrect value of category id
*
* @covers \BusinessModel\ProcessCategory::deleteCategory
* @expectedException Exception
* @expectedExceptionMessage The Category with cat_uid: 12345678912345678912345678912345678 doesn't exist!
*
* @copyright Colosa - Bolivia
*/
public function testDeleteErrorValue()
{
$this->oCategory->deleteCategory('12345678912345678912345678912345678');
}
/**
* Test delete Category