diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php index c47497f25..f21057f0d 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases/OutputDocument.php @@ -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'); diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php index 7cbc34de0..f88293cff 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/ProcessCategory.php @@ -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 )) { diff --git a/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php b/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php index 4d0adb89f..286244aa8 100644 --- a/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php +++ b/workflow/engine/src/Tests/BusinessModel/InputDocumentsCasesTest.php @@ -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'); } diff --git a/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php b/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php index 140971356..59972c8d4 100644 --- a/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php +++ b/workflow/engine/src/Tests/BusinessModel/OutputDocumentsCasesTest.php @@ -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 * diff --git a/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php b/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php index f0a1a3e25..742cae5f2 100644 --- a/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php +++ b/workflow/engine/src/Tests/BusinessModel/ProcessCategoryTest.php @@ -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