Merged in darojas/processmaker (pull request #364)
Se agrega test unit para PROCESS CATEGORY
This commit is contained in:
@@ -261,7 +261,9 @@ class ProcessCategory
|
||||
}
|
||||
//Return
|
||||
if ($oProcessCategory != '') {
|
||||
return $oProcessCategory;
|
||||
$oProcessCategory = array_change_key_case($oProcessCategory, CASE_LOWER);
|
||||
$oResponse = json_decode(json_encode($oProcessCategory), false);
|
||||
return $oResponse;
|
||||
} else {
|
||||
throw (new \Exception( 'The Category with cat_uid: '.$cat_uid.' doesn\'t exist!'));
|
||||
}
|
||||
@@ -291,7 +293,7 @@ class ProcessCategory
|
||||
$pcat->setCategoryUid( $catUid );
|
||||
$pcat->setCategoryName( $catName );
|
||||
$pcat->save();
|
||||
$oProcessCategory = array_change_key_case($this->getCategory( $catUid ), CASE_LOWER);
|
||||
$oProcessCategory = $this->getCategory( $catUid );
|
||||
//Return
|
||||
return $oProcessCategory;
|
||||
} catch (\Exception $e) {
|
||||
@@ -321,9 +323,10 @@ class ProcessCategory
|
||||
$pcat->setCategoryUid( $catUID );
|
||||
$pcat->setCategoryName( $catName );
|
||||
$pcat->save();
|
||||
$oProcessCategory = array_change_key_case($this->getCategory( $cat_uid ), CASE_LOWER);
|
||||
$oProcessCategory = $this->getCategory( $cat_uid );
|
||||
//Return
|
||||
return $oProcessCategory;
|
||||
$oResponse = json_decode(json_encode($oProcessCategory), false);
|
||||
return $oResponse;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
throw $e;
|
||||
|
||||
@@ -8,11 +8,25 @@ if (!class_exists("Propel")) {
|
||||
/**
|
||||
* Class ProcessCategoryTest
|
||||
*
|
||||
* @package Tests\BusinessModel
|
||||
* @package Tests/ProcessMaker/BusinessModel
|
||||
*/
|
||||
class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $arrayUid = array();
|
||||
protected $oCategory;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
}
|
||||
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
@@ -26,6 +40,67 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add Category
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::addCategory
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCategory()
|
||||
{
|
||||
$response = $this->oCategory->addCategory('New Category Test');
|
||||
$this->assertTrue(is_object($response));
|
||||
$aResponse = json_decode(json_encode($response), true);
|
||||
return $aResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test put Category
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::updateCategory
|
||||
* @depends testAddCategory
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateCategory(array $aResponse)
|
||||
{
|
||||
$response = $this->oCategory->updateCategory($aResponse["cat_uid"], 'Name Update Category Test');
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get Category
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::getCategory
|
||||
* @depends testAddCategory
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCategory(array $aResponse)
|
||||
{
|
||||
$response = $this->oCategory->getCategory($aResponse["cat_uid"]);
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test delete Category
|
||||
*
|
||||
* @covers \BusinessModel\ProcessCategory::deleteCategory
|
||||
* @depends testAddCategory
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteCategory(array $aResponse)
|
||||
{
|
||||
$response = $this->oCategory->deleteCategory($aResponse["cat_uid"]);
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
try {
|
||||
@@ -46,6 +121,7 @@ class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertNotEmpty($processCategoryUid);
|
||||
}
|
||||
|
||||
|
||||
public function testGetCategories()
|
||||
{
|
||||
$processCategory = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
|
||||
Reference in New Issue
Block a user