Merge branch 'master' of bitbucket.org:colosa/processmaker

This commit is contained in:
Freddy Daniel Rojas Valda
2014-03-18 14:32:27 -04:00
5 changed files with 513 additions and 197 deletions

View File

@@ -34,7 +34,6 @@ Feature: Output Documents Negative Tests
| test_description | sch_del_user_name | tas_uid | sch_name | sch_option | sch_start_date | sch_end_date | sch_start_time | sch_week_days | sch_start_day | sch_start_day_opt_1 | sch_months | sch_start_day_opt_2 | sch_repeat_every | error_code | error_message |
| Invalid sch_option | admin | 46941969352af5be2ab3f39001216717 | Case Scheduler-Daily 123@#$ 21 | 20 | 2014-01-30 | 2014-02-20 | 12:00 | | | | | | | 400 | sch_option |
| Invalid sch_del_user_name | sample | 46941969352af5be2ab3f39001216717 | Case Scheduler-Weekly monday 345%$# | 2 | 2014-02-20 | 2014-03-20 | 08:00 | 1 | | | | | | 400 | User |
| Invalid sch_del_user_pass | admin | 46941969352af5be2ab3f39001216717 | Case Scheduler-Weekly 345%$# 22 | 2 | 2014-02-20 | 2014-03-20 | 08:00 | 2\|3\|5\|6\|7 | | | | | | 400 | password |
| Invalid tas_uid | admin | 00000000000005be2ab3f39001216717 | Case Scheduler-Monthly 567&^% 1 | 3 | 2014-03-21 | 2014-04-18 | 18:00 | | 1 | 15 | 3\|4 | | | 400 | Task not found |
| Invalid sch_start_time | admin | 46941969352af5be2ab3f39001216717 | Case Scheduler-Monthly 567&^% 2 | 3 | 2014-03-21 | 2014-04-18 | 39:00:99 | | 1 | 15 | 1\|2\|5\|6\|7\|8\|9\|10\|11\|12 | | | 400 | sch_start_time |
| Invalid sch_start_date | admin | 46941969352af5be2ab3f39001216717 | Case Scheduler-Monthly 567&^% 3 | 3 | 2014-20-35 | 2014-04-18 | 18:00 | | 2 | | 3\|4\|5 | 1\|7 | | 400 | sch_start_date |

File diff suppressed because it is too large Load Diff

View File

@@ -462,192 +462,5 @@ class InputDocument
throw $e;
}
}
/**
* Get data of Cases InputDocument
*
* @param string $caseUid
* @param string $userUid
*
* return array Return an array with data of an InputDocument
*/
public function getCasesInputDocument($caseUid, $userUid)
{
try {
///
global $G_PUBLISH;
$defaultEndpoint = 'http://' . $_SERVER['SERVER_NAME'] . ':' . $_SERVER['SERVER_PORT'] . '/sys' . SYS_SYS . '/' . SYS_LANG . '/classic/services/wsdl2';
$endpoint = isset( $_SESSION['END_POINT'] ) ? $_SESSION['END_POINT'] : $defaultEndpoint;
$sessionId = isset( $_SESSION['SESSION_ID'] ) ? $_SESSION['SESSION_ID'] : '';
//Apply proxy settings
$proxy = array ();
$sysConf = \System::getSystemConfiguration();
if ($sysConf['proxy_host'] != '') {
$proxy['proxy_host'] = $sysConf['proxy_host'];
if ($sysConf['proxy_port'] != '') {
$proxy['proxy_port'] = $sysConf['proxy_port'];
}
if ($sysConf['proxy_user'] != '') {
$proxy['proxy_login'] = $sysConf['proxy_user'];
}
if ($sysConf['proxy_pass'] != '') {
$proxy['proxy_password'] = $sysConf['proxy_pass'];
}
}
@$client = new \SoapClient( $endpoint, $proxy );
///
$caseId = $caseUid;
$sessionId = $userUid;
$params = array ('sessionId' => $sessionId,'caseId' => $caseId);
$wsResponse = $client->__SoapCall( 'InputDocumentList', array ($params));
//g::pr($wsResponse);
$result = \G::PMWSCompositeResponse( $wsResponse, 'documents' );
$G_PUBLISH = new \Publisher();
$rows[] = array ('guid' => 'char','name' => 'char','processId' => 'char');
if (is_array( $result )) {
foreach ($result as $key => $item) {
if (isset( $item->item )) {
foreach ($item->item as $index => $val) {
if ($val->key == 'guid') {
$guid = $val->value;
}
if ($val->key == 'filename') {
$filename = $val->value;
}
if ($val->key == 'docId') {
$docId = $val->value;
}
if ($val->key == 'version') {
$version = $val->value;
}
if ($val->key == 'createDate') {
$createDate = $val->value;
}
if ($val->key == 'createBy') {
$createBy = $val->value;
}
if ($val->key == 'type') {
$type = $val->value;
}
if ($val->key == 'link') {
$link = $val->value;
}
}
} elseif (is_array( $item )) {
foreach ($item as $index => $val) {
if ($val->key == 'guid') {
$guid = $val->value;
}
if ($val->key == 'filename') {
$filename = $val->value;
}
if ($val->key == 'docId') {
$docId = $val->value;
}
if ($val->key == 'version') {
$version = $val->value;
}
if ($val->key == 'createDate') {
$createDate = $val->value;
}
if ($val->key == 'createBy') {
$createBy = $val->value;
}
if ($val->key == 'type') {
$type = $val->value;
}
if ($val->key == 'link') {
$link = $val->value;
}
}
} else {
if (isset( $item->guid )) {
$guid = $item->guid;
}
if (isset( $item->filename )) {
$filename = $item->filename;
}
if (isset( $item->docId )) {
$docId = $item->docId;
}
if (isset( $item->version )) {
$version = $item->version;
}
if (isset( $item->createDate )) {
$createDate = $item->createDate;
}
if (isset( $item->createBy )) {
$createBy = $item->createBy;
}
if (isset( $item->type )) {
$type = $item->type;
}
if (isset( $item->link )) {
$link = $item->link;
}
}
$rows[] = array ('guid' => $guid,'filename' => $filename,'docId' => $docId,'version' => $version,'createDate' => $createDate,'createBy' => $createBy,'type' => $type,'link' => $link);
}
}
return $rows;
/* testing//
global $_DBArray;
$_DBArray = (isset( $_SESSION['_DBArray'] ) ? $_SESSION['_DBArray'] : '');
$_DBArray['inputDocument'] = $rows;
$documentArray = array ();
$documentArray[] = array ('guid' => 'char','filename' => 'char'
);
if (isset( $_DBArray['inputDocument'] )) {
foreach ($_DBArray['inputDocument'] as $key => $val) {
if ($key != 0 && isset( $val['filename'] )) {
$documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename']
);
}
}
}
if (isset( $_DBArray['outputDocument'] )) {
foreach ($_DBArray['outputDocument'] as $key => $val) {
if ($key != 0 && isset( $val['filename'] )) {
$documentArray[] = array ('guid' => $val['guid'],'filename' => $val['filename']
);
}
}
}
$_DBArray['documents'] = $documentArray;
$_DBArray['WS_TMP_CASE_UID'] = $frm["CASE_ID"];
$_SESSION['_DBArray'] = $_DBArray;
G::LoadClass( 'ArrayPeer' );
$c = new Criteria( 'dbarray' );
$c->setDBArrayTable( 'inputDocument' );
$c->addAscendingOrderByColumn( 'name' );
$G_PUBLISH->AddContent( 'propeltable', 'paged-table', 'setup/wsrInputDocumentList', $c );
} elseif (is_object( $result )) {
$_SESSION['WS_SESSION_ID'] = '';
$fields['status_code'] = $result->status_code;
$fields['message'] = $result->message;
$fields['time_stamp'] = date( "Y-m-d H:i:s" );
$G_PUBLISH->AddContent( 'xmlform', 'xmlform', 'setup/wsShowResult', null, $fields );
}
G::RenderPage( 'publish', 'raw' );
break;*/
} catch (\Exception $e) {
throw $e;
}
}
}

View File

@@ -175,8 +175,8 @@ class Cases extends Api
try {
$userUid = $this->getUserId();
$cases = new \BusinessModel\Cases();
$arrayData = $cases->getCaseInfo($cas_uid, $userUid);
return $arrayData;
$oData = $cases->getCaseInfo($cas_uid, $userUid);
return $oData;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}
@@ -191,8 +191,8 @@ class Cases extends Api
{
try {
$cases = new \BusinessModel\Cases();
$arrayData = $cases->getTaskCase($cas_uid);
return $arrayData;
$oData = $cases->getTaskCase($cas_uid);
return $oData;
} catch (\Exception $e) {
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
}

View File

@@ -0,0 +1,175 @@
<?php
namespace Tests\BusinessModel;
if (!class_exists("Propel")) {
include_once (__DIR__ . "/../bootstrap.php");
}
/**
* Class Cases Test
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @protected
* @package Tests\BusinessModel
*/
class CasesTest extends \PHPUnit_Framework_TestCase
{
protected $oCases;
/**
* Set class for test
*
* @coversNothing
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function setUp()
{
$this->oCases = new \BusinessModel\Cases();
return true;
}
/**
* Test error for type in first field the function
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage Invalid value for '$dataList' it must be an array.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesErrorArray()
{
$this->oCases->getList(true);
}
/**
* Test error for empty userId in array
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The user with userId: '' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesErrorUserIdArray()
{
$this->oCases->getList(array());
}
/**
* Test error for not exists userId in array
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The user with userId: 'UidInexistente' does not exist.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesErrorNotExistsUserIdArray()
{
$this->oCases->getList(array('userId' => 'UidInexistente'));
}
/**
* Test error for incorrect value $action in array
*
* @covers \BusinessModel\Cases::getList
* @expectedException Exception
* @expectedExceptionMessage The value for $action is incorrect.
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesErrorIncorrectValueArray()
{
$this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'incorrect'));
}
/**
* Test get list to do
*
* @covers \BusinessModel\Cases::getList
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesToDo()
{
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
$this->assertTrue(is_array($response));
$this->assertTrue(is_numeric($response['totalCount']));
$this->assertTrue(is_array($response['data']));
}
/**
* Test get list draft
*
* @covers \BusinessModel\Cases::getList
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesDraft()
{
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
$this->assertTrue(is_array($response));
$this->assertTrue(is_numeric($response['totalCount']));
$this->assertTrue(is_array($response['data']));
}
/**
* Test get list participated
*
* @covers \BusinessModel\Cases::getList
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesParticipated()
{
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'sent'));
$this->assertTrue(is_array($response));
$this->assertTrue(is_numeric($response['totalCount']));
$this->assertTrue(is_array($response['data']));
}
/**
* Test get list unassigned
*
* @covers \BusinessModel\Cases::getList
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesUnassigned()
{
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'unassigned'));
$this->assertTrue(is_array($response));
$this->assertTrue(is_numeric($response['totalCount']));
$this->assertTrue(is_array($response['data']));
}
/**
* Test get list search
*
* @covers \BusinessModel\Cases::getList
*
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*/
public function testGetListCasesSearch()
{
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'search'));
$this->assertTrue(is_array($response));
$this->assertTrue(is_numeric($response['totalCount']));
$this->assertTrue(is_array($response['data']));
}
}