Merged in darojas/processmaker (pull request #372)

Se modifica test unit para CASES. Se agrega test unit para OUTPUT DOCUMENT. Se agrega una linea en la respuesta de upload.
This commit is contained in:
erik ao
2014-04-07 09:14:10 -04:00
4 changed files with 289 additions and 112 deletions

View File

@@ -214,6 +214,7 @@ class InputDocument
$arrayData["DEL_INDEX"] = $delIndex;
$arrayData["TAS_UID"] = $taskUid;
$case->updateCase($applicationUid, $arrayData);
return($this->getCasesInputDocument($applicationUid, $userUid, $appDocUid));
} catch (\Exception $e) {
throw $e;
}

View File

@@ -419,108 +419,5 @@ class CasesTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(isset($response['date_from']));
$this->assertTrue(isset($response['date_to']));
}
/**
* Test add Case
*
* @covers \ProcessMaker\BusinessModel\Cases::addCase
*
* @copyright Colosa - Bolivia
*/
public function testAddCase()
{
$response = $this->oCases->addCase('1265557095225ff5c688f46031700471', '46941969352af5be2ab3f39001216717', '00000000000000000000000000000001', array('name' => 'John', 'lastname' => 'Petersson'));
$this->assertTrue(is_object($response));
$aResponse = json_decode(json_encode($response), true);
return $aResponse;
}
/**
* Test get Task Case
*
* @covers \ProcessMaker\BusinessModel\Cases::getTaskCase
* @depends testAddCase
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testGetTaskCase(array $aResponse)
{
$response = $this->oCases->getTaskCase($aResponse['app_uid'], '00000000000000000000000000000001');
$this->assertTrue(is_array($response));
}
/**
* Test get Case Info
*
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
* @depends testAddCase
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testGetCaseInfo(array $aResponse)
{
$response = $this->oCases->getCaseInfo($aResponse['app_uid'], '00000000000000000000000000000001');
$this->assertTrue(is_object($response));
}
/**
* Test put reassign case
*
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
* @depends testAddCase
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testUpdateReassignCase(array $aResponse)
{
$response = $this->oCases->updateReassignCase($aResponse['app_uid'], '00000000000000000000000000000001', null, '00000000000000000000000000000001', '73005191052d56727901138030694610');
$this->assertTrue(empty($response));
}
/**
* Test add Case to test route case
*
* @covers \ProcessMaker\BusinessModel\Cases::addCase
*
* @copyright Colosa - Bolivia
*/
public function testAddCaseRouteCase()
{
$response = $this->oCases->addCase('1265557095225ff5c688f46031700471', '46941969352af5be2ab3f39001216717', '00000000000000000000000000000001', array('name' => 'John', 'lastname' => 'Petersson'));
$this->assertTrue(is_object($response));
$aResponseRouteCase = json_decode(json_encode($response), true);
return $aResponseRouteCase;
}
/**
* Test put route case
*
* @covers \ProcessMaker\BusinessModel\Cases::updateRouteCase
* @depends testAddCaseRouteCase
* @param array $aResponseRouteCase
*
* @copyright Colosa - Bolivia
*/
public function testUpdateRouteCase(array $aResponseRouteCase)
{
$response = $this->oCases->updateRouteCase($aResponseRouteCase['app_uid'], '00000000000000000000000000000001', null);
$this->assertTrue(empty($response));
}
/**
* Test add Case impersonate
*
* @covers \ProcessMaker\BusinessModel\Cases::addCaseImpersonate
*
* @copyright Colosa - Bolivia
*/
public function testAddCaseImpersonate()
{
$response = $this->oCases->addCaseImpersonate('1265557095225ff5c688f46031700471', '73005191052d56727901138030694610', '46941969352af5be2ab3f39001216717', array(array('name' => 'John', 'lastname' => 'Petersson')));
$this->assertTrue(is_object($response));
}
}

View File

@@ -0,0 +1,227 @@
<?php
namespace Tests\BusinessModel;
if (!class_exists("Propel")) {
include_once (__DIR__ . "/../bootstrap.php");
}
/**
* Class Cases Test
*
* @copyright Colosa - Bolivia
*
* @protected
* @package Tests\BusinessModel
*/
class CasesTest extends \PHPUnit_Framework_TestCase
{
protected $oCases;
protected $idCase = '';
protected static $usrUid = "00000000000000000000000000000001";
protected static $usrUid2 = "00000000000000000000000000000012";
protected static $proUid = "00000000000000000000000000000003";
protected static $tasUid = "00000000000000000000000000000004";
protected static $tasUid2 = "00000000000000000000000000000005";
protected static $tasUid3 = "00000000000000000000000000000006";
public static function setUpBeforeClass()
{
$process = new \Process();
$process->create(array("type"=>"classicProject", "PRO_TITLE"=> "NEW TEST PHP UNIT", "PRO_DESCRIPTION"=> "465",
"PRO_CATEGORY"=> "", "PRO_CREATE_USER"=> "00000000000000000000000000000001",
"PRO_UID"=> self::$proUid, "USR_UID"=> "00000000000000000000000000000001"), false);
$task = new \Task();
$task->create(array("TAS_START"=>"TRUE", "TAS_UID"=> self::$tasUid, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TEST PHP UNIT",
"TAS_POSX"=> 581, "TAS_POSY"=> 47, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
$task = new \Task();
$task->create(array( "TAS_UID"=> self::$tasUid2, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK ONE",
"TAS_POSX"=> 481, "TAS_POSY"=> 127, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
$task = new \Task();
$task->create(array( "TAS_UID"=> self::$tasUid3, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TWO",
"TAS_POSX"=> 681, "TAS_POSY"=> 127, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
$nw = new \processMap();
$nw->saveNewPattern(self::$proUid, self::$tasUid, self::$tasUid2, 'PARALLEL', true);
$nw = new \processMap();
$nw->saveNewPattern(self::$proUid, self::$tasUid, self::$tasUid3, 'PARALLEL', true);
$user = new \Users();
$user->create(array("USR_ROLE"=> "PROCESSMAKER_ADMIN","USR_UID"=> self::$usrUid2, "USR_USERNAME"=> "dummy",
"USR_PASSWORD"=>"21232f297a57a5a743894a0e4a801fc3", "USR_FIRSTNAME"=>"dummy_firstname", "USR_LASTNAME"=>"dummy_lastname",
"USR_EMAIL"=>"dummy@dummy.com", "USR_DUE_DATE"=>'2020-01-01', "USR_CREATE_DATE"=>"2014-01-01 12:00:00", "USR_UPDATE_DATE"=>"2014-01-01 12:00:00",
"USR_STATUS"=>"ACTIVE", "USR_UX"=>"NORMAL"));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid2, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid2, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid2, "USR_UID"=> self::$usrUid2, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid3, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid3, "USR_UID"=> self::$usrUid2, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
}
/**
* Set class for test
*
* @coversNothing
*
* @copyright Colosa - Bolivia
*/
public function setUp()
{
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
return true;
}
/**
* Test add Case
*
* @covers \ProcessMaker\BusinessModel\Cases::addCase
*
* @copyright Colosa - Bolivia
*/
public function testAddCase()
{
$response = $this->oCases->addCase(self::$proUid, self::$tasUid, self::$usrUid, array());
$this->assertTrue(is_object($response));
$aResponse = json_decode(json_encode($response), true);
return $aResponse;
}
/**
* Test get Task Case
*
* @covers \ProcessMaker\BusinessModel\Cases::getTaskCase
* @depends testAddCase
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testGetTaskCase(array $aResponse)
{
$response = $this->oCases->getTaskCase($aResponse['app_uid'], self::$usrUid);
$this->assertTrue(is_array($response));
}
/**
* Test get Case Info
*
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
* @depends testAddCase
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testGetCaseInfo(array $aResponse)
{
$response = $this->oCases->getCaseInfo($aResponse['app_uid'], self::$usrUid);
$this->assertTrue(is_object($response));
}
/**
* Test put reassign case
*
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
* @depends testAddCase
* @param array $aResponse
*
* @copyright Colosa - Bolivia
*/
public function testUpdateReassignCase(array $aResponse)
{
$response = $this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid, self::$usrUid2);
$this->assertTrue(empty($response));
}
/**
* Test add Case to test route case
*
* @covers \ProcessMaker\BusinessModel\Cases::addCase
*
* @copyright Colosa - Bolivia
*/
public function testAddCaseRouteCase()
{
$response = $this->oCases->addCase(self::$proUid, self::$tasUid, self::$usrUid, array());
$this->assertTrue(is_object($response));
$aResponseRouteCase = json_decode(json_encode($response), true);
return $aResponseRouteCase;
}
/**
* Test put route case
*
* @covers \ProcessMaker\BusinessModel\Cases::updateRouteCase
* @depends testAddCaseRouteCase
* @param array $aResponseRouteCase
*
* @copyright Colosa - Bolivia
*/
public function testUpdateRouteCase(array $aResponseRouteCase)
{
$response = $this->oCases->updateRouteCase($aResponseRouteCase['app_uid'], self::$usrUid, null);
$this->assertTrue(empty($response));
}
/**
* Test add Case impersonate
*
* @covers \ProcessMaker\BusinessModel\Cases::addCaseImpersonate
*
* @copyright Colosa - Bolivia
*/
public function testAddCaseImpersonate()
{
$response = $this->oCases->addCaseImpersonate(self::$proUid, self::$usrUid2, self::$tasUid, array());
$this->assertTrue(is_object($response));
}
public static function tearDownAfterClass()
{
$assign = new \TaskUser();
$assign->remove(self::$tasUid, self::$usrUid, 1,1);
$task = new \Task();
$task->remove(self::$tasUid);
$task = new \Task();
$task->remove(self::$tasUid2);
$task = new \Task();
$task->remove(self::$tasUid3);
$process = new \Process();
$process->remove(self::$proUid);
$criteria = new \Criteria("workflow");
$criteria->addSelectColumn(\RoutePeer::PRO_UID);
$criteria->add(\RoutePeer::PRO_UID, self::$proUid, \Criteria::EQUAL);
\ProcessFilesPeer::doDelete($criteria);
$user = new \Users();
$user->remove(self::$usrUid2);
$oConnection = \Propel::getConnection( \UsersPeer::DATABASE_NAME );
try {
$oUser = \UsersPeer::retrieveByPK( self::$usrUid2 );
if (! is_null( $oUser )) {
$oConnection->begin();
$oUser->delete();
$oConnection->commit();
}
} catch (Exception $oError) {
$oConnection->rollback();
throw ($oError);
}
}
}

View File

@@ -18,6 +18,59 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
protected $oOutputDocument;
protected $idCase = '';
protected static $usrUid = "00000000000000000000000000000001";
protected static $proUid = "00000000000000000000000000000002";
protected static $tasUid = "00000000000000000000000000000003";
protected static $outUid = "00000000000000000000000000000004";
protected static $steUid = "00000000000000000000000000000005";
public static function setUpBeforeClass()
{
$process = new \Process();
$process->create(array("type"=>"classicProject", "PRO_TITLE"=> "NEW TEST PHP UNIT", "PRO_DESCRIPTION"=> "465",
"PRO_CATEGORY"=> "", "PRO_CREATE_USER"=> "00000000000000000000000000000001",
"PRO_UID"=> self::$proUid, "USR_UID"=> "00000000000000000000000000000001"), false);
$task = new \Task();
$task->create(array("TAS_START"=>"TRUE", "TAS_UID"=> self::$tasUid, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TEST PHP UNIT",
"TAS_POSX"=> 581, "TAS_POSY"=> 17, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
$outputDocument = new \OutputDocument();
$outputDocument->create(array("OUT_DOC_UID"=> self::$outUid, "PRO_UID"=> self::$proUid, "OUT_DOC_TITLE"=> "NEW OUPUT TEST", "OUT_DOC_FILENAME"=> "NEW_OUPUT_TEST",
"OUT_DOC_DESCRIPTION"=> "", "OUT_DOC_REPORT_GENERATOR"=> "HTML2PDF", "OUT_DOC_REPORT_GENERATOR_label"=> "HTML2PDF (Old Version)",
"OUT_DOC_LANDSCAPE"=> "", "OUT_DOC_LANDSCAPE_label"=> "Portrait", "OUT_DOC_GENERATE"=> "BOTH", "OUT_DOC_GENERATE_label"=> "BOTH",
"OUT_DOC_VERSIONING"=> "", "OUT_DOC_VERSIONING_label"=> "NO", "OUT_DOC_MEDIA"=> "Letter", "OUT_DOC_MEDIA_label"=> "Letter",
"OUT_DOC_LEFT_MARGIN"=> "", "OUT_DOC_RIGHT_MARGIN"=> "", "OUT_DOC_TOP_MARGIN"=> "", "OUT_DOC_BOTTOM_MARGIN"=> "",
"OUT_DOC_DESTINATION_PATH"=> "", "OUT_DOC_TAGS"=> "", "OUT_DOC_PDF_SECURITY_ENABLED"=> "0", "OUT_DOC_PDF_SECURITY_ENABLED_label"=> "Disabled",
"OUT_DOC_PDF_SECURITY_OPEN_PASSWORD"=>"", "OUT_DOC_PDF_SECURITY_OWNER_PASSWORD"=> "", "OUT_DOC_PDF_SECURITY_PERMISSIONS"=> "",
"OUT_DOC_OPEN_TYPE"=> "0", "OUT_DOC_OPEN_TYPE_label"=> "Download the file", "BTN_CANCEL"=> "Cancel", "ACCEPT"=> "Save"));
$step = new \Step();
$step->create(array( "PRO_UID"=> self::$proUid, "TAS_UID"=> self::$tasUid, "STEP_UID"=> self::$steUid, "STEP_TYPE_OBJ" => "OUTPUT_DOCUMENT", "STEP_UID_OBJ" =>self::$outUid));
$assign = new \TaskUser();
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
}
public static function tearDownAfterClass()
{
$assign = new \TaskUser();
$assign->remove(self::$tasUid, self::$usrUid, 1,1);
$step = new \Step();
$step->remove(self::$steUid);
$outputDocument = new \OutputDocument();
$outputDocument->remove(self::$outUid);
$task = new \Task();
$task->remove(self::$tasUid);
$process = new \Process();
$process->remove(self::$proUid);
}
/**
* Set class for test
*
@@ -40,13 +93,8 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
public function testAddCasesOutputDocument()
{
\G::loadClass('pmFunctions');
\G::loadClass('pmFunctions');
$usrUid = '00000000000000000000000000000001';//an user id valid
$proUid = '1265557095225ff5c688f46031700471';//a process id valid
$tasUid = '46941969352af5be2ab3f39001216717';//a task id valid and related to the previous proUid
$outDocUid = '64016692453346d546d0ad1037377043';//a output document id valid and related to the previous task id
$idCase = PMFNewCase($proUid, $usrUid, $tasUid, array());
$response = $this->oOutputDocument->addCasesOutputDocument($idCase, $outDocUid, '00000000000000000000000000000001');
$idCase = PMFNewCase(self::$proUid, self::$usrUid, self::$tasUid, array());
$response = $this->oOutputDocument->addCasesOutputDocument($idCase, self::$outUid, self::$usrUid);
$this->assertTrue(is_object($response));
$aResponse = json_decode(json_encode($response), true);
$aResponse = array_merge(array("idCase" => $idCase), $aResponse);
@@ -64,7 +112,7 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
*/
public function testGetCasesOutputDocuments(array $aResponse)
{
$response = $this->oOutputDocument->getCasesOutputDocuments($aResponse["idCase"], '00000000000000000000000000000001');
$response = $this->oOutputDocument->getCasesOutputDocuments($aResponse["idCase"], self::$usrUid);
$this->assertTrue(is_array($response));
}
@@ -79,7 +127,7 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
*/
public function testGetCasesOutputDocument(array $aResponse)
{
$response = $this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], '00000000000000000000000000000001', $aResponse["app_doc_uid"]);
$response = $this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], self::$usrUid, $aResponse["app_doc_uid"]);
$this->assertTrue(is_object($response));
}
@@ -96,5 +144,9 @@ class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
{
$response = $this->oOutputDocument->removeOutputDocument($aResponse["app_doc_uid"]);
$this->assertTrue(empty($response));
//remove Case
$case = new \Cases();
$case->removeCase( $aResponse["idCase"] );
}
}