Se agrega test unit para PROCESS CATEGORY. Se modifican respuestas de PROCESS CATEGORY.

This commit is contained in:
Daniel Rojas
2014-04-02 16:35:31 -04:00
parent 59769103fb
commit 7bc831c4e9
2 changed files with 83 additions and 4 deletions

View File

@@ -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;

View File

@@ -13,6 +13,20 @@ if (!class_exists("Propel")) {
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 \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 \BusinessModel\ProcessCategory();