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

This commit is contained in:
Daniel Rojas
2014-04-07 09:03:27 -04:00
8 changed files with 187 additions and 26 deletions

View File

@@ -123,7 +123,10 @@
<target name="phpunit" description="Run unit tests with PHPUnit">
<exec executable="phpunit">
<arg path="${basedir}/workflow/engine/src" />
<arg value="--testsuite" />
<arg value="api" />
<arg value="--bootstrap" />
<arg value="${basedir}/workflow/engine/src/Tests/bootstrap.php" />
</exec>
</target>

View File

@@ -48,21 +48,21 @@ Scenario: Returns a list of the cases for the logged in user (Paused)
And the response has 12 records
Scenario: Returns information about a given case of the list Inbox
Given I request "cases/48177942153275bfa28bd04070312685"
Scenario: Returns information about a given case of the list Inbox of process "Derivation rules - Parallel"
Given I request "cases/220090038533b0c40688174019225585"
Then the response status code should be 200
And the response charset is "UTF-8"
And the type is "array"
And the "app_uid" property equals "48177942153275bfa28bd04070312685"
And the "app_number" property equals 16
And the "app_name" property equals "#16"
And the "app_uid" property equals "220090038533b0c40688174019225585"
And the "app_number" property equals 137
And the "app_name" property equals "#137"
And the "app_status" property equals "TO_DO"
And the "app_init_usr_uid" property equals "00000000000000000000000000000001"
And the "app_init_usr_username" property equals "Administrator"
And the "pro_uid" property equals "99209594750ec27ea338927000421575"
And the "pro_name" property equals "Derivation rules - sequential"
And the "app_create_date" property equals "2014-03-17 16:32:58"
And the "app_update_date" property equals "2014-03-17 16:33:01"
And the "pro_uid" property equals "35894775350ec7daa099378048029617"
And the "pro_name" property equals "Derivation rules - Parallel"
And the "app_create_date" property equals "2014-04-01 14:58:08"
And the "app_update_date" property equals "2014-04-01 14:58:20"
Scenario: Returns the current task for a given case of the list Inbox

View File

@@ -1,4 +1,4 @@
miche@ProcessMakerMichelangelo @RestAPI
@ProcessMakerMichelangelo @RestAPI
Feature: ProcessPermissions Resources
@1: TEST FOR GET PROCESS PERMISSIONS /----------------------------------------------------------------------

View File

@@ -3,6 +3,9 @@ namespace Maveriks\Extension;
use Luracast\Restler\Defaults;
use Luracast\Restler\Format\UrlEncodedFormat;
use ProcessMaker\Services\Api;
use Luracast\Restler\RestException;
/**
* Class Restler
* Extension Restler class to implement in ProcessMaker
@@ -103,4 +106,20 @@ class Restler extends \Luracast\Restler\Restler
}
return $includeQueryParameters ? $get : array(); //no body
}
/**
* This method call the function message
*
* @param RestException $e. Exception the error
*
* @access public
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
* @copyright Colosa - Bolivia
*
* @return void
*/
public function setMessage(RestException $e)
{
$this->message($e);
}
}

View File

@@ -3,6 +3,8 @@ namespace Maveriks;
use Maveriks\Util;
use ProcessMaker\Services;
use ProcessMaker\Services\Api;
use Luracast\Restler\RestException;
class WebApplication
{
@@ -106,10 +108,19 @@ class WebApplication
public function multipart($uri, $version = "1.0")
{
$stringInput = file_get_contents('php://input');
if (is_null($stringInput)) {
return array(); //no body
}
if (empty($stringInput)) {
$rest = new \Maveriks\Extension\Restler();
$rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart without body."));
exit();
} else {
$input = json_decode($stringInput);
if (empty($input->calls)) {
$rest = new \Maveriks\Extension\Restler();
$rest->setMessage(new RestException(Api::STAT_APP_EXCEPTION, "Invalid Request, multipart body without calls."));
exit();
}
}
$baseUrl = (empty($input->base_url)) ? $uri : $input->base_url;
foreach($input->calls as $value) {

View File

@@ -2,7 +2,7 @@
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
@@ -20,6 +20,9 @@
<directory>./tests/unit/</directory>
</testsuite>
-->
<testsuite name="api">
<directory>./workflow/engine/src/</directory>
</testsuite>
</testsuites>
<!-- <filter>

View File

@@ -35,7 +35,7 @@ debug = 1
report-Table = "ProcessMaker\Services\Api\Project\ReportTable"
sub-process= "ProcessMaker\Services\Api\Project\SubProcess"
trigger-wizard = "ProcessMaker\Services\Api\Project\TriggerWizard"
category = "ProcessMaker\Services\Api\ProcessCategory"
;category = "ProcessMaker\Services\Api\ProcessCategory"
[alias: projects]
project = "ProcessMaker\Services\Api\Project"

View File

@@ -12,26 +12,151 @@ if (!class_exists("Propel")) {
*/
class CalendarTest extends \PHPUnit_Framework_TestCase
{
public function testGetCalendars()
{
$calendar = new \ProcessMaker\BusinessModel\Calendar();
private static $calendar;
private static $numCalendar = 2;
$arrayCalendar = $calendar->getCalendars();
/**
* Set class for test
*
* @coversNothing
*/
public static function setUpBeforeClass()
{
self::$calendar = new \ProcessMaker\BusinessModel\Calendar();
}
/**
* Test create calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::create
*
* @return array
*/
public function testCreate()
{
$arrayRecord = array();
//Create
for ($i = 0; $i <= self::$numCalendar - 1; $i++) {
$arrayData = array(
"CAL_NAME" => "PHPUnit Calendar$i",
"CAL_DESCRIPTION" => "Description",
"CAL_WORK_DAYS" => array("MON", "TUE", "WED", "THU", "FRI"),
"CAL_STATUS" => "ACTIVE",
"CAL_WORK_HOUR" => array(
array("DAY" => "ALL", "HOUR_START" => "00:00", "HOUR_END" => "00:00"),
array("DAY" => "MON", "HOUR_START" => "09:00", "HOUR_END" => "17:00")
),
"CAL_HOLIDAY" => array(
array("NAME" => "holiday1", "DATE_START" => "2014-03-01", "DATE_END" => "2014-03-31"),
array("NAME" => "holiday2", "DATE_START" => "2014-03-01", "DATE_END" => "2014-03-31")
)
);
$arrayCalendar = self::$calendar->create($arrayData);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertTrue(isset($arrayCalendar["CAL_UID"]));
$arrayRecord[] = $arrayCalendar;
}
//Return
return $arrayRecord;
}
/**
* Test update calendars
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::update
*/
public function testUpdate($arrayRecord)
{
$arrayData = array("CAL_DESCRIPTION" => "Description...");
$arrayCalendar = self::$calendar->update($arrayRecord[1]["CAL_UID"], $arrayData);
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[1]["CAL_UID"]);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], $arrayData["CAL_DESCRIPTION"]);
}
/**
* Test get calendars
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendars
*/
public function testGetCalendars($arrayRecord)
{
$arrayCalendar = self::$calendar->getCalendars();
$this->assertNotEmpty($arrayCalendar);
$arrayCalendar = $calendar->getCalendars(null, null, null, 0, 0);
$arrayCalendar = self::$calendar->getCalendars(null, null, null, 0, 0);
$this->assertEmpty($arrayCalendar);
$arrayCalendar = $calendar->getCalendars(array("filter" => "Default"));
$arrayCalendar = self::$calendar->getCalendars(array("filter" => "PHPUnit"));
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertEquals($arrayCalendar[0]["CAL_UID"], "00000000000000000000000000000001");
$this->assertEquals($arrayCalendar[0]["CAL_NAME"], "Default");
$this->assertEquals($arrayCalendar[0]["CAL_DESCRIPTION"], "Default");
$this->assertEquals($arrayCalendar[0]["CAL_STATUS"], "ACTIVE");
$this->assertEquals($arrayCalendar[0]["CAL_UID"], $arrayRecord[0]["CAL_UID"]);
$this->assertEquals($arrayCalendar[0]["CAL_NAME"], $arrayRecord[0]["CAL_NAME"]);
$this->assertEquals($arrayCalendar[0]["CAL_DESCRIPTION"], $arrayRecord[0]["CAL_DESCRIPTION"]);
$this->assertEquals($arrayCalendar[0]["CAL_STATUS"], $arrayRecord[0]["CAL_STATUS"]);
}
/**
* Test get calendar
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendar
*/
public function testGetCalendar($arrayRecord)
{
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[0]["CAL_UID"]);
$this->assertTrue(is_array($arrayCalendar));
$this->assertNotEmpty($arrayCalendar);
$this->assertEquals($arrayCalendar["CAL_UID"], $arrayRecord[0]["CAL_UID"]);
$this->assertEquals($arrayCalendar["CAL_NAME"], $arrayRecord[0]["CAL_NAME"]);
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], $arrayRecord[0]["CAL_DESCRIPTION"]);
$this->assertEquals($arrayCalendar["CAL_STATUS"], $arrayRecord[0]["CAL_STATUS"]);
}
/**
* Test delete calendars
*
* @depends testCreate
* @param array $arrayRecord Data of the calendars
*
* @covers \ProcessMaker\BusinessModel\Calendar::delete
*/
public function testDelete($arrayRecord)
{
foreach ($arrayRecord as $value) {
self::$calendar->delete($value["CAL_UID"]);
}
$arrayCalendar = self::$calendar->getCalendars(array("filter" => "PHPUnit"));
$this->assertTrue(is_array($arrayCalendar));
$this->assertEmpty($arrayCalendar);
}
}