CODE STYLE
files modified: class.form.php
class.functionTest.php
class.rbac.php
class.restClient.php
class.ymlTestCases.php
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.database_base.php
|
||||
*
|
||||
* @package gulliver.system
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -25,60 +27,64 @@
|
||||
*/
|
||||
/**
|
||||
* Class Form
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @package gulliver.system
|
||||
* @access public
|
||||
*/
|
||||
class Form extends XmlForm
|
||||
{
|
||||
var $id='';
|
||||
var $width = 600;
|
||||
var $title = '';
|
||||
var $fields = array();
|
||||
var $values = array();
|
||||
var $action = '';
|
||||
var $ajaxServer = '';
|
||||
var $enableTemplate = false;
|
||||
var $ajaxSubmit = false;
|
||||
var $callback='function(){}';
|
||||
var $in_progress='function(){}';
|
||||
var $template;
|
||||
var $className="formDefault";
|
||||
var $objectRequiredFields = null;
|
||||
var $nextstepsave = '';
|
||||
var $printdynaform = '';
|
||||
var $adjustgridswidth = '0';
|
||||
public $id = '';
|
||||
public $width = 600;
|
||||
public $title = '';
|
||||
public $fields = array ();
|
||||
public $values = array ();
|
||||
public $action = '';
|
||||
public $ajaxServer = '';
|
||||
public $enableTemplate = false;
|
||||
public $ajaxSubmit = false;
|
||||
public $callback = 'function(){}';
|
||||
public $in_progress = 'function(){}';
|
||||
public $template;
|
||||
public $className = "formDefault";
|
||||
public $objectRequiredFields = null;
|
||||
public $nextstepsave = '';
|
||||
public $printdynaform = '';
|
||||
public $adjustgridswidth = '0';
|
||||
|
||||
public $visual_frontend;
|
||||
|
||||
/**
|
||||
* Function setDefaultValues
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function setDefaultValues( )
|
||||
public function setDefaultValues ()
|
||||
{
|
||||
foreach($this->fields as $name => $content) {
|
||||
if (is_object($content) && get_class($content) != '__PHP_Incomplete_Class') {
|
||||
if (isset($content->defaultValue))
|
||||
foreach ($this->fields as $name => $content) {
|
||||
if (is_object( $content ) && get_class( $content ) != '__PHP_Incomplete_Class') {
|
||||
if (isset( $content->defaultValue )) {
|
||||
$this->values[$name] = $content->defaultValue;
|
||||
else
|
||||
} else {
|
||||
$this->values[$name] = '';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$this->values[$name] = '';
|
||||
}
|
||||
}
|
||||
foreach($this->fields as $k => $v){
|
||||
if (is_object($v)) {//julichu
|
||||
$this->fields[$k]->owner =& $this;
|
||||
foreach ($this->fields as $k => $v) {
|
||||
if (is_object( $v )) {
|
||||
//julichu
|
||||
$this->fields[$k]->owner = & $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function Form
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string filename
|
||||
@@ -88,62 +94,70 @@ class Form extends XmlForm
|
||||
* @param string $visual_frontend
|
||||
* @return string
|
||||
*/
|
||||
function Form($filename, $home='', $language = '', $forceParse = false, $visual_frontend=null)
|
||||
public function Form ($filename, $home = '', $language = '', $forceParse = false, $visual_frontend = null)
|
||||
{
|
||||
$this->visual_frontend = $visual_frontend;
|
||||
if ($language=== '')
|
||||
$language = defined('SYS_LANG')? SYS_LANG : 'en';
|
||||
if ($home=== '')
|
||||
$home = defined('PATH_XMLFORM')? PATH_XMLFORM :
|
||||
(defined('PATH_DYNAFORM')? PATH_DYNAFORM: '');
|
||||
if ($language === '') {
|
||||
$language = defined( 'SYS_LANG' ) ? SYS_LANG : 'en';
|
||||
}
|
||||
if ($home === '') {
|
||||
$home = defined( 'PATH_XMLFORM' ) ? PATH_XMLFORM : (defined( 'PATH_DYNAFORM' ) ? PATH_DYNAFORM : '');
|
||||
}
|
||||
//to do: obtain the error code in case the xml parsing has errors: DONE
|
||||
//Load and parse the xml file
|
||||
if ( substr($filename, -4) !== '.xml' )
|
||||
if (substr( $filename, - 4 ) !== '.xml') {
|
||||
$filename = $filename . '.xml';
|
||||
$this->home=$home;
|
||||
$res = parent::parseFile( $filename , $language, $forceParse );
|
||||
if ($res==1)
|
||||
trigger_error('Faild to parse file ' . $filename . '.', E_USER_ERROR );
|
||||
if ($res==2)
|
||||
trigger_error('Faild to create cache file "' . $xmlform->parsedFile . '".', E_USER_ERROR );
|
||||
}
|
||||
$this->home = $home;
|
||||
$res = parent::parseFile( $filename, $language, $forceParse );
|
||||
if ($res == 1) {
|
||||
trigger_error( 'Faild to parse file ' . $filename . '.', E_USER_ERROR );
|
||||
}
|
||||
if ($res == 2) {
|
||||
trigger_error( 'Faild to create cache file "' . $xmlform->parsedFile . '".', E_USER_ERROR );
|
||||
}
|
||||
$this->setDefaultValues();
|
||||
//to do: review if you can use the same form twice. in order to use once or not.
|
||||
//DONE: Use require to be able to use the same xmlform more than once.
|
||||
foreach($this->fields as $k => $v) {
|
||||
foreach ($this->fields as $k => $v) {
|
||||
//too memory? but it fails if it's loaded with baneco.xml with SYS_LANG='es'
|
||||
//NOTE: This fails apparently when class of ($this->fields[$k]) is PHP_Incomplete_Class (because of cache)
|
||||
if (is_object($v)) {//julichu
|
||||
$this->fields[$k]->owner =& $this;
|
||||
if ($this->fields[$k]->type==='grid') $this->fields[$k]->parseFile($home, $language);
|
||||
if (is_object( $v )) {
|
||||
//julichu
|
||||
$this->fields[$k]->owner = & $this;
|
||||
if ($this->fields[$k]->type === 'grid') {
|
||||
$this->fields[$k]->parseFile( $home, $language );
|
||||
}
|
||||
}
|
||||
$this->template = PATH_CORE . 'templates/'.$this->type.'.html';
|
||||
}
|
||||
$this->template = PATH_CORE . 'templates/' . $this->type . '.html';
|
||||
}
|
||||
|
||||
/**
|
||||
* Function printTemplate
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string template
|
||||
* @param string scriptContent
|
||||
* @return string
|
||||
*/
|
||||
function printTemplate( $template, &$scriptContent )
|
||||
public function printTemplate ($template, &$scriptContent)
|
||||
{
|
||||
if (!file_exists($template)){
|
||||
throw(new Exception('Template "'.basename($template).'" doesn`t exist.'));
|
||||
if (! file_exists( $template )) {
|
||||
throw (new Exception( 'Template "' . basename( $template ) . '" doesn`t exist.' ));
|
||||
}
|
||||
$o = new xmlformTemplate( $this, $template );
|
||||
if (is_array( reset( $this->values ) )) {
|
||||
$this->rows = count( reset( $this->values ) );
|
||||
}
|
||||
$o = new xmlformTemplate($this, $template);
|
||||
if (is_array(reset($this->values)))
|
||||
$this->rows=count(reset($this->values));
|
||||
if ($this->enableTemplate) {
|
||||
$filename = substr($this->fileName , 0, -3) .
|
||||
( $this->type==='xmlform' ? '' : '.' . $this->type ) . 'html';
|
||||
if (!file_exists( $filename )) {
|
||||
$filename = substr( $this->fileName, 0, - 3 ) . ($this->type === 'xmlform' ? '' : '.' . $this->type) . 'html';
|
||||
if (! file_exists( $filename )) {
|
||||
$o->template = $o->printTemplate( $this );
|
||||
$f=fopen($filename, 'w+');
|
||||
fwrite($f, $o->template);
|
||||
fclose($f);
|
||||
$f = fopen( $filename, 'w+' );
|
||||
fwrite( $f, $o->template );
|
||||
fclose( $f );
|
||||
}
|
||||
$o->template = implode( '', file( $filename ) );
|
||||
} else {
|
||||
@@ -154,199 +168,212 @@ class Form extends XmlForm
|
||||
|
||||
/**
|
||||
* Function render
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string template
|
||||
* @param string scriptContent
|
||||
* @return string
|
||||
*/
|
||||
function render( $template, &$scriptContent )
|
||||
public function render ($template, &$scriptContent)
|
||||
{
|
||||
/***
|
||||
/**
|
||||
* *
|
||||
* This section was added for store the current used template.
|
||||
*/
|
||||
$tmp_var = explode('/', $template);
|
||||
if( is_array($tmp_var) ){
|
||||
$tmp_var = $tmp_var[sizeof($tmp_var)-1];
|
||||
$tmp_var = explode( '/', $template );
|
||||
if (is_array( $tmp_var )) {
|
||||
$tmp_var = $tmp_var[sizeof( $tmp_var ) - 1];
|
||||
$this->using_template = $tmp_var;
|
||||
}
|
||||
/***/
|
||||
/**
|
||||
*/
|
||||
$this->template = $template;
|
||||
$o = new xmlformTemplate($this, $template);
|
||||
$o = new xmlformTemplate( $this, $template );
|
||||
$values = $this->values;
|
||||
$aValuekeys=array_keys($values);
|
||||
if (isset($aValuekeys[0]) && ((int)$aValuekeys[0]==1))
|
||||
$values=XmlForm_Field_Grid::flipValues($values);
|
||||
$aValuekeys = array_keys( $values );
|
||||
if (isset( $aValuekeys[0] ) && ((int) $aValuekeys[0] == 1)) {
|
||||
$values = XmlForm_Field_Grid::flipValues( $values );
|
||||
}
|
||||
//TODO: Review when $values of a grid has only one row it is converted as a $values for a list (when template="grid" at addContent())
|
||||
if (is_array(reset($values))) {
|
||||
$this->rows=count(reset($values));
|
||||
if (is_array( reset( $values ) )) {
|
||||
$this->rows = count( reset( $values ) );
|
||||
}
|
||||
if ($this->enableTemplate) {
|
||||
$filename = substr($this->fileName, 0, -3) . 'html';
|
||||
if (!file_exists( $filename )) {
|
||||
$filename = substr( $this->fileName, 0, - 3 ) . 'html';
|
||||
if (! file_exists( $filename )) {
|
||||
$o->template = $o->printTemplate( $this );
|
||||
$f=fopen($filename, 'w+');
|
||||
fwrite($f, $o->template);
|
||||
fclose($f);
|
||||
$f = fopen( $filename, 'w+' );
|
||||
fwrite( $f, $o->template );
|
||||
fclose( $f );
|
||||
}
|
||||
$o->template = implode( '', file( $filename ) );
|
||||
} else {
|
||||
$o->template = $o->printTemplate( $this );
|
||||
}
|
||||
$scriptContent = $o->printJavaScript( $this );
|
||||
$content = $o->printObject($this);
|
||||
$content = $o->printObject( $this );
|
||||
return $content;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function setValues
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param array $newValues
|
||||
* @return string
|
||||
*/
|
||||
function setValues($newValues=array())
|
||||
public function setValues ($newValues = array())
|
||||
{
|
||||
if ( !is_array ( $newValues) ){
|
||||
if (! is_array( $newValues )) {
|
||||
return;
|
||||
}
|
||||
foreach($this->fields as $k => $v){
|
||||
if ( array_key_exists($k,$newValues) ) {
|
||||
if ( is_array($newValues[$k]) ) {
|
||||
$this->values[$k] = array();
|
||||
foreach( $newValues[$k] as $j => $item ) {
|
||||
if ($this->fields[$k]->validateValue($newValues[$k][$j], $this ))
|
||||
foreach ($this->fields as $k => $v) {
|
||||
if (array_key_exists( $k, $newValues )) {
|
||||
if (is_array( $newValues[$k] )) {
|
||||
$this->values[$k] = array ();
|
||||
foreach ($newValues[$k] as $j => $item) {
|
||||
if ($this->fields[$k]->validateValue( $newValues[$k][$j], $this )) {
|
||||
$this->values[$k][$j] = $newValues[$k][$j];
|
||||
}
|
||||
if ((sizeof($this->values[$k])===1) && ($v->type!=='grid') && isset($this->values[$k][0]) )
|
||||
}
|
||||
if ((sizeof( $this->values[$k] ) === 1) && ($v->type !== 'grid') && isset( $this->values[$k][0] )) {
|
||||
$this->values[$k] = $this->values[$k][0];
|
||||
if (sizeof($this->values[$k])===0)
|
||||
}
|
||||
if (sizeof( $this->values[$k] ) === 0) {
|
||||
$this->values[$k] = '';
|
||||
}
|
||||
} else {
|
||||
if ($this->fields[$k]->validateValue($newValues[$k], $this ))
|
||||
if ($this->fields[$k]->validateValue( $newValues[$k], $this )) {
|
||||
$this->values[$k] = $newValues[$k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($newValues as $k => $v) {
|
||||
if (strpos($k,'SYS_GRID_AGGREGATE_') !== false) {
|
||||
if (strpos( $k, 'SYS_GRID_AGGREGATE_' ) !== false) {
|
||||
$this->values[$k] = $newValues[$k];
|
||||
}
|
||||
}
|
||||
foreach($this->fields as $k => $v){
|
||||
if(is_object($this->fields[$k]) && get_class($this->fields[$k])!='__PHP_Incomplete_Class'){
|
||||
$this->fields[$k]->owner =& $this;
|
||||
foreach ($this->fields as $k => $v) {
|
||||
if (is_object( $this->fields[$k] ) && get_class( $this->fields[$k] ) != '__PHP_Incomplete_Class') {
|
||||
$this->fields[$k]->owner = & $this;
|
||||
}
|
||||
}
|
||||
if(isset($this->labelWidth)){
|
||||
if (isset( $this->labelWidth )) {
|
||||
$nMaxPorcent = 1024;
|
||||
$nWidth = stripos($this->width, '%');
|
||||
if($nWidth > 0) {
|
||||
$nWidth = stripos( $this->width, '%' );
|
||||
if ($nWidth > 0) {
|
||||
$sStrFind = $this->width;
|
||||
$result = substr($sStrFind, 0, strpos($sStrFind, '%'));
|
||||
$nWidth = (int)(($nMaxPorcent/100)*$result);
|
||||
$result = substr( $sStrFind, 0, strpos( $sStrFind, '%' ) );
|
||||
$nWidth = (int) (($nMaxPorcent / 100) * $result);
|
||||
} else {
|
||||
$nWidth = (int)$this->width;
|
||||
$nWidth = (int) $this->width;
|
||||
$nMaxPorcent = $nWidth;
|
||||
}
|
||||
$nLabelWidth = stripos($this->labelWidth, '%');
|
||||
if($nLabelWidth > 0) {
|
||||
$nLabelWidth = stripos( $this->labelWidth, '%' );
|
||||
if ($nLabelWidth > 0) {
|
||||
$sStrFind = $this->labelWidth;
|
||||
$result = substr($sStrFind, 0, strpos($sStrFind, '%'));
|
||||
$nLabelWidth = (int)(($nWidth/100)*$result);
|
||||
$result = substr( $sStrFind, 0, strpos( $sStrFind, '%' ) );
|
||||
$nLabelWidth = (int) (($nWidth / 100) * $result);
|
||||
} else {
|
||||
$nLabelWidth = (int)$this->labelWidth;
|
||||
$nLabelWidth = (int) $this->labelWidth;
|
||||
}
|
||||
// krumo($nWidth,$nLabelWidth);
|
||||
if(($nWidth - $nLabelWidth) > 0)
|
||||
$this->fieldContentWidth = (int)($nWidth - $nLabelWidth);
|
||||
if (($nWidth - $nLabelWidth) > 0) {
|
||||
$this->fieldContentWidth = (int) ($nWidth - $nLabelWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function getFields
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param string template
|
||||
* @param int $therow
|
||||
* @return string
|
||||
*/
|
||||
function getFields($template, $therow = -1)
|
||||
public function getFields ($template, $therow = -1)
|
||||
{
|
||||
$o = new xmlformTemplate($this, $template);
|
||||
$o = new xmlformTemplate( $this, $template );
|
||||
return $o->getFields( $this, $therow );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that validates the values retrieved in $_POST
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @return array $_POST['form']
|
||||
*/
|
||||
function validatePost()
|
||||
public function validatePost ()
|
||||
{
|
||||
$_POST['form']=$this->validateFields($_POST['form']);
|
||||
return $_POST['form']=$this->validateArray($_POST['form']);
|
||||
$_POST['form'] = $this->validateFields( $_POST['form'] );
|
||||
return $_POST['form'] = $this->validateArray( $_POST['form'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Function that validates the values retrieved in an Array:
|
||||
* ex $_POST['form']
|
||||
*
|
||||
* @author David S. Callizaya S. <davidsantos@colosa.com>
|
||||
* @access public
|
||||
* @param array $newValues
|
||||
* @return array
|
||||
*/
|
||||
function validateArray($newValues)
|
||||
public function validateArray ($newValues)
|
||||
{
|
||||
$values = array();
|
||||
foreach($this->fields as $k => $v) {
|
||||
$values = array ();
|
||||
foreach ($this->fields as $k => $v) {
|
||||
if (($v->type != 'submit')) {
|
||||
if ($v->type != 'file') {
|
||||
if ( array_key_exists($k,$newValues) ) {
|
||||
if (array_key_exists( $k, $newValues )) {
|
||||
|
||||
switch($v->type){
|
||||
switch ($v->type) {
|
||||
case 'radiogroup':
|
||||
$values[$k] = $newValues[$k];
|
||||
$values[$k . "_label"] = $newValues[$k . "_label"] = $v->options[$newValues[$k]];
|
||||
break;
|
||||
|
||||
case 'suggest':
|
||||
$values[$k] = $newValues[$k];
|
||||
$values[$k . "_label"] = $newValues[$k . "_label"];
|
||||
break;
|
||||
|
||||
case 'checkgroup':
|
||||
|
||||
case 'listbox':
|
||||
if ( is_array($newValues[$k]) ) {
|
||||
if (is_array( $newValues[$k] )) {
|
||||
$values[$k] = $values[$k . "_label"] = null;
|
||||
foreach ($newValues[$k] as $i => $value) {
|
||||
//if $value is empty continue with the next loop, because this is a not selected/checked item
|
||||
if (trim($value) == '') {
|
||||
if (trim( $value ) == '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
$values[$k] .= (($i != 0)? "|" : null) . $value;
|
||||
$values[$k] .= (($i != 0) ? "|" : null) . $value;
|
||||
|
||||
if (isset($v->options[$value])){
|
||||
$values[$k . "_label"] .= (($i != 0)? "|" : null) . $v->options[$value];
|
||||
}
|
||||
else { // if hasn't options try execute a sql sentence
|
||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||
if (isset( $v->options[$value] )) {
|
||||
$values[$k . "_label"] .= (($i != 0) ? "|" : null) . $v->options[$value];
|
||||
} else {
|
||||
// if hasn't options try execute a sql sentence
|
||||
$query = G::replaceDataField( $this->fields[$k]->sql, $newValues );
|
||||
|
||||
if ($query != '') { // execute just if a query was set, it should be not empty
|
||||
if ($query != '') {
|
||||
// execute just if a query was set, it should be not empty
|
||||
//we do the query to the external connection and we've got the label
|
||||
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");//use default connection workflow if connection is not defined. Same as Dynaforms
|
||||
$con = Propel::getConnection( $this->fields[$k]->sqlConnection != "" ? $this->fields[$k]->sqlConnection : "workflow" ); //use default connection workflow if connection is not defined. Same as Dynaforms
|
||||
|
||||
$stmt = $con->prepareStatement($query);
|
||||
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
|
||||
|
||||
$stmt = $con->prepareStatement( $query );
|
||||
$rs = $stmt->executeQuery( ResultSet::FETCHMODE_NUM );
|
||||
|
||||
while ($rs->next()) {
|
||||
list($rowId, $rowContent) = array_values($rs->getRow());//This to be sure that the array is numeric. Some cases when is DBArray result it returns an associative. By JHL
|
||||
list ($rowId, $rowContent) = array_values( $rs->getRow() ); //This to be sure that the array is numeric. Some cases when is DBArray result it returns an associative. By JHL
|
||||
|
||||
if ($value == $rowId){
|
||||
$values[$k . "_label"] .= (($i != 0)? "|" : null) . $rowContent;
|
||||
|
||||
if ($value == $rowId) {
|
||||
$values[$k . "_label"] .= (($i != 0) ? "|" : null) . $rowContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -355,44 +382,41 @@ class Form extends XmlForm
|
||||
}
|
||||
}
|
||||
|
||||
$newValues[$k . "_label"] = (isset($values[$k . "_label"]))? $values[$k . "_label"] : null;
|
||||
$newValues[$k . "_label"] = (isset( $values[$k . "_label"] )) ? $values[$k . "_label"] : null;
|
||||
} else {
|
||||
$values[$k] = $newValues[$k];
|
||||
$values[$k . "_label"] = (isset($newValues[$k . "_label"]))? $newValues[$k . "_label"] : null;
|
||||
$values[$k . "_label"] = (isset( $newValues[$k . "_label"] )) ? $newValues[$k . "_label"] : null;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'dropdown':
|
||||
$values[$k] = $newValues[$k];
|
||||
|
||||
if (isset($v->options[$newValues[$k]])){
|
||||
if (isset( $v->options[$newValues[$k]] )) {
|
||||
$values[$k . "_label"] = $newValues[$k . "_label"] = $v->options[$newValues[$k]];
|
||||
}
|
||||
else {
|
||||
$query = G::replaceDataField($this->fields[$k]->sql,$newValues);
|
||||
} else {
|
||||
$query = G::replaceDataField( $this->fields[$k]->sql, $newValues );
|
||||
|
||||
// execute just if a query was set, it should be not empty
|
||||
if(trim($query) == '') {
|
||||
if (trim( $query ) == '') {
|
||||
continue; //if it is empty string skip it
|
||||
}
|
||||
|
||||
//we do the query to the external connection and we've got the label
|
||||
$con = Propel::getConnection($this->fields[$k]->sqlConnection!=""?$this->fields[$k]->sqlConnection:"workflow");
|
||||
$stmt = $con->prepareStatement($query);
|
||||
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
|
||||
$con = Propel::getConnection( $this->fields[$k]->sqlConnection != "" ? $this->fields[$k]->sqlConnection : "workflow" );
|
||||
$stmt = $con->prepareStatement( $query );
|
||||
$rs = $stmt->executeQuery( ResultSet::FETCHMODE_NUM );
|
||||
while ($rs->next()) {
|
||||
list($rowId, $rowContent) = $rs->getRow();
|
||||
if ($newValues[$k]==$rowId){
|
||||
list ($rowId, $rowContent) = $rs->getRow();
|
||||
if ($newValues[$k] == $rowId) {
|
||||
$values[$k . "_label"] = $rowContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'grid':
|
||||
foreach( $newValues[$k] as $j => $item ) {
|
||||
if(is_array($item)){
|
||||
foreach ($newValues[$k] as $j => $item) {
|
||||
if (is_array( $item )) {
|
||||
$values[$k][$j] = $this->fields[$k]->maskValue( $newValues[$k][$j], $this );
|
||||
foreach ($item as $kk => $vv) {
|
||||
if ($this->fields[$k]->fields[$kk]->type != "file") {
|
||||
@@ -401,32 +425,32 @@ class Form extends XmlForm
|
||||
//We need to know which fields are dropdowns
|
||||
$values[$k][$j] = $newValues[$k][$j];
|
||||
|
||||
if ($this->fields[$k]->validateValue($newValues[$k][$j], $this)) {
|
||||
if ($this->fields[$k]->validateValue( $newValues[$k][$j], $this )) {
|
||||
//If the dropdown has otions
|
||||
if (isset($this->fields[$k]->fields[$kk]->options[$vv])) {
|
||||
if (isset( $this->fields[$k]->fields[$kk]->options[$vv] )) {
|
||||
$values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"] = $this->fields[$k]->fields[$kk]->options[$vv];
|
||||
} else {
|
||||
//If hasn't options try execute a sql sentence
|
||||
$query = G::replaceDataField($this->fields[$k]->fields[$kk]->sql,$values[$k][$j]);
|
||||
$con = Propel::getConnection((!empty($this->fields[$k]->fields[$kk]->sqlConnection))? $this->fields[$k]->fields[$kk]->sqlConnection : "workflow");
|
||||
$stmt = $con->prepareStatement($query);
|
||||
$query = G::replaceDataField( $this->fields[$k]->fields[$kk]->sql, $values[$k][$j] );
|
||||
$con = Propel::getConnection( (! empty( $this->fields[$k]->fields[$kk]->sqlConnection )) ? $this->fields[$k]->fields[$kk]->sqlConnection : "workflow" );
|
||||
$stmt = $con->prepareStatement( $query );
|
||||
|
||||
//Execute just if a query was set, it should be not empty
|
||||
if (trim($query) == "") {
|
||||
if (trim( $query ) == "") {
|
||||
//if it is empty string skip it
|
||||
continue;
|
||||
}
|
||||
|
||||
$rs = $stmt->executeQuery(ResultSet::FETCHMODE_NUM);
|
||||
$rs = $stmt->executeQuery( ResultSet::FETCHMODE_NUM );
|
||||
|
||||
while ($rs->next()) {
|
||||
//From the query executed we only need certain elements
|
||||
//note added by krlos pacha carlos[at]colosa[dot]com
|
||||
//the following line has the correct values because the query return an associative array. Related 7945 bug
|
||||
list($rowId, $rowContent) = explode(",", implode(",", $rs->getRow()));
|
||||
list ($rowId, $rowContent) = explode( ",", implode( ",", $rs->getRow() ) );
|
||||
|
||||
if ($vv == $rowId) {
|
||||
$values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk. "_label"] = $rowContent;
|
||||
$values[$k][$j][$kk . "_label"] = $newValues[$k][$j][$kk . "_label"] = $rowContent;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -436,15 +460,15 @@ class Form extends XmlForm
|
||||
default:
|
||||
//If there are no dropdowns previously setted and the evaluated field is not a dropdown
|
||||
//only then rewritte the $values
|
||||
$values[$k][$j] = $this->fields[$k]->maskValue($newValues[$k][$j], $this);
|
||||
$values[$k][$j] = $this->fields[$k]->maskValue( $newValues[$k][$j], $this );
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (isset($_FILES["form"]["name"][$k][$j][$kk])) {
|
||||
if (isset( $_FILES["form"]["name"][$k][$j][$kk] )) {
|
||||
$values[$k][$j][$kk] = $_FILES["form"]["name"][$k][$j][$kk];
|
||||
}
|
||||
|
||||
if (isset($this->fields[$k]->fields[$kk]->input) && !empty($this->fields[$k]->fields[$kk]->input)) {
|
||||
if (isset( $this->fields[$k]->fields[$kk]->input ) && ! empty( $this->fields[$k]->fields[$kk]->input )) {
|
||||
//$_POST["INPUTS"][$k][$j][$kk] = $this->fields[$k]->fields[$kk]->input;
|
||||
$_POST["INPUTS"][$k][$kk] = $this->fields[$k]->fields[$kk]->input;
|
||||
}
|
||||
@@ -455,20 +479,18 @@ class Form extends XmlForm
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($this->fields[$k]->validateValue($newValues[$k], $this ))
|
||||
if ($this->fields[$k]->validateValue( $newValues[$k], $this )) {
|
||||
$values[$k] = $this->fields[$k]->maskValue( $newValues[$k], $this );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isset($_FILES["form"]["name"][$k])) {
|
||||
if (isset( $_FILES["form"]["name"][$k] )) {
|
||||
$values[$k] = $_FILES["form"]["name"][$k];
|
||||
}
|
||||
|
||||
if (isset($v->input) && !empty($v->input)) {
|
||||
if (isset( $v->input ) && ! empty( $v->input )) {
|
||||
$_POST["INPUTS"][$k] = $v->input;
|
||||
}
|
||||
}
|
||||
@@ -476,7 +498,7 @@ class Form extends XmlForm
|
||||
}
|
||||
|
||||
foreach ($newValues as $k => $v) {
|
||||
if (strpos($k, 'SYS_GRID_AGGREGATE_') !== false) {
|
||||
if (strpos( $k, 'SYS_GRID_AGGREGATE_' ) !== false) {
|
||||
$values[$k] = $v;
|
||||
}
|
||||
}
|
||||
@@ -486,26 +508,26 @@ class Form extends XmlForm
|
||||
|
||||
/**
|
||||
* Function that return the valid fields to replace
|
||||
*
|
||||
* @author Julio Cesar Laura Avendao?=o <juliocesar@colosa.com>
|
||||
* @access public
|
||||
* @param boolean $bWhitSystemVars
|
||||
* @return array
|
||||
*/
|
||||
function getVars($bWhitSystemVars = true)
|
||||
public function getVars ($bWhitSystemVars = true)
|
||||
{
|
||||
$aFields = array();
|
||||
$aFields = array ();
|
||||
if ($bWhitSystemVars) {
|
||||
$aAux = G::getSystemConstants();
|
||||
foreach ($aAux as $sName => $sValue) {
|
||||
$aFields[] = array('sName' => $sName, 'sType' => 'system');
|
||||
$aFields[] = array ('sName' => $sName,'sType' => 'system'
|
||||
);
|
||||
}
|
||||
}
|
||||
foreach($this->fields as $k => $v) {
|
||||
if (($v->type != 'title') && ($v->type != 'subtitle') && ($v->type != 'link') &&
|
||||
($v->type != 'file') && ($v->type != 'button') && ($v->type != 'reset') &&
|
||||
($v->type != 'submit') && ($v->type != 'listbox') && ($v->type != 'checkgroup') &&
|
||||
($v->type != 'grid') && ($v->type != 'javascript')) {
|
||||
$aFields[] = array('sName' => trim($k), 'sType' => trim($v->type));
|
||||
foreach ($this->fields as $k => $v) {
|
||||
if (($v->type != 'title') && ($v->type != 'subtitle') && ($v->type != 'link') && ($v->type != 'file') && ($v->type != 'button') && ($v->type != 'reset') && ($v->type != 'submit') && ($v->type != 'listbox') && ($v->type != 'checkgroup') && ($v->type != 'grid') && ($v->type != 'javascript')) {
|
||||
$aFields[] = array ('sName' => trim( $k ),'sType' => trim( $v->type )
|
||||
);
|
||||
}
|
||||
}
|
||||
return $aFields;
|
||||
@@ -513,58 +535,59 @@ class Form extends XmlForm
|
||||
|
||||
/**
|
||||
* Function that verify the required fields without a correct value
|
||||
*
|
||||
* @author Erik Amaru Ortiz <erik@colosa.com>
|
||||
* @access public
|
||||
* @param array $dataFields
|
||||
* @param array $noRequired
|
||||
* @return array/false
|
||||
*/
|
||||
function validateRequiredFields($dataFields, $noRequired = array())
|
||||
public function validateRequiredFields ($dataFields, $noRequired = array())
|
||||
{
|
||||
if (!is_array($noRequired)) {
|
||||
$noRequired = array();
|
||||
if (! is_array( $noRequired )) {
|
||||
$noRequired = array ();
|
||||
}
|
||||
$requiredFields = array();
|
||||
$notPassedFields = array();
|
||||
$skippedFieldsTypes = array('javascript', 'checkbox', 'yesno', 'submit', 'button', 'title', 'subtitle',
|
||||
'button', 'submit', 'reset', 'hidden', 'link');
|
||||
$requiredFieldsGrids = array();
|
||||
$grids = array();
|
||||
$requiredFields = array ();
|
||||
$notPassedFields = array ();
|
||||
$skippedFieldsTypes = array ('javascript','checkbox','yesno','submit','button','title','subtitle','button','submit','reset','hidden','link'
|
||||
);
|
||||
$requiredFieldsGrids = array ();
|
||||
$grids = array ();
|
||||
|
||||
foreach ($this->fields as $field) {
|
||||
// verify fields in grids
|
||||
if($field->type == 'grid') {
|
||||
array_push($grids, $field->name);
|
||||
if ($field->type == 'grid') {
|
||||
array_push( $grids, $field->name );
|
||||
foreach ($field->fields as $fieldGrid) {
|
||||
if (is_object($fieldGrid) && isset($fieldGrid->required) && $fieldGrid->required) {
|
||||
if (!in_array($fieldGrid->type, $skippedFieldsTypes)) {
|
||||
if ( !(is_array($requiredFieldsGrids[$field->name])) ) {
|
||||
$requiredFieldsGrids[$field->name] = array();
|
||||
if (is_object( $fieldGrid ) && isset( $fieldGrid->required ) && $fieldGrid->required) {
|
||||
if (! in_array( $fieldGrid->type, $skippedFieldsTypes )) {
|
||||
if (! (is_array( $requiredFieldsGrids[$field->name] ))) {
|
||||
$requiredFieldsGrids[$field->name] = array ();
|
||||
}
|
||||
array_push($requiredFieldsGrids[$field->name], $fieldGrid->name);
|
||||
array_push( $requiredFieldsGrids[$field->name], $fieldGrid->name );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// verify fields the form
|
||||
if (is_object($field) && isset($field->required) && $field->required) {
|
||||
if (!in_array($field->type, $skippedFieldsTypes)) {
|
||||
array_push($requiredFields, $field->name);
|
||||
if (is_object( $field ) && isset( $field->required ) && $field->required) {
|
||||
if (! in_array( $field->type, $skippedFieldsTypes )) {
|
||||
array_push( $requiredFields, $field->name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($dataFields as $dataFieldName => $dataField) {
|
||||
if (in_array($dataFieldName, $grids)) {
|
||||
foreach ($dataFields as $dataFieldName => $dataField) {
|
||||
if (in_array( $dataFieldName, $grids )) {
|
||||
foreach ($dataField as $indexGrid => $dataGrid) {
|
||||
foreach ($dataGrid as $fieldGridName => $fieldGridValue) {
|
||||
if (!is_array($requiredFieldsGrids[$dataFieldName])) {
|
||||
$requiredFieldsGrids[$dataFieldName] = array();
|
||||
if (! is_array( $requiredFieldsGrids[$dataFieldName] )) {
|
||||
$requiredFieldsGrids[$dataFieldName] = array ();
|
||||
}
|
||||
if (in_array($fieldGridName, $requiredFieldsGrids[$dataFieldName]) && !in_array($fieldGridName, $noRequired) && trim($fieldGridValue) == '') {
|
||||
if ( !(is_array($notPassedFields[$dataFieldName])) ) {
|
||||
$notPassedFields[$dataFieldName] = array();
|
||||
if (in_array( $fieldGridName, $requiredFieldsGrids[$dataFieldName] ) && ! in_array( $fieldGridName, $noRequired ) && trim( $fieldGridValue ) == '') {
|
||||
if (! (is_array( $notPassedFields[$dataFieldName] ))) {
|
||||
$notPassedFields[$dataFieldName] = array ();
|
||||
}
|
||||
$notPassedFields[$dataFieldName][$indexGrid][] = $fieldGridName;
|
||||
}
|
||||
@@ -573,37 +596,36 @@ class Form extends XmlForm
|
||||
}
|
||||
|
||||
//verify if the requiered field is in $requiredFields array
|
||||
if (in_array($dataFieldName, $requiredFields) && !in_array($dataFieldName, $noRequired) && trim($dataField) == '') {
|
||||
if (in_array( $dataFieldName, $requiredFields ) && ! in_array( $dataFieldName, $noRequired ) && trim( $dataField ) == '') {
|
||||
$notPassedFields[] = $dataFieldName;
|
||||
}
|
||||
}
|
||||
|
||||
return count($notPassedFields) > 0 ? $notPassedFields : false;
|
||||
return count( $notPassedFields ) > 0 ? $notPassedFields : false;
|
||||
}
|
||||
|
||||
public function validateFields($data)
|
||||
public function validateFields ($data)
|
||||
{
|
||||
$excludeTypes = array("submit", "file");
|
||||
$excludeTypes = array ("submit","file" );
|
||||
|
||||
foreach ($this->fields as $k => $v) {
|
||||
if (!in_array($v->type, $excludeTypes)) {
|
||||
if (! in_array( $v->type, $excludeTypes )) {
|
||||
switch ($v->type) {
|
||||
case "checkbox":
|
||||
$data[$v->name] = (isset($data[$v->name]))? $data[$v->name] : ((isset($v->falseValue))? $v->falseValue : null);
|
||||
$data[$v->name] = (isset( $data[$v->name] )) ? $data[$v->name] : ((isset( $v->falseValue )) ? $v->falseValue : null);
|
||||
break;
|
||||
case "grid":
|
||||
$i = 0;
|
||||
|
||||
foreach ($data[$v->name] as $dataGrid) {
|
||||
$i = $i + 1;
|
||||
|
||||
foreach ($v->fields as $gridField) {
|
||||
switch ($gridField->type) {
|
||||
case "file":
|
||||
$data[$v->name][$i][$gridField->name] = (isset($_FILES["form"]["name"][$v->name][$i][$gridField->name]))? $_FILES["form"]["name"][$v->name][$i][$gridField->name] : ((isset($gridField->falseValue))? $gridField->falseValue : null);
|
||||
$data[$v->name][$i][$gridField->name] = (isset( $_FILES["form"]["name"][$v->name][$i][$gridField->name] )) ? $_FILES["form"]["name"][$v->name][$i][$gridField->name] : ((isset( $gridField->falseValue )) ? $gridField->falseValue : null);
|
||||
break;
|
||||
case "checkbox":
|
||||
$data[$v->name][$i][$gridField->name] = (isset($data[$v->name][$i][$gridField->name]))? $data[$v->name][$i][$gridField->name] : ((isset($gridField->falseValue))? $gridField->falseValue : null);
|
||||
$data[$v->name][$i][$gridField->name] = (isset( $data[$v->name][$i][$gridField->name] )) ? $data[$v->name][$i][$gridField->name] : ((isset( $gridField->falseValue )) ? $gridField->falseValue : null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -614,7 +636,7 @@ class Form extends XmlForm
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.functionTest.php
|
||||
*
|
||||
* @package gulliver.system
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -24,14 +26,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package gulliver.system
|
||||
**/
|
||||
*
|
||||
*/
|
||||
|
||||
class functionTest
|
||||
{
|
||||
var $dbc;
|
||||
var $times;
|
||||
public $dbc;
|
||||
public $times;
|
||||
|
||||
/**
|
||||
* Starts functionTest with a database connection
|
||||
@@ -41,8 +45,9 @@ class functionTest
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
function functionTest( $dbc ) {
|
||||
$this->dbc= $dbc;
|
||||
public function functionTest ($dbc)
|
||||
{
|
||||
$this->dbc = $dbc;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +60,9 @@ class functionTest
|
||||
* @return ok
|
||||
*
|
||||
*/
|
||||
function sample( $testCase , &$testDomain , &$limeTestObject ) {
|
||||
public function sample ($testCase, &$testDomain, &$limeTestObject)
|
||||
{
|
||||
return "OK";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,78 +3,82 @@
|
||||
/**
|
||||
* Class RestClient
|
||||
*/
|
||||
class RestClient {
|
||||
class RestClient
|
||||
{
|
||||
|
||||
private $curl ;
|
||||
private $url ;
|
||||
private $response ="";
|
||||
private $headers = array();
|
||||
private $curl;
|
||||
private $url;
|
||||
private $response = "";
|
||||
private $headers = array ();
|
||||
|
||||
private $method="GET";
|
||||
private $params=null;
|
||||
private $method = "GET";
|
||||
private $params = null;
|
||||
private $contentType = null;
|
||||
private $file =null;
|
||||
private $file = null;
|
||||
|
||||
/**
|
||||
* Private Constructor, sets default options
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct ()
|
||||
{
|
||||
$this->curl = curl_init();
|
||||
curl_setopt($this->curl,CURLOPT_RETURNTRANSFER,true);
|
||||
curl_setopt($this->curl,CURLOPT_AUTOREFERER,true); // This make sure will follow redirects
|
||||
curl_setopt($this->curl,CURLOPT_FOLLOWLOCATION,true); // This too
|
||||
curl_setopt($this->curl,CURLOPT_HEADER,true); // THis verbose option for extracting the headers
|
||||
curl_setopt( $this->curl, CURLOPT_RETURNTRANSFER, true );
|
||||
curl_setopt( $this->curl, CURLOPT_AUTOREFERER, true ); // This make sure will follow redirects
|
||||
curl_setopt( $this->curl, CURLOPT_FOLLOWLOCATION, true ); // This too
|
||||
curl_setopt( $this->curl, CURLOPT_HEADER, true ); // THis verbose option for extracting the headers
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the call to the webservice
|
||||
*
|
||||
* @return RestClient
|
||||
*/
|
||||
public function execute() {
|
||||
if($this->method === "POST") {
|
||||
curl_setopt($this->curl,CURLOPT_POST,true);
|
||||
curl_setopt($this->curl,CURLOPT_POSTFIELDS,$this->params);
|
||||
public function execute ()
|
||||
{
|
||||
if ($this->method === "POST") {
|
||||
curl_setopt( $this->curl, CURLOPT_POST, true );
|
||||
curl_setopt( $this->curl, CURLOPT_POSTFIELDS, $this->params );
|
||||
//var_dump($this->params);
|
||||
//die;
|
||||
} else if($this->method == "GET"){
|
||||
curl_setopt($this->curl,CURLOPT_HTTPGET,true);
|
||||
} elseif ($this->method == "GET") {
|
||||
curl_setopt( $this->curl, CURLOPT_HTTPGET, true );
|
||||
$this->treatURL();
|
||||
} else if($this->method === "PUT") {
|
||||
curl_setopt($this->curl,CURLOPT_PUT,true);
|
||||
} elseif ($this->method === "PUT") {
|
||||
curl_setopt( $this->curl, CURLOPT_PUT, true );
|
||||
$this->treatURL();
|
||||
$this->file = tmpFile();
|
||||
fwrite($this->file,$this->params);
|
||||
fseek($this->file,0);
|
||||
curl_setopt($this->curl,CURLOPT_INFILE,$this->file);
|
||||
curl_setopt($this->curl,CURLOPT_INFILESIZE,strlen($this->params));
|
||||
fwrite( $this->file, $this->params );
|
||||
fseek( $this->file, 0 );
|
||||
curl_setopt( $this->curl, CURLOPT_INFILE, $this->file );
|
||||
curl_setopt( $this->curl, CURLOPT_INFILESIZE, strlen( $this->params ) );
|
||||
} else {
|
||||
curl_setopt($this->curl,CURLOPT_CUSTOMREQUEST,$this->method);
|
||||
curl_setopt( $this->curl, CURLOPT_CUSTOMREQUEST, $this->method );
|
||||
}
|
||||
if($this->contentType != null) {
|
||||
curl_setopt($this->curl,CURLOPT_HTTPHEADER,array("Content-Type: ".$this->contentType, "SKEY: 8QRtY5zXyViZ9fjYou"));
|
||||
if ($this->contentType != null) {
|
||||
curl_setopt( $this->curl, CURLOPT_HTTPHEADER, array ("Content-Type: " . $this->contentType,"SKEY: 8QRtY5zXyViZ9fjYou" ) );
|
||||
}
|
||||
curl_setopt($this->curl,CURLOPT_URL,$this->url);
|
||||
$r = curl_exec($this->curl);
|
||||
if($this->method !== "DELETE")
|
||||
{
|
||||
$this->treatResponse($r); // Extract the headers and response
|
||||
return $this ;
|
||||
}
|
||||
else{
|
||||
curl_setopt( $this->curl, CURLOPT_URL, $this->url );
|
||||
$r = curl_exec( $this->curl );
|
||||
if ($this->method !== "DELETE") {
|
||||
$this->treatResponse( $r ); // Extract the headers and response
|
||||
return $this;
|
||||
} else {
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Treats URL
|
||||
*/
|
||||
private function treatURL(){
|
||||
if(is_array($this->params) && count($this->params) >= 1) { // Transform parameters in key/value pars in URL
|
||||
if(!strpos($this->url,'?'))
|
||||
$this->url .= '?' ;
|
||||
foreach($this->params as $k=>$v) {
|
||||
$this->url .= "&".urlencode($k)."=".urlencode($v);
|
||||
private function treatURL ()
|
||||
{
|
||||
if (is_array( $this->params ) && count( $this->params ) >= 1) {
|
||||
// Transform parameters in key/value pars in URL
|
||||
if (! strpos( $this->url, '?' )) {
|
||||
$this->url .= '?';
|
||||
}
|
||||
foreach ($this->params as $k => $v) {
|
||||
$this->url .= "&" . urlencode( $k ) . "=" . urlencode( $v );
|
||||
}
|
||||
}
|
||||
return $this->url;
|
||||
@@ -83,26 +87,28 @@ class RestClient {
|
||||
/*
|
||||
* Treats the Response for extracting the Headers and Response
|
||||
*/
|
||||
private function treatResponse($r) {
|
||||
if($r == null or strlen($r) < 1) {
|
||||
private function treatResponse ($r)
|
||||
{
|
||||
if ($r == null or strlen( $r ) < 1) {
|
||||
return;
|
||||
}
|
||||
$parts = explode("\n\r",$r); // HTTP packets define that Headers end in a blank line (\n\r) where starts the body
|
||||
while(preg_match('@HTTP/1.[0-1] 100 Continue@',$parts[0]) or preg_match("@Moved@",$parts[0])) {
|
||||
$parts = explode( "\n\r", $r ); // HTTP packets define that Headers end in a blank line (\n\r) where starts the body
|
||||
while (preg_match( '@HTTP/1.[0-1] 100 Continue@', $parts[0] ) or preg_match( "@Moved@", $parts[0] )) {
|
||||
// Continue header must be bypass
|
||||
for($i=1;$i<count($parts);$i++) {
|
||||
$parts[$i - 1] = trim($parts[$i]);
|
||||
for ($i = 1; $i < count( $parts ); $i ++) {
|
||||
$parts[$i - 1] = trim( $parts[$i] );
|
||||
}
|
||||
unset($parts[count($parts) - 1]);
|
||||
unset( $parts[count( $parts ) - 1] );
|
||||
}
|
||||
preg_match("@Content-Type: ([a-zA-Z0-9-]+/?[a-zA-Z0-9-]*)@",$parts[0],$reg);// This extract the content type
|
||||
preg_match( "@Content-Type: ([a-zA-Z0-9-]+/?[a-zA-Z0-9-]*)@", $parts[0], $reg ); // This extract the content type
|
||||
$this->headers['content-type'] = $reg[1];
|
||||
preg_match("@HTTP/1.[0-1] ([0-9]{3}) ([a-zA-Z ]+)@",$parts[0],$reg); // This extracts the response header Code and Message
|
||||
preg_match( "@HTTP/1.[0-1] ([0-9]{3}) ([a-zA-Z ]+)@", $parts[0], $reg ); // This extracts the response header Code and Message
|
||||
$this->headers['code'] = $reg[1];
|
||||
$this->headers['message'] = $reg[2];
|
||||
$this->response = "";
|
||||
for($i=1;$i<count($parts);$i++) {//This make sure that exploded response get back togheter
|
||||
if($i > 1) {
|
||||
for ($i = 1; $i < count( $parts ); $i ++) {
|
||||
//This make sure that exploded response get back togheter
|
||||
if ($i > 1) {
|
||||
$this->response .= "\n\r";
|
||||
}
|
||||
$this->response .= $parts[$i];
|
||||
@@ -112,22 +118,25 @@ class RestClient {
|
||||
/*
|
||||
* @return array
|
||||
*/
|
||||
public function getHeaders() {
|
||||
public function getHeaders ()
|
||||
{
|
||||
return $this->headers;
|
||||
}
|
||||
|
||||
/*
|
||||
* @return string
|
||||
*/
|
||||
public function getResponse() {
|
||||
return $this->response ;
|
||||
public function getResponse ()
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
/*
|
||||
* HTTP response code (404,401,200,etc)
|
||||
* @return int
|
||||
*/
|
||||
public function getResponseCode() {
|
||||
public function getResponseCode ()
|
||||
{
|
||||
return (int) $this->headers['code'];
|
||||
}
|
||||
|
||||
@@ -135,7 +144,8 @@ class RestClient {
|
||||
* HTTP response message (Not Found, Continue, etc )
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseMessage() {
|
||||
public function getResponseMessage ()
|
||||
{
|
||||
return $this->headers['message'];
|
||||
}
|
||||
|
||||
@@ -143,38 +153,45 @@ class RestClient {
|
||||
* Content-Type (text/plain, application/xml, etc)
|
||||
* @return string
|
||||
*/
|
||||
public function getResponseContentType() {
|
||||
public function getResponseContentType ()
|
||||
{
|
||||
return $this->headers['content-type'];
|
||||
}
|
||||
|
||||
/**
|
||||
* This sets that will not follow redirects
|
||||
*
|
||||
* @return RestClient
|
||||
*/
|
||||
public function setNoFollow() {
|
||||
curl_setopt($this->curl,CURLOPT_AUTOREFERER,false);
|
||||
curl_setopt($this->curl,CURLOPT_FOLLOWLOCATION,false);
|
||||
public function setNoFollow ()
|
||||
{
|
||||
curl_setopt( $this->curl, CURLOPT_AUTOREFERER, false );
|
||||
curl_setopt( $this->curl, CURLOPT_FOLLOWLOCATION, false );
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* This closes the connection and release resources
|
||||
*
|
||||
* @return RestClient
|
||||
*/
|
||||
public function close() {
|
||||
curl_close($this->curl);
|
||||
$this->curl = null ;
|
||||
if($this->file !=null) {
|
||||
fclose($this->file);
|
||||
public function close ()
|
||||
{
|
||||
curl_close( $this->curl );
|
||||
$this->curl = null;
|
||||
if ($this->file != null) {
|
||||
fclose( $this->file );
|
||||
}
|
||||
return $this ;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the URL to be Called
|
||||
*
|
||||
* @return RestClient
|
||||
*/
|
||||
public function setUrl($url) {
|
||||
public function setUrl ($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
return $this;
|
||||
}
|
||||
@@ -182,24 +199,28 @@ class RestClient {
|
||||
/**
|
||||
* Set the Content-Type of the request to be send
|
||||
* Format like "application/xml" or "text/plain" or other
|
||||
*
|
||||
* @param string $contentType
|
||||
* @return RestClient
|
||||
*/
|
||||
public function setContentType($contentType) {
|
||||
public function setContentType ($contentType)
|
||||
{
|
||||
$this->contentType = $contentType;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Credentials for BASIC Authentication
|
||||
*
|
||||
* @param string $user
|
||||
* @param string $pass
|
||||
* @return RestClient
|
||||
*/
|
||||
public function setCredentials($user,$pass) {
|
||||
if($user != null) {
|
||||
curl_setopt($this->curl,CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
|
||||
curl_setopt($this->curl,CURLOPT_USERPWD,"{$user}:{$pass}");
|
||||
public function setCredentials ($user, $pass)
|
||||
{
|
||||
if ($user != null) {
|
||||
curl_setopt( $this->curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC );
|
||||
curl_setopt( $this->curl, CURLOPT_USERPWD, "{$user}:{$pass}" );
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@@ -207,11 +228,13 @@ class RestClient {
|
||||
/**
|
||||
* Set the Request HTTP Method
|
||||
* For now, only accepts GET and POST
|
||||
*
|
||||
* @param string $method
|
||||
* @return RestClient
|
||||
*/
|
||||
public function setMethod($method) {
|
||||
$this->method=$method;
|
||||
public function setMethod ($method)
|
||||
{
|
||||
$this->method = $method;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -220,29 +243,34 @@ class RestClient {
|
||||
* It can be both a key/value par array (as in array("key"=>"value"))
|
||||
* or a string containing the body of the request, like a XML, JSON or other
|
||||
* Proper content-type should be set for the body if not a array
|
||||
*
|
||||
* @param mixed $params
|
||||
* @return RestClient
|
||||
*/
|
||||
public function setParameters($params) {
|
||||
$this->params=$params;
|
||||
public function setParameters ($params)
|
||||
{
|
||||
$this->params = $params;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the RESTClient
|
||||
*
|
||||
* @param string $url=null [optional]
|
||||
* @return RestClient
|
||||
*/
|
||||
public static function createClient($url=null) {
|
||||
$client = new RestClient ;
|
||||
if($url != null) {
|
||||
$client->setUrl($url);
|
||||
public static function createClient ($url = null)
|
||||
{
|
||||
$client = new RestClient();
|
||||
if ($url != null) {
|
||||
$client->setUrl( $url );
|
||||
}
|
||||
return $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method wrapping a commom POST call
|
||||
*
|
||||
* @param string $url
|
||||
* @param mixed params
|
||||
* @param string $user=null [optional]
|
||||
@@ -251,13 +279,15 @@ class RestClient {
|
||||
* @return RestClient
|
||||
*/
|
||||
//public static function post($url,$params=null,$user=null,$pwd=null,$contentType="multipart/form-data") {
|
||||
public static function post($url,$params,$user,$pwd,$contentType="multipart/form-data") {
|
||||
public static function post ($url, $params, $user, $pwd, $contentType = "multipart/form-data")
|
||||
{
|
||||
//return self::call("POST",$url,$params,$user,$pwd,$contentType);
|
||||
return self::call("POST",$url,$params,$user,$pwd,$contentType);
|
||||
return self::call( "POST", $url, $params, $user, $pwd, $contentType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method wrapping a commom PUT call
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $body
|
||||
* @param string $user=null [optional]
|
||||
@@ -265,12 +295,14 @@ class RestClient {
|
||||
* @param string $contentType=null [optional]
|
||||
* @return RestClient
|
||||
*/
|
||||
public static function put($url,$body,$user=null,$pwd=null,$contentType=null) {
|
||||
return self::call("PUT",$url,$body,$user,$pwd,$contentType);
|
||||
public static function put ($url, $body, $user = null, $pwd = null, $contentType = null)
|
||||
{
|
||||
return self::call( "PUT", $url, $body, $user, $pwd, $contentType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method wrapping a commom GET call
|
||||
*
|
||||
* @param string $url
|
||||
* @param array params
|
||||
* @param string $user=null [optional]
|
||||
@@ -278,25 +310,29 @@ class RestClient {
|
||||
* @return RestClient
|
||||
*/
|
||||
//public static function get($url,array $params=null,$user=null,$pwd=null,$contentType=null) {
|
||||
public static function get($url,$user,$pwd,$contentType=null) {
|
||||
public static function get ($url, $user, $pwd, $contentType = null)
|
||||
{
|
||||
//return self::call("GET",$url,$params,$user,$pwd,$contentType);
|
||||
return self::call("GET",$url,null,$user,$pwd,$contentType);
|
||||
return self::call( "GET", $url, null, $user, $pwd, $contentType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method wrapping a commom delete call
|
||||
*
|
||||
* @param string $url
|
||||
* @param array params
|
||||
* @param string $user=null [optional]
|
||||
* @param string $password=null [optional]
|
||||
* @return RestClient
|
||||
*/
|
||||
public static function delete($url,$user=null,$pwd=null,$contentType=null) {
|
||||
return self::call("DELETE",$url,null,$user,$pwd,$contentType);
|
||||
public static function delete ($url, $user = null, $pwd = null, $contentType = null)
|
||||
{
|
||||
return self::call( "DELETE", $url, null, $user, $pwd, $contentType );
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method wrapping a commom custom call
|
||||
*
|
||||
* @param string $method
|
||||
* @param string $url
|
||||
* @param string $body
|
||||
@@ -305,15 +341,9 @@ class RestClient {
|
||||
* @param string $contentType=null [optional]
|
||||
* @return RestClient
|
||||
*/
|
||||
public static function call($method,$url,$body,$user=null,$pwd=null,$contentType=null) {
|
||||
return self::createClient($url)
|
||||
->setParameters($body)
|
||||
->setMethod($method)
|
||||
->setCredentials($user,$pwd)
|
||||
->setContentType($contentType)
|
||||
->execute()
|
||||
->close();
|
||||
public static function call ($method, $url, $body, $user = null, $pwd = null, $contentType = null)
|
||||
{
|
||||
return self::createClient( $url )->setParameters( $body )->setMethod( $method )->setCredentials( $user, $pwd )->setContentType( $contentType )->execute()->close();
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* class.ymlTestCases.php
|
||||
*
|
||||
* @package gulliver.system
|
||||
*
|
||||
* ProcessMaker Open Source Edition
|
||||
@@ -41,13 +43,14 @@
|
||||
* ...
|
||||
*/
|
||||
|
||||
/**
|
||||
/**
|
||||
*
|
||||
* @package gulliver.system
|
||||
*/
|
||||
class ymlTestCases
|
||||
{
|
||||
var $testCaseFile;
|
||||
var $testCases=array();
|
||||
public $testCaseFile;
|
||||
public $testCases = array ();
|
||||
|
||||
/**
|
||||
* function TestCases
|
||||
@@ -58,13 +61,14 @@ class ymlTestCases
|
||||
* @param string $testLime
|
||||
* @return void
|
||||
*/
|
||||
function ymlTestCases( $testCaseFile, &$testDomain, &$testLime )
|
||||
public function ymlTestCases ($testCaseFile, &$testDomain, &$testLime)
|
||||
{
|
||||
$this->testDomain =& $testDomain;
|
||||
$this->testLime =& $testLime;
|
||||
if (basename($testCaseFile)===$testCaseFile)
|
||||
$this->testDomain = & $testDomain;
|
||||
$this->testLime = & $testLime;
|
||||
if (basename( $testCaseFile ) === $testCaseFile) {
|
||||
$testCaseFile = PATH_FIXTURES . $testCaseFile;
|
||||
$this->testCaseFile=$testCaseFile;
|
||||
}
|
||||
$this->testCaseFile = $testCaseFile;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,64 +79,59 @@ class ymlTestCases
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*/
|
||||
function load( $inputTestCasesIndex = 'TestCases', $fields=array() )
|
||||
public function load ($inputTestCasesIndex = 'TestCases', $fields = array())
|
||||
{
|
||||
$testCases=array();
|
||||
$testCases = array ();
|
||||
$input = sfYAML::Load( /*PATH_FIXTURES .*/ $this->testCaseFile );
|
||||
foreach($input[$inputTestCasesIndex] as $preTestCase){
|
||||
$testFunctionInputs=array();
|
||||
foreach($preTestCase['Input'] as $inputArgument => $value ){
|
||||
if (substr($inputArgument,-2,2)==='[]'){
|
||||
foreach ($input[$inputTestCasesIndex] as $preTestCase) {
|
||||
$testFunctionInputs = array ();
|
||||
foreach ($preTestCase['Input'] as $inputArgument => $value) {
|
||||
if (substr( $inputArgument, - 2, 2 ) === '[]') {
|
||||
//DOMAIN
|
||||
$inputArgument=substr($inputArgument,0,strlen($inputArgument)-2);
|
||||
if (!isset($testFunctionInputs[$inputArgument]))
|
||||
$testFunctionInputs[$inputArgument]=array();
|
||||
$inputArgument = substr( $inputArgument, 0, strlen( $inputArgument ) - 2 );
|
||||
if (! isset( $testFunctionInputs[$inputArgument] )) {
|
||||
$testFunctionInputs[$inputArgument] = array ();
|
||||
}
|
||||
//var_dump($this->testDomain->global,$this->testDomain->get( $value ), $value );
|
||||
ymlDomain::arrayAppend(
|
||||
$testFunctionInputs[$inputArgument],
|
||||
$this->testDomain->get( $value )
|
||||
);
|
||||
}
|
||||
else{
|
||||
ymlDomain::arrayAppend( $testFunctionInputs[$inputArgument], $this->testDomain->get( $value ) );
|
||||
} else {
|
||||
//SPECIFIC VALUE
|
||||
if (!isset($testFunctionInputs[$inputArgument])){
|
||||
$testFunctionInputs[$inputArgument]=array();
|
||||
if (! isset( $testFunctionInputs[$inputArgument] )) {
|
||||
$testFunctionInputs[$inputArgument] = array ();
|
||||
}
|
||||
ymlDomain::arrayAppend(
|
||||
$testFunctionInputs[$inputArgument],
|
||||
array($value)
|
||||
);
|
||||
ymlDomain::arrayAppend( $testFunctionInputs[$inputArgument], array ($value) );
|
||||
}
|
||||
}
|
||||
/* Start Block: "Explode" all the posible test cases defined in the yml
|
||||
* using domains and single values
|
||||
*/
|
||||
//Initialize $index key values for the first test case (5.2 array_fill_keys(array_keys($testFunctionInputs),0))
|
||||
$index=array_combine(array_keys($testFunctionInputs),array_fill(0,count($testFunctionInputs),0));
|
||||
$index = array_combine( array_keys( $testFunctionInputs ), array_fill( 0, count( $testFunctionInputs ), 0 ) );
|
||||
//array_product()
|
||||
$prod=1;
|
||||
foreach($testFunctionInputs as $values) $prod*=count($values);
|
||||
$lastCase=($prod==0);
|
||||
while(!$lastCase){
|
||||
$prod = 1;
|
||||
foreach ($testFunctionInputs as $values) {
|
||||
$prod *= count( $values );
|
||||
}
|
||||
$lastCase = ($prod == 0);
|
||||
while (! $lastCase) {
|
||||
//foreach($index as $v) echo($v);echo("\n");
|
||||
/* Put in $aux one test case */
|
||||
$aux=array();
|
||||
foreach($testFunctionInputs as $key => $values){
|
||||
$aux[$key]=$values[$index[$key]];
|
||||
$aux = array ();
|
||||
foreach ($testFunctionInputs as $key => $values) {
|
||||
$aux[$key] = $values[$index[$key]];
|
||||
}
|
||||
/* CREATE TEST CASE: Put $aux test case in $testCases array */
|
||||
$i=count($testCases);
|
||||
$i = count( $testCases );
|
||||
$testCases[$i] = $preTestCase;
|
||||
$testCases[$i]['Input']=$aux;
|
||||
$testCases[$i]['Input'] = $aux;
|
||||
/* Increse the $index key values to the next test case */
|
||||
$lastCase=true;
|
||||
foreach($testFunctionInputs as $key => $values){
|
||||
$index[$key]++;
|
||||
if ($index[$key]>=count($values)){
|
||||
$index[$key]=0;
|
||||
}
|
||||
else{
|
||||
$lastCase=false;
|
||||
$lastCase = true;
|
||||
foreach ($testFunctionInputs as $key => $values) {
|
||||
$index[$key] ++;
|
||||
if ($index[$key] >= count( $values )) {
|
||||
$index[$key] = 0;
|
||||
} else {
|
||||
$lastCase = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -140,11 +139,11 @@ class ymlTestCases
|
||||
/*End Block */
|
||||
}
|
||||
/* Start Block: Replace @@ tags variables */
|
||||
foreach($testCases as $key => $testCase){
|
||||
$testCases[$key]=testTools::replaceVariables( $testCases[$key] );
|
||||
$testCases[$key]['Input']=testTools::replaceVariables( $testCases[$key]['Input'], $fields );
|
||||
if (isset($testCase['Output'])){
|
||||
if (isset($testCase['Output']['Value'])) {
|
||||
foreach ($testCases as $key => $testCase) {
|
||||
$testCases[$key] = testTools::replaceVariables( $testCases[$key] );
|
||||
$testCases[$key]['Input'] = testTools::replaceVariables( $testCases[$key]['Input'], $fields );
|
||||
if (isset( $testCase['Output'] )) {
|
||||
if (isset( $testCase['Output']['Value'] )) {
|
||||
/*$testCases[$key]['Output']['Value'] =
|
||||
unserialize($testCases[$key]['Output']['Value']);*/
|
||||
}
|
||||
@@ -158,36 +157,37 @@ class ymlTestCases
|
||||
/**
|
||||
* function load
|
||||
* Increase the number of "planned" tests.
|
||||
*
|
||||
* @access public
|
||||
* @param int $count
|
||||
* @param int $start
|
||||
* @return void
|
||||
*/
|
||||
function addToPlan( $count=-1, $start=0 )
|
||||
public function addToPlan ($count = -1, $start = 0)
|
||||
{
|
||||
foreach($this->testCases as $testCase){
|
||||
if (($start==0) && ($count!=0)){
|
||||
if (isset($testCase['TODO'])){
|
||||
$this->testLime->plan++;
|
||||
}
|
||||
else{
|
||||
if(isset($testCase['Output'])){
|
||||
if ( isset($testCase['Output']['Type']) ||
|
||||
isset($testCase['Output']['Value']) )
|
||||
$this->testLime->plan++;
|
||||
foreach ($this->testCases as $testCase) {
|
||||
if (($start == 0) && ($count != 0)) {
|
||||
if (isset( $testCase['TODO'] )) {
|
||||
$this->testLime->plan ++;
|
||||
} else {
|
||||
if (isset( $testCase['Output'] )) {
|
||||
if (isset( $testCase['Output']['Type'] ) || isset( $testCase['Output']['Value'] )) {
|
||||
$this->testLime->plan ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$start--;
|
||||
if ($count>0)
|
||||
$count--;
|
||||
} else {
|
||||
$start --;
|
||||
if ($count > 0) {
|
||||
$count --;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* function run
|
||||
*
|
||||
* @access public
|
||||
* @param object $testerObject
|
||||
* @param array $fields
|
||||
@@ -195,65 +195,63 @@ class ymlTestCases
|
||||
* @param int $start
|
||||
* @return array
|
||||
*/
|
||||
function run( &$testerObject, $fields=array(), $count=-1, $start=0 )
|
||||
public function run (&$testerObject, $fields = array(), $count = -1, $start = 0)
|
||||
{
|
||||
$results=array();
|
||||
$results = array ();
|
||||
//$this->addToPlan( $count, $start );
|
||||
$functions=get_class_methods( get_class($testerObject) );
|
||||
foreach($functions as $id=>$fn)
|
||||
$functions[$id]=strtolower($fn);
|
||||
foreach($this->testCases as $index => $testCase){
|
||||
if (($start==0) && ($count!=0)){
|
||||
if (isset($testCase['TODO'])){
|
||||
$this->testLime->todo($testCase['TODO']);
|
||||
$functions = get_class_methods( get_class( $testerObject ) );
|
||||
foreach ($functions as $id => $fn) {
|
||||
$functions[$id] = strtolower( $fn );
|
||||
}
|
||||
else{
|
||||
if (isset($testCase['Function'])){
|
||||
if (array_search(strtolower($testCase['Function']),$functions)!==FALSE){
|
||||
$testCase['Input'] = G::array_merges( $testCase['Input'] , $fields );
|
||||
$result = eval('return $testerObject->'.$testCase['Function'].'($testCase, $testCase["Input"]);');
|
||||
$results[]=$result;
|
||||
foreach ($this->testCases as $index => $testCase) {
|
||||
if (($start == 0) && ($count != 0)) {
|
||||
if (isset( $testCase['TODO'] )) {
|
||||
$this->testLime->todo( $testCase['TODO'] );
|
||||
} else {
|
||||
if (isset( $testCase['Function'] )) {
|
||||
if (array_search( strtolower( $testCase['Function'] ), $functions ) !== false) {
|
||||
$testCase['Input'] = G::array_merges( $testCase['Input'], $fields );
|
||||
$result = eval( 'return $testerObject->' . $testCase['Function'] . '($testCase, $testCase["Input"]);' );
|
||||
$results[] = $result;
|
||||
/* Start Block: Test the $result */
|
||||
if (isset($testCase['Output'])){
|
||||
if (isset($testCase['Output']['Value'])){
|
||||
if (isset( $testCase['Output'] )) {
|
||||
if (isset( $testCase['Output']['Value'] )) {
|
||||
//$this->testLime->is( $result, $testCase['Output']['Value'], $testCase['Title'] );
|
||||
$this->testLime->todo( ($testCase['Output']['Type']) );
|
||||
$this->testLime->diag("/processmaker/trunk/gulliver/system/class.ymlTestCases.php at line 204");
|
||||
}
|
||||
elseif (isset($testCase['Output']['Type'])){
|
||||
$this->testLime->diag( "/processmaker/trunk/gulliver/system/class.ymlTestCases.php at line 204" );
|
||||
} elseif (isset( $testCase['Output']['Type'] )) {
|
||||
// $this->testLime->isa_ok( $result, $testCase['Output']['Type'], $testCase['Title'] );
|
||||
$this->testLime->todo( ($testCase['Output']['Type']) );
|
||||
$this->testLime->diag("/processmaker/trunk/gulliver/system/class.ymlTestCases.php at line 204");
|
||||
$this->testLime->diag( "/processmaker/trunk/gulliver/system/class.ymlTestCases.php at line 204" );
|
||||
}
|
||||
}
|
||||
/* End Block */
|
||||
} else {
|
||||
$this->testLime->fail( 'Case #' . $index . ': Test function (Function) is not present in tester object.' );
|
||||
}
|
||||
else{
|
||||
$this->testLime->fail( 'Case #'.$index.': Test function (Function) is not present in tester object.' );
|
||||
} else {
|
||||
$this->testLime->fail( 'Case #' . $index . ' doesn\'t have a test function (Function) defined.' );
|
||||
}
|
||||
}
|
||||
else{
|
||||
$this->testLime->fail( 'Case #'.$index.' doesn\'t have a test function (Function) defined.' );
|
||||
} else {
|
||||
$start --;
|
||||
if ($count > 0) {
|
||||
$count --;
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
$start--;
|
||||
if ($count>0)
|
||||
$count--;
|
||||
}
|
||||
}
|
||||
return $results;
|
||||
}
|
||||
|
||||
/**
|
||||
* function runSingle
|
||||
*
|
||||
* @access public
|
||||
* @param object $testerObject
|
||||
* @param array $fields
|
||||
* @return array
|
||||
*/
|
||||
function runSingle( &$testerObject, $fields=array() )
|
||||
public function runSingle (&$testerObject, $fields = array())
|
||||
{
|
||||
$results = $this->run( $testerObject, $fields, 1, 0 );
|
||||
return $results[0];
|
||||
@@ -261,6 +259,7 @@ class ymlTestCases
|
||||
|
||||
/**
|
||||
* function runMultiple
|
||||
*
|
||||
* @access public
|
||||
* @param object $testerObject
|
||||
* @param array $fields
|
||||
@@ -268,8 +267,9 @@ class ymlTestCases
|
||||
* @param int $start
|
||||
* @return array
|
||||
*/
|
||||
function runMultiple( &$testerObject, $fields=array(), $count = -1, $start=0)
|
||||
public function runMultiple (&$testerObject, $fields = array(), $count = -1, $start = 0)
|
||||
{
|
||||
return $this->run( $testerObject, $fields, $count, $start );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user