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:
Daniel Rojas
2014-04-07 16:25:36 -04:00
parent a5662a9ff1
commit 9f5a9910ba
5 changed files with 139 additions and 5 deletions

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