diff --git a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php index f1a8ed6b3..468123114 100644 --- a/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php +++ b/workflow/engine/src/ProcessMaker/BusinessModel/Cases.php @@ -610,12 +610,16 @@ class Cases $ws = new \wsBase(); $fields = $ws->reassignCase($userUid, $applicationUid, $delIndex, $userUidTarget, $userUidSource); $array = json_decode(json_encode($fields), true); - if ($array ["status_code"] != 0) { - throw (new \Exception($array ["message"])); + if (array_key_exists("status_code", $array)) { + if ($array ["status_code"] != 0) { + throw (new \Exception($array ["message"])); + } else { + unset($array['status_code']); + unset($array['message']); + unset($array['timestamp']); + } } else { - unset($array['status_code']); - unset($array['message']); - unset($array['timestamp']); + throw (new \Exception('The Application with app_uid: '.$applicationUid.' doesn\'t exist')); } } catch (\Exception $e) { throw $e; diff --git a/workflow/engine/src/Tests/BusinessModel/CasesTest7_12.php b/workflow/engine/src/Tests/BusinessModel/CasesTest7_12.php index 33d934d56..1477fd50f 100644 --- a/workflow/engine/src/Tests/BusinessModel/CasesTest7_12.php +++ b/workflow/engine/src/Tests/BusinessModel/CasesTest7_12.php @@ -83,6 +83,34 @@ class CasesTest extends \PHPUnit_Framework_TestCase return true; } + /** + * Test error for incorrect value of process in array + * + * @covers \ProcessMaker\BusinessModel\Cases::addCase + * @expectedException Exception + * @expectedExceptionMessage Invalid process 12345678912345678912345678912345678 + * + * @copyright Colosa - Bolivia + */ + public function testAddCaseErrorIncorrectProcessValueArray() + { + $this->oCases->addCase('12345678912345678912345678912345678', self::$tasUid, self::$usrUid, array()); + } + + /** + * Test error for incorrect value of task in array + * + * @covers \ProcessMaker\BusinessModel\Cases::addCase + * @expectedException Exception + * @expectedExceptionMessage Task invalid or the user is not assigned to the task + * + * @copyright Colosa - Bolivia + */ + public function testAddCaseErrorIncorrectTaskValueArray() + { + $this->oCases->addCase(self::$proUid, '12345678912345678912345678912345678', self::$usrUid, array()); + } + /** * Test add Case * @@ -98,6 +126,20 @@ class CasesTest extends \PHPUnit_Framework_TestCase return $aResponse; } + /** + * Test error for incorrect value of case in array + * + * @covers \ProcessMaker\BusinessModel\Cases::getTaskCase + * @expectedException Exception + * @expectedExceptionMessage Incorrect or unavailable information about this case: 12345678912345678912345678912345678 + * + * @copyright Colosa - Bolivia + */ + public function testGetTaskCaseErrorIncorrectCaseValueArray() + { + $this->oCases->getTaskCase('12345678912345678912345678912345678', self::$usrUid); + } + /** * Test get Task Case * @@ -113,6 +155,20 @@ class CasesTest extends \PHPUnit_Framework_TestCase $this->assertTrue(is_array($response)); } + /** + * Test error for incorrect value of case in array + * + * @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo + * @expectedException Exception + * @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testGetCaseInfoErrorIncorrectCaseValueArray() + { + $this->oCases->getCaseInfo('12345678912345678912345678912345678', self::$usrUid); + } + /** * Test get Case Info * @@ -128,10 +184,40 @@ class CasesTest extends \PHPUnit_Framework_TestCase $this->assertTrue(is_object($response)); } + /** + * Test error for incorrect value of user delegation in array + * + * @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase + * @depends testAddCase + * @param array $aResponse + * @expectedException Exception + * @expectedExceptionMessage Invalid Case Delegation index for this user + * + * @copyright Colosa - Bolivia + */ + public function testUpdateReassignCaseErrorIncorrectUserValueArray(array $aResponse) + { + $this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid, self::$usrUid2); + } + + /** + * Test error for incorrect value of case in array + * + * @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase + * @expectedException Exception + * @expectedExceptionMessage The Application with app_uid: 12345678912345678912345678912345678 doesn't exist + * + * @copyright Colosa - Bolivia + */ + public function testUpdateReassignCaseErrorIncorrectCaseValueArray() + { + $this->oCases->updateReassignCase('12345678912345678912345678912345678', self::$usrUid, null, self::$usrUid2, self::$usrUid); + } + /** * Test put reassign case * - * @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo + * @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase * @depends testAddCase * @param array $aResponse * @@ -158,6 +244,20 @@ class CasesTest extends \PHPUnit_Framework_TestCase return $aResponseRouteCase; } + /** + * Test error for incorrect value of case in array + * + * @covers \ProcessMaker\BusinessModel\Cases::updateRouteCase + * @expectedException Exception + * @expectedExceptionMessage The row '12345678912345678912345678912345678, ' in table AppDelegation doesn't exist! + * + * @copyright Colosa - Bolivia + */ + public function testUpdateRouteCaseErrorIncorrectCaseValueArray() + { + $this->oCases->updateRouteCase('12345678912345678912345678912345678', self::$usrUid, null); + } + /** * Test put route case * @@ -173,6 +273,35 @@ class CasesTest extends \PHPUnit_Framework_TestCase $this->assertTrue(empty($response)); } + /** + * Test error for incorrect value of process in array + * + * @covers \ProcessMaker\BusinessModel\Cases::addCase + * @expectedException Exception + * @expectedExceptionMessage Invalid process 12345678912345678912345678912345678 + * + * @copyright Colosa - Bolivia + */ + public function testAddCaseImpersonateErrorIncorrectProcessValueArray() + { + $this->oCases->addCaseImpersonate('12345678912345678912345678912345678', self::$usrUid2, self::$tasUid, array()); + } + + /** + * Test error for incorrect value of task in array + * + * @covers \ProcessMaker\BusinessModel\Cases::addCase + * @expectedException Exception + * @expectedExceptionMessage User not registered! 12345678912345678912345678912345678!! + * + * @copyright Colosa - Bolivia + */ + public function testAddCaseImpersonateErrorIncorrectTaskValueArray() + { + $this->oCases->addCaseImpersonate(self::$proUid, '12345678912345678912345678912345678', self::$tasUid, array()); + } + + /** * Test add Case impersonate *