Merge remote branch 'upstream/master'
This commit is contained in:
171
tests/unit/backend/services/AppOwnerTest.php
Normal file
171
tests/unit/backend/services/AppOwnerTest.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/AppOwner.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class AppOwnerTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("741388075505cd6bba2e993094312973", "000000000000000000000000000002", "00000000000000000000000000000001");
|
||||
$table = "APP_OWNER";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312973"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("741388075505cd6bba2e993094312900", "000000000000000000000000000003", "00000000000000000000000000000001");
|
||||
$table = "APP_OWNER";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("741388075505cd6bba2e993094312900", "000000000000000000000000000003", "00000000000000000000000000000001");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312900"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("741388075505cd6bba2e993094312900", "000000000000000000000000000004", "00000000000000000000000000000001");
|
||||
$table = "APP_OWNER";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("741388075505cd6bba2e993094312900", "000000000000000000000000000004", "00000000000000000000000000000001");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312900"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("741388075505cd6bba2e993094312900", "000000000000000000000000000004", "00000000000000000000000000000001");
|
||||
$table = "APP_OWNER";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'APP_OWNER', 'SELECT * FROM APP_OWNER WHERE APP_UID = "741388075505cd6bba2e993094312900"'
|
||||
);
|
||||
|
||||
$resp = array();
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
}
|
||||
159
tests/unit/backend/services/ApplicationTest.php
Normal file
159
tests/unit/backend/services/ApplicationTest.php
Normal file
@@ -0,0 +1,159 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Application.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class ApplicationTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$APP_UID = array("741388075505cd6bba2e993094312973");
|
||||
$table = "APPLICATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$APP_UID);
|
||||
//$rest->displayResponse();
|
||||
|
||||
//Obtengo solo el campo q necesito del array
|
||||
//$ultimo = end( $resp );
|
||||
//$solo = object mysql_fetch_field ( resource $resp ['data'] );
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'APPLICATION', 'SELECT * FROM APPLICATION WHERE APP_UID = "741388075505cd6bba2e993094312973"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$APP_UID = array("4670755835065b7eb6a4187052654566", "2008", "", "DRAFT", "6548800755065a63d67f727063273525", "", "", "N", "00000000000000000000000000000001", "00000000000000000000000000000001", "2012-09-28 10:44:59", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "", "00a9357205f5ea2d9325e166092b0e3f");
|
||||
$table = "APPLICATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$APP_UID);
|
||||
$rest->displayResponse();
|
||||
|
||||
$ID = array("4670755835065b7eb6a4187052654566");
|
||||
$resp = $rest->sendGET($table,$ID);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'APPLICATION', 'SELECT * FROM APPLICATION WHERE APP_UID = "4670755835065b7eb6a4187052654566"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$APP_UID = array("4670755835065b7eb6a4187052654566", "2008", "", "DRAFT", "6548800755065a63d67f727063273525", "", "", "N", "00000000000000000000000000000001", "00000000000000000000000000000001", "2012-09-28 10:44:59", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "2012-09-28 12:11:58", "", "00a9357205f5ea2d9325e166092b0e3f");
|
||||
$table = "APPLICATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$APP_UID);
|
||||
//$rest->displayResponse();
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$APP_UID = array("4670755835065b7eb6a4187052654566");
|
||||
$table = "APPLICATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$APP_UID);
|
||||
//$rest->displayResponse();
|
||||
}
|
||||
}
|
||||
|
||||
176
tests/unit/backend/services/CalendarDefinitionTest.php
Normal file
176
tests/unit/backend/services/CalendarDefinitionTest.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/CalendarDefinition.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class CalendarDefinitionTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000001" );
|
||||
$table = "CalendarDefinition";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$key1 = array( "942663514792946220");
|
||||
$rest->sendGET($table,$key1);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CALENDAR_DEFINITION', 'SELECT * FROM CALENDAR_DEFINITION WHERE CALENDAR_UID = "00000000000000000000000000000001"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method,$msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000002", "Calendario Diario", "2012-09-17 13:00:04", "2012-09-17 13:01:06", "1", "horarios", "ACTIVE");
|
||||
//$table = "CALENDAR_DEFINITION";
|
||||
$table = "CalendarDefinition";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("00000000000000000000000000000002");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CALENDAR_DEFINITION', 'SELECT * FROM CALENDAR_DEFINITION WHERE CALENDAR_UID = "00000000000000000000000000000002"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR inserting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
/* $msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "9426635155057479305aa11012946220", "Calendario Empleados", "2012-09-17 12:00:04", "2012-09-17 12:01:06", "1|2|3|4|5", "Horarios laborales", "ACTIVE");
|
||||
$table = "CALENDAR_DEFINITION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("9426635155057479305aa11012946220");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CALENDAR_DEFINITION', 'SELECT * FROM CALENDAR_DEFINITION WHERE CALENDAR_UID = "66666635155057479305ab1101111111"'
|
||||
);
|
||||
|
||||
$this->assertEquals($queryTable, $resp, "ERROR updating data");*/
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("00000000000000000000000000000002");
|
||||
$table = "CalendarDefinition";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CALENDAR_DEFINITION', 'SELECT * FROM CALENDAR_DEFINITION WHERE CALENDAR_UID = "00000000000000000000000000000002"'
|
||||
);
|
||||
|
||||
$this->assertEquals($queryTable, $resp, "ERROR deleting data");
|
||||
}
|
||||
}
|
||||
|
||||
174
tests/unit/backend/services/ContentTest.php
Normal file
174
tests/unit/backend/services/ContentTest.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Content.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class ContentTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "PRO_TITLE", "", "6548800755065a63d67f727063273525", "en");
|
||||
$key1 = array( "PRO_DESCRIPTION", "", "4880075", "en");
|
||||
$table = "CONTENT";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
$rest->sendGET($table,$key1);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CONTENT', 'SELECT * FROM CONTENT WHERE CON_CATEGORY = "PRO_TITLE" AND CON_ID = "6548800755065a63d67f727063273525"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "PRO_TITLE", "", "6666000755065a63d67f727063273222", "en", "SAMPLE");
|
||||
$table = "CONTENT";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("PRO_TITLE", "", "6666000755065a63d67f727063273222", "en");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CONTENT', 'SELECT * FROM CONTENT WHERE CON_CATEGORY = "PRO_TITLE" AND CON_ID = "6666000755065a63d67f727063273222"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR inserting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "PRO_TITLE", "", "6666000755065a63d67f727063273222", "en", "XAMPLE");
|
||||
$table = "CONTENT";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("PRO_TITLE", "", "6666000755065a63d67f727063273222", "en");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CONTENT', 'SELECT * FROM CONTENT WHERE CON_CATEGORY = "PRO_TITLE" AND CON_ID = "6666000755065a63d67f727063273222"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR updating data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "PRO_TITLE", "", "6666000755065a63d67f727063273222", "en");
|
||||
$table = "CONTENT";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'CONTENT', 'SELECT * FROM CONTENT WHERE CON_CATEGORY = "PRO_TITLE" AND CON_ID = "6666000755065a63d67f727063273222"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR deleting data");
|
||||
}
|
||||
}
|
||||
|
||||
173
tests/unit/backend/services/ProcessTest.php
Normal file
173
tests/unit/backend/services/ProcessTest.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Process.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class ProcessTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "6548800755065a63d67f727063273525");
|
||||
$key1 = array( "8421281685065a");
|
||||
$table = "PROCESS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
$rest->sendGET($table,$key1);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'PROCESS', 'SELECT * FROM PROCESS WHERE PRO_UID = "6548800755065a63d67f727063273525"'
|
||||
);
|
||||
|
||||
$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "6548800755065a63d67f727063255555", "6548800755065a63d67f727063666665", "5", "HOURS", "ACTIVE", "0", "NORMAL", "FALSE", "1", "1", "1", "0", " ", " ", "1", "2012-09-28 09:29:33", "2012-09-28 09:29:33", "00000000000000000000000000000001", "5000", "10000", "0", "6", "0", " ", " " );
|
||||
$table = "PROCESS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("6548800755065a63d67f727063255555");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'PROCESS', 'SELECT * FROM PROCESS WHERE PRO_UID = "6548800755065a63d67f727063255555"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR inserting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "6548800755065a63d67f727063255555", "6548800755065a63d67f727063666665", "2", "DAYS", "ACTIVE", "0", "NORMAL", "FALSE", "1", "1", "1", "0", " ", " ", "1", "2012-09-28 09:29:33", "2012-09-28 09:29:33", "00000000000000000000000000000001", "5000", "10000", "0", "6", "0", " ", " " );
|
||||
$table = "PROCESS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("6548800755065a63d67f727063255555");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'PROCESS', 'SELECT * FROM PROCESS WHERE PRO_UID = "6548800755065a63d67f727063255555"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR updating data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("6548800755065a63d67f727063255555");
|
||||
$table = "PROCESS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'PROCESS', 'SELECT * FROM PROCESS WHERE PRO_UID = "6548800755065a63d67f727063255555"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR deleting data");
|
||||
}
|
||||
}
|
||||
204
tests/unit/backend/services/Rest/CRUD.java
Normal file
204
tests/unit/backend/services/Rest/CRUD.java
Normal file
@@ -0,0 +1,204 @@
|
||||
// Main class to sent differen kind of messages to the http server
|
||||
import org.apache.http.impl.client.DefaultHttpClient;
|
||||
|
||||
// Enter CRUD memebers
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
|
||||
|
||||
// Used to set JSON or XML messages request
|
||||
import org.apache.http.entity.StringEntity;
|
||||
|
||||
// Needed for response fetch goal
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
/**
|
||||
* Single class containing functions to show how to use GET,POST,PUT,DELETE methods.
|
||||
*/
|
||||
public class CRUD
|
||||
{
|
||||
private static String m_user = "workflow"; // This member variable must be changed to its own dev workspace
|
||||
|
||||
private static void PostSample()
|
||||
{
|
||||
System.out.println("POST: Enter login params\n");
|
||||
|
||||
String loginParamsXML = "<?xml version='1.0'?>\n"
|
||||
+"<request>\n"
|
||||
+"<user>admin</user>\n"
|
||||
+"<password>admin</password>\n"
|
||||
+"</request>";
|
||||
String URI = "http://"+m_user+".pmos.colosa.net/rest/"+m_user+"/login/";
|
||||
|
||||
System.out.println( "Request: "+URI + "\n"+ loginParamsXML + "\n");
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
HttpPost postRequest = new HttpPost(URI);
|
||||
try
|
||||
{
|
||||
StringEntity input = new StringEntity( loginParamsXML);
|
||||
input.setContentType("application/xml");
|
||||
postRequest.setEntity(input);
|
||||
HttpResponse httpResponse = httpClient.execute(postRequest);
|
||||
|
||||
HttpEntity responseEntity = httpResponse.getEntity();
|
||||
if( responseEntity != null)
|
||||
{
|
||||
String response = new String();
|
||||
response = EntityUtils.toString( responseEntity);
|
||||
System.out.println( "Response: " + response + "\n");
|
||||
}
|
||||
}
|
||||
catch( java.io.IOException x)
|
||||
{
|
||||
throw new RuntimeException("I/O error: " + x.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GetSample()
|
||||
{
|
||||
System.out.println("GET: Display TRANSLATION table row\n");
|
||||
|
||||
String URI = "http://"+m_user+".pmos.colosa.net/rest/"+m_user+"/TRANSLATION/LABEL/LOGIN/en/";
|
||||
System.out.println( "Request: " + URI + "\n");
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
HttpGet getRequest = new HttpGet(URI);
|
||||
try
|
||||
{
|
||||
HttpResponse httpResponse = httpClient.execute(getRequest);
|
||||
|
||||
HttpEntity responseEntity = httpResponse.getEntity();
|
||||
if( responseEntity != null)
|
||||
{
|
||||
String response = new String();
|
||||
response = EntityUtils.toString( responseEntity);
|
||||
System.out.println( "Response: " + response + "\n");
|
||||
}
|
||||
}
|
||||
catch( java.io.IOException x)
|
||||
{
|
||||
throw new RuntimeException("I/O error: " + x.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void AnotherPostSample()
|
||||
{
|
||||
System.out.println("POST: Insert new row in TRANLATION\n");
|
||||
|
||||
String URI = "http://"+m_user+".pmos.colosa.net/rest/"+m_user+"/TRANSLATION/";
|
||||
String newRow = "BUTTON/ESCAPE/en/sample/2012-05-05/";
|
||||
System.out.println( "Request: " + URI + " new row: " + newRow + "\n");
|
||||
URI = URI + newRow;
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
HttpPost postRequest = new HttpPost(URI);
|
||||
try
|
||||
{
|
||||
HttpResponse httpResponse = httpClient.execute(postRequest);
|
||||
|
||||
HttpEntity responseEntity = httpResponse.getEntity();
|
||||
if( responseEntity != null)
|
||||
{
|
||||
String response = new String();
|
||||
if(response.isEmpty())
|
||||
{
|
||||
System.out.println( "Response: Status code: " + httpResponse.getStatusLine().getStatusCode()+ "\n");
|
||||
return;
|
||||
}
|
||||
response = EntityUtils.toString( responseEntity);
|
||||
System.out.println( "Response: " + response + "\n");
|
||||
}
|
||||
}
|
||||
catch( java.io.IOException x)
|
||||
{
|
||||
throw new RuntimeException("I/O error: " + x.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void PutSample()
|
||||
{
|
||||
System.out.println("POST: Update a row in TRANLATION\n");
|
||||
|
||||
String URI = "http://"+m_user+".pmos.colosa.net/rest/"+m_user+"/TRANSLATION/";
|
||||
String index = "BUTTON/ESCAPE/en/";
|
||||
String updateData = "changesample/2011-07-06/";
|
||||
|
||||
System.out.println( "Request: " + URI + " index: " + index + " updateData: " + updateData + "\n");
|
||||
URI = URI + index + updateData;
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
HttpPut putRequest = new HttpPut(URI);
|
||||
try
|
||||
{
|
||||
HttpResponse httpResponse = httpClient.execute(putRequest);
|
||||
|
||||
HttpEntity responseEntity = httpResponse.getEntity();
|
||||
if( responseEntity != null)
|
||||
{
|
||||
String response = new String();
|
||||
if(response.isEmpty())
|
||||
{
|
||||
System.out.println( "Response: Status code: " + httpResponse.getStatusLine().getStatusCode()+ "\n");
|
||||
return;
|
||||
}
|
||||
response = EntityUtils.toString( responseEntity);
|
||||
System.out.println( "Response: " + response + "\n");
|
||||
}
|
||||
}
|
||||
catch( java.io.IOException x)
|
||||
{
|
||||
throw new RuntimeException("I/O error: " + x.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeleteSample()
|
||||
{
|
||||
System.out.println("DELETE: Remove a row in TRANLATION\n");
|
||||
|
||||
String URI = "http://"+m_user+".pmos.colosa.net/rest/"+m_user+"/TRANSLATION/";
|
||||
String index = "BUTTON/ESCAPE/en/";
|
||||
|
||||
System.out.println( "Request: " + URI + "index:" + index + "\n");
|
||||
URI = URI + index;
|
||||
|
||||
DefaultHttpClient httpClient = new DefaultHttpClient();
|
||||
HttpDelete deleteRequest = new HttpDelete(URI);
|
||||
try
|
||||
{
|
||||
HttpResponse httpResponse = httpClient.execute(deleteRequest);
|
||||
|
||||
HttpEntity responseEntity = httpResponse.getEntity();
|
||||
if( responseEntity != null)
|
||||
{
|
||||
String response = new String();
|
||||
if(response.isEmpty())
|
||||
{
|
||||
System.out.println( "Response: Status code: " + httpResponse.getStatusLine().getStatusCode()+ "\n");
|
||||
return;
|
||||
}
|
||||
response = EntityUtils.toString( responseEntity);
|
||||
System.out.println( "Response: " + response + "\n");
|
||||
}
|
||||
}
|
||||
catch( java.io.IOException x)
|
||||
{
|
||||
throw new RuntimeException("I/O error: " + x.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String args[])
|
||||
{
|
||||
System.out.println("CRUD samples.");
|
||||
PostSample();
|
||||
GetSample();
|
||||
AnotherPostSample();
|
||||
PutSample();
|
||||
DeleteSample();
|
||||
|
||||
}
|
||||
}
|
||||
149
tests/unit/backend/services/Rest/CURLMessage.php
Normal file
149
tests/unit/backend/services/Rest/CURLMessage.php
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
/**
|
||||
* Abstract class containing the CURL functionality, used to handle GET, POST, PUT and DELETE http methods.
|
||||
*
|
||||
* This class uses many different Curl functions, it would be great if this one gorws to allow the use of alll of them.
|
||||
*
|
||||
* @category Zend
|
||||
* @package ProcessMaker
|
||||
* @subpackage workflow
|
||||
* @copyright Copyright (c) ProcessMaker Colosa Inc.
|
||||
* @version Release: @2.0.44@
|
||||
* @since Class available since Release 2.0.44
|
||||
*/
|
||||
|
||||
//define('PATH_SEP', '/');
|
||||
define('COLON', ':');
|
||||
define('DOT', '.');
|
||||
define('PROTOCOL_HTTP', 'http');
|
||||
|
||||
/**
|
||||
* Abstract class, containing the CURL functionality, used to handle GET, POST, PUT and DELETE http methods.
|
||||
*/
|
||||
abstract class CURLMessage
|
||||
{
|
||||
protected $restServer; // e.g. "http://ralph.pmos.colosa.net/rest/ralph/"; host + technich dir + workspace
|
||||
protected $content = "Content-Type: application/"; //set the string used to attach next the kind of message to be handle.
|
||||
protected $serviceTechnic = "rest";// name of the current durectory where the rest methods are.
|
||||
protected $server_method; // used to set the name of the remote host and the Rest method to be called.
|
||||
protected $type; // contains the type of the message.
|
||||
protected $ch; //curl handle instance.
|
||||
protected $output; // contains the output returned by the curl_exec function.
|
||||
|
||||
/**
|
||||
* Setting the remote host and init the Curl handle options
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$serverDNS = explode(DOT,"jennylee.pmos.colosa.net");//$_SERVER['SERVER_NAME']);
|
||||
$serverDNS = array_reverse($serverDNS);
|
||||
$workspace = array_pop($serverDNS); //***aware this must contains the workspace name***
|
||||
|
||||
$this->restServer = PROTOCOL_HTTP . COLON.PATH_SEP . PATH_SEP;
|
||||
$this->restServer .= "jennylee.pmos.colosa.net"/*$_SERVER['SERVER_NAME'] */. PATH_SEP;
|
||||
$this->restServer .= $this->serviceTechnic . PATH_SEP . $workspace . PATH_SEP;
|
||||
|
||||
$this->ch = curl_init();
|
||||
curl_setopt($this->ch,CURLOPT_TIMEOUT, 2);
|
||||
curl_setopt($this->ch,CURLOPT_POST, 1);
|
||||
curl_setopt($this->ch,CURLOPT_RETURNTRANSFER, 1);
|
||||
}
|
||||
/**
|
||||
* set the message in order to follow the message format
|
||||
*/
|
||||
abstract protected function format(array $message);
|
||||
/**
|
||||
* Set properties used in a simpleMessage Class like a set in a URI, or formatted as a JSon msg.
|
||||
*/
|
||||
abstract protected function setMoreProperties($messageFormated);
|
||||
/**
|
||||
* Attach the method to the restServer path, set the type of the message, and the message itself.
|
||||
*/
|
||||
protected function setMessageProperties($method,array $message)
|
||||
{
|
||||
$messageFormated = $this->format($message);
|
||||
$this->server_method = $this->restServer . $method;
|
||||
$this->setMoreProperties($messageFormated);
|
||||
}
|
||||
/**
|
||||
* Send or execute(curl notation) the message using a rest method
|
||||
**/
|
||||
public function send($method,array $message)
|
||||
{
|
||||
self::setMessageProperties($method,$message);
|
||||
$this->output = curl_exec($this->ch);
|
||||
return $this->output;
|
||||
}
|
||||
/**
|
||||
* Set the message to GET method type
|
||||
*/
|
||||
public function sendGET($method,array $message)
|
||||
{
|
||||
curl_setopt($this->ch, CURLOPT_HTTPGET,true);
|
||||
return $this->send($method,$message);
|
||||
}
|
||||
/**
|
||||
* Set the message to POST method type
|
||||
*/
|
||||
public function sendPOST($method,array $message)
|
||||
{
|
||||
curl_setopt($this->ch,CURLOPT_POST,true);
|
||||
return $this->send($method,$message);
|
||||
}
|
||||
/**
|
||||
* Set the message to PUT method type
|
||||
*/
|
||||
public function sendPUT($method,array $message)
|
||||
{
|
||||
curl_setopt($this->ch,CURLOPT_PUT,true);
|
||||
return $this->send($method,$message);
|
||||
}
|
||||
/**
|
||||
* Set the message to DELETE method type
|
||||
*/
|
||||
public function sendDELETE($method,array $message)
|
||||
{
|
||||
curl_setopt($this->ch,CURLOPT_CUSTOMREQUEST,"DELETE");
|
||||
return $this->send($method,$message);
|
||||
}
|
||||
/**
|
||||
* Display all the data that the response could got.
|
||||
*/
|
||||
public function displayResponse()
|
||||
{
|
||||
$error = curl_error($this->ch);
|
||||
$result = array( 'header' => '',
|
||||
'body' => '',
|
||||
'curl_error' => '',
|
||||
'http_code' => '',
|
||||
'last_url' => '');
|
||||
if ($error != ""){
|
||||
$result['curl_error'] = $error;
|
||||
return $result;
|
||||
}
|
||||
$response = $this->output;
|
||||
$header_size = curl_getinfo($this->ch,CURLINFO_HEADER_SIZE);
|
||||
$result['header'] = substr($response,0,$header_size);
|
||||
$result['body'] = substr($response,$header_size);
|
||||
$result['http_code'] = curl_getinfo($this -> ch,CURLINFO_HTTP_CODE);
|
||||
$result['last_url'] = curl_getinfo($this -> ch,CURLINFO_EFFECTIVE_URL);
|
||||
|
||||
echo $this->type." Response: ".$response."<BR>";
|
||||
foreach($result as $index => $data)
|
||||
{
|
||||
if($data != ""){
|
||||
echo $index . "=" . $data . "<BR>";
|
||||
}
|
||||
}
|
||||
echo "<BR>";
|
||||
}
|
||||
/**
|
||||
* Close the Curl session using the Curl Handle set by curl_init() function.
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
curl_close($this->ch);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
46
tests/unit/backend/services/Rest/FormatedMessage.php
Normal file
46
tests/unit/backend/services/Rest/FormatedMessage.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
/**
|
||||
* Class defined to set all the configuration that XML, Json or other needs.
|
||||
*
|
||||
*
|
||||
* @category Zend
|
||||
* @package ProcessMaker
|
||||
* @subpackage workflow
|
||||
* @copyright Copyright (c) ProcessMaker Colosa Inc.
|
||||
* @version Release: @2.0.44@
|
||||
* @since Class available since Release 2.0.44
|
||||
*/
|
||||
|
||||
require_once("CURLMessage.php");
|
||||
|
||||
/**
|
||||
* Class defined to set all the configuration that XML, Json or other needs.
|
||||
*/
|
||||
class FormatedMessage extends CURLMessage
|
||||
{
|
||||
public function FormatedMessage()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Set the message in order to follow the message format, empty caused this class should not be instanced
|
||||
*/
|
||||
protected function format(array $message)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Setting CURL Url, Content and the message to be send
|
||||
*/
|
||||
protected function setMoreProperties($messageFormated)
|
||||
{
|
||||
//Please, remove this comment, is only for looging proposes.
|
||||
//
|
||||
echo "Request: " . $this->server_method . PATH_SEP . $messageFormated . " <br>";
|
||||
//
|
||||
curl_setopt($this->ch,CURLOPT_URL,$this->server_method);
|
||||
$contentSelected = $this->content . $this->type;
|
||||
curl_setopt($this->ch,CURLOPT_HTTPHEADER,array($contentSelected));
|
||||
curl_setopt($this->ch,CURLOPT_POSTFIELDS,$messageFormated);
|
||||
}
|
||||
}
|
||||
?>
|
||||
43
tests/unit/backend/services/Rest/JsonMessage.php
Normal file
43
tests/unit/backend/services/Rest/JsonMessage.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Class defined to be instanced and handle Json messages.
|
||||
*
|
||||
*
|
||||
* @category Zend
|
||||
* @package ProcessMaker
|
||||
* @subpackage workflow
|
||||
* @copyright Copyright (c) ProcessMaker Colosa Inc.
|
||||
* @version Release: @2.0.44@
|
||||
* @since Class available since Release 2.0.44
|
||||
*/
|
||||
|
||||
require_once("FormatedMessage.php");
|
||||
/**
|
||||
* Class defined to be instanced and handle Json messages
|
||||
*/
|
||||
class JsonMessage extends FormatedMessage
|
||||
{
|
||||
/**
|
||||
* Call the parent Curl initialization and set the type of the message
|
||||
*/
|
||||
public function JsonMessage()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->type = "json";
|
||||
}
|
||||
/**
|
||||
* Format the array parameter to a json format.
|
||||
*/
|
||||
protected function format(array $message)
|
||||
{
|
||||
if (empty($message)){
|
||||
return ;
|
||||
}
|
||||
if (is_array($message)){
|
||||
$jsonMessage = json_encode( $message);
|
||||
}
|
||||
return $jsonMessage;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
47
tests/unit/backend/services/Rest/RestMessage.php
Normal file
47
tests/unit/backend/services/Rest/RestMessage.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
* Class defined to be instanced and handle rest single parameters.
|
||||
*
|
||||
*
|
||||
* @category Zend
|
||||
* @package ProcessMaker
|
||||
* @subpackage workflow
|
||||
* @copyright Copyright (c) ProcessMaker Colosa Inc.
|
||||
* @version Release: @2.0.44@
|
||||
* @since Class available since Release 2.0.44
|
||||
*/
|
||||
|
||||
require_once("SimpleMessage.php");
|
||||
/**
|
||||
* Class defined to be instanced and handle rest single parameters
|
||||
*/
|
||||
class RestMessage extends SimpleMessage
|
||||
{
|
||||
/**
|
||||
* Call the parent Curl initialization and set the type of the message
|
||||
*/
|
||||
public function RestMessage()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->type = "rest";
|
||||
}
|
||||
/**
|
||||
* Format the array parameter to a single rest line format separed by '/'.
|
||||
*/
|
||||
protected function format(array $message)
|
||||
{
|
||||
$rest = "";
|
||||
if (!empty($message)){
|
||||
if (is_array($message)){
|
||||
foreach($message as $index => $data)
|
||||
{
|
||||
$rest .= "/" . $data;
|
||||
}
|
||||
$rest .= "/";
|
||||
}
|
||||
}
|
||||
return $rest;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
43
tests/unit/backend/services/Rest/SimpleMessage.php
Normal file
43
tests/unit/backend/services/Rest/SimpleMessage.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* Class defined to set enough curl configuration.
|
||||
*
|
||||
*
|
||||
* @category Zend
|
||||
* @package ProcessMaker
|
||||
* @subpackage workflow
|
||||
* @copyright Copyright (c) ProcessMaker Colosa Inc.
|
||||
* @version Release: @2.0.44@
|
||||
* @since Class available since Release 2.0.44
|
||||
*/
|
||||
|
||||
require_once("CURLMessage.php");
|
||||
|
||||
/**
|
||||
* Class defined to set enough curl configuration
|
||||
*/
|
||||
class SimpleMessage extends CURLMessage
|
||||
{
|
||||
public function SimpleMessage()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
/**
|
||||
* Set the message in order to follow the message format, empty caused this class should not be instanced
|
||||
*/
|
||||
protected function format(array $message)
|
||||
{
|
||||
}
|
||||
/**
|
||||
* Setting CURL Url, enough to attach a message.
|
||||
*/
|
||||
protected function setMoreProperties($messageFormated)
|
||||
{
|
||||
//Please, remove this comment, is only for looging proposes.
|
||||
//
|
||||
echo "Request: " . $this->server_method . PATH_SEP . $messageFormated . " <br>";
|
||||
//
|
||||
curl_setopt($this->ch,CURLOPT_URL,$this->server_method.$messageFormated);
|
||||
}
|
||||
}
|
||||
?>
|
||||
48
tests/unit/backend/services/Rest/XmlMessage.php
Normal file
48
tests/unit/backend/services/Rest/XmlMessage.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* Class defined to be instanced and handle XML format messages.
|
||||
*
|
||||
*
|
||||
* @category Zend
|
||||
* @package ProcessMaker
|
||||
* @subpackage workflow
|
||||
* @copyright Copyright (c) ProcessMaker Colosa Inc.
|
||||
* @version Release: @2.0.44@
|
||||
* @since Class available since Release 2.0.44
|
||||
*/
|
||||
|
||||
require_once("FormatedMessage.php");
|
||||
/**
|
||||
* Class defined to be instanced and handle XML format messages.
|
||||
*/
|
||||
class XmlMessage extends FormatedMessage
|
||||
{
|
||||
/**
|
||||
* Call the parent Curl initialization and set the type of the message
|
||||
*/
|
||||
public function XmlMessage()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->type = "xml";
|
||||
}
|
||||
/**
|
||||
* Format the array parameter to a xml valid format. TODO: Need to find out a better way to do it.
|
||||
*/
|
||||
protected function format(array $message)
|
||||
{
|
||||
if (empty($message)){
|
||||
return ;
|
||||
}
|
||||
if (is_array($message)){
|
||||
$xml = "<?xml version='1.0'?><request>";
|
||||
foreach($message as $index => $data)
|
||||
{
|
||||
$xml .= "<" . $index . ">" . $data . "</" . $index . ">";
|
||||
}
|
||||
$xml .= "</request>";
|
||||
}
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
33
tests/unit/backend/services/Rest/fixtures/application.xml
Normal file
33
tests/unit/backend/services/Rest/fixtures/application.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" ?>
|
||||
<dataset>
|
||||
<table name="SLA">
|
||||
<column>SLA_UID</column>
|
||||
<column>PRO_UID</column>
|
||||
<column>SLA_NAME</column>
|
||||
<column>SLA_DESCRIPTION</column>
|
||||
<column>SLA_TYPE</column>
|
||||
<column>SLA_TAS_START</column>
|
||||
<column>SLA_TAS_END</column>
|
||||
<column>SLA_TIME_DURATION</column>
|
||||
<column>SLA_TIME_DURATION_MODE</column>
|
||||
<column>SLA_CONDITIONS</column>
|
||||
<column>SLA_PEN_ENABLED</column>
|
||||
<column>SLA_PEN_TIME</column>
|
||||
<column>SLA_PEN_TIME_MODE</column>
|
||||
<column>SLA_PEN_VALUE</column>
|
||||
<column>SLA_PEN_VALUE_UNIT</column>
|
||||
<column>SLA_STATUS</column>
|
||||
</table>
|
||||
<table name="APP_SLA">
|
||||
<column>APP_UID</column>
|
||||
<column>SLA_UID</column>
|
||||
<column>APP_SLA_INIT_DATE</column>
|
||||
<column>APP_SLA_DUE_DATE</column>
|
||||
<column>APP_SLA_FINISH_DATE</column>
|
||||
<column>APP_SLA_DURATION</column>
|
||||
<column>APP_SLA_REMAINING</column>
|
||||
<column>APP_SLA_EXCEEDED</column>
|
||||
<column>APP_SLA_PEN_VALUE</column>
|
||||
<column>APP_SLA_STATUS</column>
|
||||
</table>
|
||||
</dataset>
|
||||
37
tests/unit/backend/services/Rest/testing.php
Normal file
37
tests/unit/backend/services/Rest/testing.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
require_once("JsonMessage.php");
|
||||
require_once("XmlMessage.php");
|
||||
require_once("RestMessage.php");
|
||||
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
$xmlm->displayResponse();
|
||||
|
||||
$msg0 = array( "LABEL", "LOGIN", "en");
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendGET($table,$msg0);
|
||||
$rest->displayResponse();
|
||||
|
||||
$msg1 = array( "HOUSE", "PUSHIN", "en", "sample", "2012-06-06" );
|
||||
$rest->sendPOST($table,$msg1);
|
||||
$rest->displayResponse();
|
||||
|
||||
$msg2 = array( "HOUSE", "PUSHIN", "en", "samplemod", "2012-07-06" );
|
||||
$rest->sendPUT($table,$msg2);
|
||||
$rest->displayResponse();
|
||||
|
||||
$msg3 = array( "HOUSE", "PUSHIN", "en");
|
||||
$rest->sendDELETE($table,$msg3);
|
||||
$rest->displayResponse();
|
||||
|
||||
?>
|
||||
173
tests/unit/backend/services/SessionTest.php
Normal file
173
tests/unit/backend/services/SessionTest.php
Normal file
@@ -0,0 +1,173 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Session.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class SessionTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "8421281685065aec01a7643096730466");
|
||||
$key1 = array( "8421281685065a");
|
||||
$table = "SESSION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
$rest->sendGET($table,$key1);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'SESSION', 'SELECT * FROM SESSION WHERE SES_UID = "8421281685065aec01a7643096730466"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "2252443815002e3c2422675066811111", "ACTIVE", "00000000000000000000000000000001", "192.168.11.21", "2012-10-09 10:05:52", "2012-10-09 10:20:52", "");
|
||||
$table = "SESSION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("2252443815002e3c2422675066811111");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'SESSION', 'SELECT * FROM SESSION WHERE SES_UID = "2252443815002e3c2422675066811111"'
|
||||
);
|
||||
|
||||
$this->assertEquals($queryTable, $resp, "ERROR inserting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "2252443815002e3c2422675066811111", "XAMPLE", "00000000000000000000000000000001", "192.168.11.21", "2012-10-09 10:05:52", "2012-10-09 10:20:52", "");
|
||||
$table = "SESSION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("2252443815002e3c2422675066811111");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'SESSION', 'SELECT * FROM SESSION WHERE SES_UID = "2252443815002e3c2422675066811111"'
|
||||
);
|
||||
|
||||
$this->assertEquals($queryTable, $resp, "ERROR updating data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("2252443815002e3c2422675066811111");
|
||||
$table = "SESSION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'SESSION', 'SELECT * FROM SESSION WHERE SES_UID = "2252443815002e3c2422675066811111"'
|
||||
);
|
||||
|
||||
$this->assertEquals($queryTable, $resp, "ERROR deleting data");
|
||||
}
|
||||
}
|
||||
171
tests/unit/backend/services/StepTest.php
Normal file
171
tests/unit/backend/services/StepTest.php
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Step.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class StepTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "440848627503b77c71a9637072432170");
|
||||
$table = "STEP";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'STEP', 'SELECT * FROM STEP WHERE STEP_UID = "440848627503b77c71a9637072432170"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "440848627503b77c71a9637074444444", "359728002502a792a568a54012111111", "499115418502a795a0cfb43043666666", "SAMPLE", "913768259503b76894536b2095222222", "", "1", "EDIT");
|
||||
$table = "STEP";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("440848627503b77c71a9637074444444");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'STEP', 'SELECT * FROM STEP WHERE STEP_UID = "440848627503b77c71a9637074444444"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR inserting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "440848627503b77c71a9637074444444", "359728002502a792a568a54012111111", "499115418502a795a0cfb43043666666", "XAMPLE", "913768259503b76894536b2095222222", "", "1", "VIEW");
|
||||
$table = "STEP";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("440848627503b77c71a9637074444444");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'STEP', 'SELECT * FROM STEP WHERE STEP_UID = "440848627503b77c71a9637074444444"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR updating data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("440848627503b77c71a9637074444444");
|
||||
$table = "STEP";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'STEP', 'SELECT * FROM STEP WHERE STEP_UID = "440848627503b77c71a9637074444444"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
}
|
||||
|
||||
169
tests/unit/backend/services/TranslationTest.php
Normal file
169
tests/unit/backend/services/TranslationTest.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Translation.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class TraslationTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "LABEL", "LOGIN", "en");
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "LABEL" AND TRN_ID = "LOGIN"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $key, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "HOUSE", "PUSHIN", "en", "sample", "2012-06-06" );
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("HOUSE", "PUSHIN", "en");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("HOUSE", "PUSHIN", "en", "samplemod", "2012-07-06");
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("HOUSE", "PUSHIN", "en");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("HOUSE", "PUSHIN", "en");
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
}
|
||||
169
tests/unit/backend/services/UsersPropertiesTest.php
Normal file
169
tests/unit/backend/services/UsersPropertiesTest.php
Normal file
@@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/UsersProperties.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class UsersPropertiesTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000001");
|
||||
$table = "USERS_PROPERTIES";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'USERS_PROPERTIES', 'SELECT * FROM USERS_PROPERTIES WHERE USR_UID = "00000000000000000000000000000001"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000002", "2012-09-04 09:48:57", "0", 'a:1:{i:0;s:32:"21232f297a57a5a743894a0e4a801fc3";}');
|
||||
$table = "USERS_PROPERTIES";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("00000000000000000000000000000002");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'USERS_PROPERTIES', 'SELECT * FROM USERS_PROPERTIES WHERE USR_UID = "00000000000000000000000000000002"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
/* $msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("HOUSE", "PUSHIN", "en", "samplemod", "2012-07-06");
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("HOUSE", "PUSHIN", "en");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");*/
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
/* $msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("HOUSE", "PUSHIN", "en");
|
||||
$table = "TRANSLATION";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'TRANSLATION', 'SELECT * FROM TRANSLATION WHERE TRN_CATEGORY = "HOUSE" AND TRN_ID = "PUSHIN"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR getting data");*/
|
||||
}
|
||||
}
|
||||
177
tests/unit/backend/services/UsersTest.php
Normal file
177
tests/unit/backend/services/UsersTest.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
|
||||
if (!defined('PATH_SEP')) {
|
||||
define('PATH_SEP', '/');
|
||||
}
|
||||
|
||||
require_once PATH_HOME . 'engine/services/rest/crud/Users.php';
|
||||
require_once("Rest/JsonMessage.php");
|
||||
require_once("Rest/XmlMessage.php");
|
||||
require_once("Rest/RestMessage.php");
|
||||
|
||||
class UsersTest extends PHPUnit_Extensions_Database_TestCase
|
||||
{
|
||||
public function setup()
|
||||
{
|
||||
}
|
||||
|
||||
protected function getTearDownOperation()
|
||||
{
|
||||
return PHPUnit_Extensions_Database_Operation_Factory::DELETE_ALL();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PHPUnit_Extensions_Database_DB_IDatabaseConnection
|
||||
*/
|
||||
|
||||
// only instantiate pdo once for test clean-up/fixture load
|
||||
static private $pdo = null;
|
||||
// only instantiate PHPUnit_Extensions_Database_DB_IDatabaseConnection once per test
|
||||
private $conn = null;
|
||||
|
||||
public function getConnection()
|
||||
{
|
||||
if ($this->conn === null) {
|
||||
$dsn = 'mysql:dbname=' . $_SERVER['PM_UNIT_DB_NAME'] . ';host='. $_SERVER['PM_UNIT_DB_HOST'];
|
||||
if (self::$pdo == null) {
|
||||
self::$pdo = new PDO(
|
||||
$dsn,
|
||||
$_SERVER['PM_UNIT_DB_USER'],
|
||||
$_SERVER['PM_UNIT_DB_PASS'] );
|
||||
}
|
||||
$this->conn = $this->createDefaultDBConnection(self::$pdo, $_SERVER['PM_UNIT_DB_NAME']);
|
||||
}
|
||||
return $this->conn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return PHPUnit_Extensions_Database_DataSet_IDataSet
|
||||
*/
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet('tests/unit/backend/services/Rest/fixtures/application.xml');
|
||||
}
|
||||
|
||||
public function testGet()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000001" );
|
||||
$table = "USERS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$key1 = array( "942663514792946220");
|
||||
$rest->sendGET($table,$key1);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'USERS', 'SELECT * FROM USERS WHERE USR_UID = "00000000000000000000000000000001"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($resp, $queryTable, "ERROR getting data");
|
||||
}
|
||||
|
||||
public function testPost()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method,$msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000002", "admin", "21232f297a57a5a743894a0e4a801fc3",
|
||||
"Administrator", "Adminn", "admin@processmaker.com", "2020-01-01", "1999-11-30 00:00:00",
|
||||
"2008-05-23 18:36:19", "ACTIVE", "US", "FL", "MMK", "Miraflores", "2240448", "1-305-402-0282",
|
||||
"1-305-675-1400", "", "", "Administrator", "", "1999-02-25", "PROCESSMAKER_ADMIN",
|
||||
"", "", "NORMAL");
|
||||
$table = "Users";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPOST($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("00000000000000000000000000000002");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'USERS', 'SELECT * FROM USERS WHERE USR_UID = "00000000000000000000000000000002"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR inserting data");
|
||||
}
|
||||
|
||||
public function testPut()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array( "00000000000000000000000000000002", "adminsad", "21232f297a57a5a743894a0e4a801fc3", "Administrator", "adminsad@processmaker.com", "2020-01-01", "1999-11-30 00:00:00", "2008-05-23 18:36:19", "ACTIVE", "US", "FL", "MMK", "", "", "1-305-402-0282", "1-305-675-1400", "", "", "Administrator", "", "1999-02-25", "PROCESSMAKER_ADMIN", "", "", "NORMAL");
|
||||
$table = "USERS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendPUT($table,$key);
|
||||
//$rest->displayResponse();
|
||||
|
||||
$key1 = array("00000000000000000000000000000002");
|
||||
$resp = $rest->sendGET($table,$key1);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'USERS', 'SELECT * FROM USERS WHERE USR_UID = "00000000000000000000000000000002"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR updating data");
|
||||
}
|
||||
|
||||
public function testDelete()
|
||||
{
|
||||
$msg = array( 'user'=>'admin' , 'password'=>'admin');
|
||||
$method = "login";
|
||||
|
||||
$jsonm = new JsonMessage();
|
||||
$jsonm->send($method,$msg);
|
||||
//$jsonm->displayResponse();
|
||||
|
||||
$xmlm = new XmlMessage();
|
||||
$xmlm->send($method, $msg);
|
||||
//$xmlm->displayResponse();
|
||||
|
||||
$key = array("00000000000000000000000000000002");
|
||||
$table = "USERS";
|
||||
|
||||
$rest = new RestMessage();
|
||||
$rest->sendDELETE($table,$key);
|
||||
//$rest->displayResponse();
|
||||
$resp = $rest->sendGET($table,$key);
|
||||
|
||||
$queryTable = $this->getConnection()->createQueryTable(
|
||||
'USERS', 'SELECT * FROM USERS WHERE USR_UID = "00000000000000000000000000000002"'
|
||||
);
|
||||
|
||||
//$this->assertEquals($queryTable, $resp, "ERROR deleting data");
|
||||
}
|
||||
}
|
||||
@@ -3390,7 +3390,7 @@ class Processes {
|
||||
}
|
||||
$client = @new SoapClient($endpoint, $proxy);
|
||||
} catch (Exception $e) {
|
||||
throw ( new Exception ( $e->message ) );
|
||||
throw ( new Exception ( $e->getMessage() ) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1010,10 +1010,6 @@ class System {
|
||||
|
||||
if ($_SESSION['PROCESSMAKER_ENV_HASH'] === $hash) {
|
||||
$_SESSION['PROCESSMAKER_ENV']['from_cache'] = 1;
|
||||
if (!isset($_SESSION['PROCESSMAKER_ENV']['proxy_pass'])) {
|
||||
$_SESSION['PROCESSMAKER_ENV']['proxy_pass'] = '';
|
||||
}
|
||||
$_SESSION['PROCESSMAKER_ENV']['proxy_pass'] = G::decrypt($_SESSION['PROCESSMAKER_ENV']['proxy_pass'], 'proxy_pass');
|
||||
return $_SESSION['PROCESSMAKER_ENV'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -322,6 +322,7 @@ class Content extends BaseContent {
|
||||
or die ("Could not connect");
|
||||
|
||||
mysql_select_db($workSpace->dbName, $link);
|
||||
mysql_query("SET NAMES 'utf8';");
|
||||
mysql_query('SET OPTION SQL_BIG_SELECTS=1');
|
||||
$result = mysql_unbuffered_query($sql, $link);
|
||||
$list = array();
|
||||
|
||||
@@ -39,6 +39,7 @@ class Services_Rest_AppDocument
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_TAGS);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_STATUS);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_STATUS_DATE);
|
||||
$criteria->addSelectColumn(AppDocumentPeer::APP_DOC_FIELDNAME);
|
||||
|
||||
$dataset = AppEventPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
@@ -61,5 +61,77 @@ class Services_Rest_AppOwner
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $ownUid, $usrUid)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppOwner();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setOwnUid($ownUid);
|
||||
$obj->setUsrUid($usrUid);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $ownUid, $usrUid)
|
||||
{
|
||||
try {
|
||||
$obj = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
|
||||
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $ownUid, $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $ownUid, $usrUid)
|
||||
{
|
||||
$conn = Propel::getConnection(AppOwnerPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppOwnerPeer::retrieveByPK($appUid, $ownUid, $usrUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -63,5 +63,82 @@ class Services_Rest_AppThread
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $appThreadIndex, $appThreadParent, $appThreadStatus, $delIndex)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new AppThread();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppThreadIndex($appThreadIndex);
|
||||
$obj->setAppThreadParent($appThreadParent);
|
||||
$obj->setAppThreadStatus($appThreadStatus);
|
||||
$obj->setDelIndex($delIndex);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $appThreadIndex, $appThreadParent, $appThreadStatus, $delIndex)
|
||||
{
|
||||
try {
|
||||
$obj = AppThreadPeer::retrieveByPK($appUid, $appThreadIndex);
|
||||
|
||||
$obj->setAppThreadParent($appThreadParent);
|
||||
$obj->setAppThreadStatus($appThreadStatus);
|
||||
$obj->setDelIndex($delIndex);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid, $appThreadIndex Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid, $appThreadIndex)
|
||||
{
|
||||
$conn = Propel::getConnection(AppThreadPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = AppThreadPeer::retrieveByPK($appUid, $appThreadIndex);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -74,5 +74,105 @@ class Services_Rest_Application
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Application();
|
||||
|
||||
$obj->setAppUid($appUid);
|
||||
$obj->setAppNumber($appNumber);
|
||||
$obj->setAppParent($appParent);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAppProcStatus($appProcStatus);
|
||||
$obj->setAppProcCode($appProcCode);
|
||||
$obj->setAppParallel($appParallel);
|
||||
$obj->setAppInitUser($appInitUser);
|
||||
$obj->setAppCurUser($appCurUser);
|
||||
$obj->setAppCreateDate($appCreateDate);
|
||||
$obj->setAppInitDate($appInitDate);
|
||||
$obj->setAppFinishDate($appFinishDate);
|
||||
$obj->setAppUpdateDate($appUpdateDate);
|
||||
$obj->setAppData($appData);
|
||||
$obj->setAppPin($appPin);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($appUid, $appNumber, $appParent, $appStatus, $proUid, $appProcStatus, $appProcCode, $appParallel, $appInitUser, $appCurUser, $appCreateDate, $appInitDate, $appFinishDate, $appUpdateDate, $appData, $appPin)
|
||||
{
|
||||
try {
|
||||
$obj = ApplicationPeer::retrieveByPK($appUid);
|
||||
|
||||
$obj->setAppNumber($appNumber);
|
||||
$obj->setAppParent($appParent);
|
||||
$obj->setAppStatus($appStatus);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setAppProcStatus($appProcStatus);
|
||||
$obj->setAppProcCode($appProcCode);
|
||||
$obj->setAppParallel($appParallel);
|
||||
$obj->setAppInitUser($appInitUser);
|
||||
$obj->setAppCurUser($appCurUser);
|
||||
$obj->setAppCreateDate($appCreateDate);
|
||||
$obj->setAppInitDate($appInitDate);
|
||||
$obj->setAppFinishDate($appFinishDate);
|
||||
$obj->setAppUpdateDate($appUpdateDate);
|
||||
$obj->setAppData($appData);
|
||||
$obj->setAppPin($appPin);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $appUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($appUid)
|
||||
{
|
||||
$conn = Propel::getConnection(ApplicationPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = ApplicationPeer::retrieveByPK($appUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -65,5 +65,87 @@ class Services_Rest_CalendarDefinition
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($calendarUid, $calendarName, $calendarCreateDate, $calendarUpdateDate, $calendarWorkDays, $calendarDescription, $calendarStatus)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new CalendarDefinition();
|
||||
|
||||
$obj->setCalendarUid($calendarUid);
|
||||
$obj->setCalendarName($calendarName);
|
||||
$obj->setCalendarCreateDate($calendarCreateDate);
|
||||
$obj->setCalendarUpdateDate($calendarUpdateDate);
|
||||
$obj->setCalendarWorkDays($calendarWorkDays);
|
||||
$obj->setCalendarDescription($calendarDescription);
|
||||
$obj->setCalendarStatus($calendarStatus);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($calendarUid, $calendarName, $calendarCreateDate, $calendarUpdateDate, $calendarWorkDays, $calendarDescription, $calendarStatus)
|
||||
{
|
||||
try {
|
||||
$obj = CalendarDefinitionPeer::retrieveByPK($calendarUid);
|
||||
|
||||
$obj->setCalendarName($calendarName);
|
||||
$obj->setCalendarCreateDate($calendarCreateDate);
|
||||
$obj->setCalendarUpdateDate($calendarUpdateDate);
|
||||
$obj->setCalendarWorkDays($calendarWorkDays);
|
||||
$obj->setCalendarDescription($calendarDescription);
|
||||
$obj->setCalendarStatus($calendarStatus);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $calendarUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($calendarUid)
|
||||
{
|
||||
$conn = Propel::getConnection(CalendarDefinitionPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = CalendarDefinitionPeer::retrieveByPK($calendarUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -63,5 +63,80 @@ class Services_Rest_Content
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $conCategory, $conParent, $conId, $conLang Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($conCategory, $conParent, $conId, $conLang, $conValue)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Content();
|
||||
|
||||
$obj->setConCategory($conCategory);
|
||||
$obj->setConParent($conParent);
|
||||
$obj->setConId($conId);
|
||||
$obj->setConLang($conLang);
|
||||
$obj->setConValue($conValue);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $conCategory, $conParent, $conId, $conLang Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($conCategory, $conParent, $conId, $conLang, $conValue)
|
||||
{
|
||||
try {
|
||||
$obj = ContentPeer::retrieveByPK($conCategory, $conParent, $conId, $conLang);
|
||||
|
||||
$obj->setConValue($conValue);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $conCategory, $conParent, $conId, $conLang Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($conCategory, $conParent, $conId, $conLang)
|
||||
{
|
||||
$conn = Propel::getConnection(ContentPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = ContentPeer::retrieveByPK($conCategory, $conParent, $conId, $conLang);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -61,5 +61,79 @@ class Services_Rest_Holiday
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $hldUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($hldUid, $hldDate, $hldDescription)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Holiday();
|
||||
|
||||
$obj->setHldUid($hldUid);
|
||||
$obj->setHldDate($hldDate);
|
||||
$obj->setHldDescription($hldDescription);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $hldUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($hldUid, $hldDate, $hldDescription)
|
||||
{
|
||||
try {
|
||||
$obj = HolidayPeer::retrieveByPK($hldUid);
|
||||
|
||||
$obj->setHldDate($hldDate);
|
||||
$obj->setHldDescription($hldDescription);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $hldUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($hldUid)
|
||||
{
|
||||
$conn = Propel::getConnection(HolidayPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = HolidayPeer::retrieveByPK($hldUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -83,5 +83,123 @@ class Services_Rest_Process
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($proUid, $proParent, $proTime, $proTimeunit, $proStatus, $proTypeDay, $proType, $proAssignment, $proShowMap, $proShowMessage, $proShowDelegate, $proShowDynaform, $proCategory, $proSubCategory, $proIndustry, $proUpdateDate, $proCreateDate, $proCreateUser, $proHeight, $proWidth, $proTitleX, $proTitleY, $proDebug, $proDynaforms, $proDerivationScreenTpl)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Process();
|
||||
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setProParent($proParent);
|
||||
$obj->setProTime($proTime);
|
||||
$obj->setProTimeunit($proTimeunit);
|
||||
$obj->setProStatus($proStatus);
|
||||
$obj->setProTypeDay($proTypeDay);
|
||||
$obj->setProType($proType);
|
||||
$obj->setProAssignment($proAssignment);
|
||||
$obj->setProShowMap($proShowMap);
|
||||
$obj->setProShowMessage($proShowMessage);
|
||||
$obj->setProShowDelegate($proShowDelegate);
|
||||
$obj->setProShowDynaform($proShowDynaform);
|
||||
$obj->setProCategory($proCategory);
|
||||
$obj->setProSubCategory($proSubCategory);
|
||||
$obj->setProIndustry($proIndustry);
|
||||
$obj->setProUpdateDate($proUpdateDate);
|
||||
$obj->setProCreateDate($proCreateDate);
|
||||
$obj->setProCreateUser($proCreateUser);
|
||||
$obj->setProHeight($proHeight);
|
||||
$obj->setProWidth($proWidth);
|
||||
$obj->setProTitleX($proTitleX);
|
||||
$obj->setProTitleY($proTitleY);
|
||||
$obj->setProDebug($proDebug);
|
||||
$obj->setProDynaforms($proDynaforms);
|
||||
$obj->setProDerivationScreenTpl($proDerivationScreenTpl);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($proUid, $proParent, $proTime, $proTimeunit, $proStatus, $proTypeDay, $proType, $proAssignment, $proShowMap, $proShowMessage, $proShowDelegate, $proShowDynaform, $proCategory, $proSubCategory, $proIndustry, $proUpdateDate, $proCreateDate, $proCreateUser, $proHeight, $proWidth, $proTitleX, $proTitleY, $proDebug, $proDynaforms, $proDerivationScreenTpl)
|
||||
{
|
||||
try {
|
||||
$obj = ProcessPeer::retrieveByPK($proUid);
|
||||
|
||||
$obj->setProParent($proParent);
|
||||
$obj->setProTime($proTime);
|
||||
$obj->setProTimeunit($proTimeunit);
|
||||
$obj->setProStatus($proStatus);
|
||||
$obj->setProTypeDay($proTypeDay);
|
||||
$obj->setProType($proType);
|
||||
$obj->setProAssignment($proAssignment);
|
||||
$obj->setProShowMap($proShowMap);
|
||||
$obj->setProShowMessage($proShowMessage);
|
||||
$obj->setProShowDelegate($proShowDelegate);
|
||||
$obj->setProShowDynaform($proShowDynaform);
|
||||
$obj->setProCategory($proCategory);
|
||||
$obj->setProSubCategory($proSubCategory);
|
||||
$obj->setProIndustry($proIndustry);
|
||||
$obj->setProUpdateDate($proUpdateDate);
|
||||
$obj->setProCreateDate($proCreateDate);
|
||||
$obj->setProCreateUser($proCreateUser);
|
||||
$obj->setProHeight($proHeight);
|
||||
$obj->setProWidth($proWidth);
|
||||
$obj->setProTitleX($proTitleX);
|
||||
$obj->setProTitleY($proTitleY);
|
||||
$obj->setProDebug($proDebug);
|
||||
$obj->setProDynaforms($proDynaforms);
|
||||
$obj->setProDerivationScreenTpl($proDerivationScreenTpl);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $proUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($proUid)
|
||||
{
|
||||
$conn = Propel::getConnection(ProcessPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = ProcessPeer::retrieveByPK($proUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -65,5 +65,87 @@ class Services_Rest_Session
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $sesUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($sesUid, $sesStatus, $usrUid, $sesRemoteIp, $sesInitDate, $sesDueDate, $sesEndDate)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Session();
|
||||
|
||||
$obj->setSesUid($sesUid);
|
||||
$obj->setSesStatus($sesStatus);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setSesRemoteIp($sesRemoteIp);
|
||||
$obj->setSesInitDate($sesInitDate);
|
||||
$obj->setSesDueDate($sesDueDate);
|
||||
$obj->setSesEndDate($sesEndDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $sesUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($sesUid, $sesStatus, $usrUid, $sesRemoteIp, $sesInitDate, $sesDueDate, $sesEndDate)
|
||||
{
|
||||
try {
|
||||
$obj = SessionPeer::retrieveByPK($sesUid);
|
||||
|
||||
$obj->setSesStatus($sesStatus);
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setSesRemoteIp($sesRemoteIp);
|
||||
$obj->setSesInitDate($sesInitDate);
|
||||
$obj->setSesDueDate($sesDueDate);
|
||||
$obj->setSesEndDate($sesEndDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $sesUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($sesUid)
|
||||
{
|
||||
$conn = Propel::getConnection(SessionPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = SessionPeer::retrieveByPK($sesUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -66,5 +66,89 @@ class Services_Rest_Step
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $stepUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($stepUid, $proUid, $tasUid, $stepTypeObj, $stepUidObj, $stepCondition, $stepPosition, $stepMode)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Step();
|
||||
|
||||
$obj->setStepUid($stepUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setStepTypeObj($stepTypeObj);
|
||||
$obj->setStepUidObj($stepUidObj);
|
||||
$obj->setStepCondition($stepCondition);
|
||||
$obj->setStepPosition($stepPosition);
|
||||
$obj->setStepMode($stepMode);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $stepUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($stepUid, $proUid, $tasUid, $stepTypeObj, $stepUidObj, $stepCondition, $stepPosition, $stepMode)
|
||||
{
|
||||
try {
|
||||
$obj = StepPeer::retrieveByPK($stepUid);
|
||||
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setStepTypeObj($stepTypeObj);
|
||||
$obj->setStepUidObj($stepUidObj);
|
||||
$obj->setStepCondition($stepCondition);
|
||||
$obj->setStepPosition($stepPosition);
|
||||
$obj->setStepMode($stepMode);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $stepUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($stepUid)
|
||||
{
|
||||
$conn = Propel::getConnection(StepPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = StepPeer::retrieveByPK($stepUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -70,5 +70,97 @@ class Services_Rest_SubProcess
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $spUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($spUid, $proUid, $tasUid, $proParent, $tasParent, $spType, $spSynchronous, $spSynchronousType, $spSynchronousWait, $spVariablesOut, $spVariablesIn, $spGridIn)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new SubProcess();
|
||||
|
||||
$obj->setSpUid($spUid);
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setProParent($proParent);
|
||||
$obj->setTasParent($tasParent);
|
||||
$obj->setSpType($spType);
|
||||
$obj->setSpSynchronous($spSynchronous);
|
||||
$obj->setSpSynchronousType($spSynchronousType);
|
||||
$obj->setSpSynchronousWait($spSynchronousWait);
|
||||
$obj->setSpVariablesOut($spVariablesOut);
|
||||
$obj->setSpVariablesIn($spVariablesIn);
|
||||
$obj->setSpGridIn($spGridIn);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $spUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($spUid, $proUid, $tasUid, $proParent, $tasParent, $spType, $spSynchronous, $spSynchronousType, $spSynchronousWait, $spVariablesOut, $spVariablesIn, $spGridIn)
|
||||
{
|
||||
try {
|
||||
$obj = SubProcessPeer::retrieveByPK($spUid);
|
||||
|
||||
$obj->setProUid($proUid);
|
||||
$obj->setTasUid($tasUid);
|
||||
$obj->setProParent($proParent);
|
||||
$obj->setTasParent($tasParent);
|
||||
$obj->setSpType($spType);
|
||||
$obj->setSpSynchronous($spSynchronous);
|
||||
$obj->setSpSynchronousType($spSynchronousType);
|
||||
$obj->setSpSynchronousWait($spSynchronousWait);
|
||||
$obj->setSpVariablesOut($spVariablesOut);
|
||||
$obj->setSpVariablesIn($spVariablesIn);
|
||||
$obj->setSpGridIn($spGridIn);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $spUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($spUid)
|
||||
{
|
||||
$conn = Propel::getConnection(SubProcessPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = SubProcessPeer::retrieveByPK($spUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ class Services_Rest_Task
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_PRIORITY_VARIABLE);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_TYPE);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_VARIABLE);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_GROUP_VARIABLE);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_MI_INSTANCE_VARIABLE);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_MI_COMPLETE_VARIABLE);
|
||||
$criteria->addSelectColumn(TaskPeer::TAS_ASSIGN_LOCATION);
|
||||
|
||||
@@ -63,5 +63,81 @@ class Services_Rest_Translation
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $trnCategory, $trnId, $trnLang Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($trnCategory, $trnId, $trnLang, $trnValue, $trnUpdateDate)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Translation();
|
||||
|
||||
$obj->setTrnCategory($trnCategory);
|
||||
$obj->setTrnId($trnId);
|
||||
$obj->setTrnLang($trnLang);
|
||||
$obj->setTrnValue($trnValue);
|
||||
$obj->setTrnUpdateDate($trnUpdateDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $trnCategory, $trnId, $trnLang Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($trnCategory, $trnId, $trnLang, $trnValue, $trnUpdateDate)
|
||||
{
|
||||
try {
|
||||
$obj = TranslationPeer::retrieveByPK($trnCategory, $trnId, $trnLang);
|
||||
|
||||
$obj->setTrnValue($trnValue);
|
||||
$obj->setTrnUpdateDate($trnUpdateDate);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $trnCategory, $trnId, $trnLang Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($trnCategory, $trnId, $trnLang)
|
||||
{
|
||||
$conn = Propel::getConnection(TranslationPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = TranslationPeer::retrieveByPK($trnCategory, $trnId, $trnLang);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -84,5 +84,125 @@ class Services_Rest_Users
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'POST' method for Rest API
|
||||
*
|
||||
* @param mixed $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function post($usrUid, $usrUsername, $usrPassword, $usrFirstname, $usrLastname, $usrEmail, $usrDueDate, $usrCreateDate, $usrUpdateDate, $usrStatus, $usrCountry, $usrCity, $usrLocation, $usrAddress, $usrPhone, $usrFax, $usrCellular, $usrZipCode, $depUid, $usrPosition, $usrResume, $usrBirthday, $usrRole, $usrReportsTo, $usrReplacedBy, $usrUx)
|
||||
{
|
||||
try {
|
||||
$result = array();
|
||||
$obj = new Users();
|
||||
|
||||
$obj->setUsrUid($usrUid);
|
||||
$obj->setUsrUsername($usrUsername);
|
||||
$obj->setUsrPassword($usrPassword);
|
||||
$obj->setUsrFirstname($usrFirstname);
|
||||
$obj->setUsrLastname($usrLastname);
|
||||
$obj->setUsrEmail($usrEmail);
|
||||
$obj->setUsrDueDate($usrDueDate);
|
||||
$obj->setUsrCreateDate($usrCreateDate);
|
||||
$obj->setUsrUpdateDate($usrUpdateDate);
|
||||
$obj->setUsrStatus($usrStatus);
|
||||
$obj->setUsrCountry($usrCountry);
|
||||
$obj->setUsrCity($usrCity);
|
||||
$obj->setUsrLocation($usrLocation);
|
||||
$obj->setUsrAddress($usrAddress);
|
||||
$obj->setUsrPhone($usrPhone);
|
||||
$obj->setUsrFax($usrFax);
|
||||
$obj->setUsrCellular($usrCellular);
|
||||
$obj->setUsrZipCode($usrZipCode);
|
||||
$obj->setDepUid($depUid);
|
||||
$obj->setUsrPosition($usrPosition);
|
||||
$obj->setUsrResume($usrResume);
|
||||
$obj->setUsrBirthday($usrBirthday);
|
||||
$obj->setUsrRole($usrRole);
|
||||
$obj->setUsrReportsTo($usrReportsTo);
|
||||
$obj->setUsrReplacedBy($usrReplacedBy);
|
||||
$obj->setUsrUx($usrUx);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'PUT' method for Rest API
|
||||
*
|
||||
* @param mixed $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function put($usrUid, $usrUsername, $usrPassword, $usrFirstname, $usrLastname, $usrEmail, $usrDueDate, $usrCreateDate, $usrUpdateDate, $usrStatus, $usrCountry, $usrCity, $usrLocation, $usrAddress, $usrPhone, $usrFax, $usrCellular, $usrZipCode, $depUid, $usrPosition, $usrResume, $usrBirthday, $usrRole, $usrReportsTo, $usrReplacedBy, $usrUx)
|
||||
{
|
||||
try {
|
||||
$obj = UsersPeer::retrieveByPK($usrUid);
|
||||
|
||||
$obj->setUsrUsername($usrUsername);
|
||||
$obj->setUsrPassword($usrPassword);
|
||||
$obj->setUsrFirstname($usrFirstname);
|
||||
$obj->setUsrLastname($usrLastname);
|
||||
$obj->setUsrEmail($usrEmail);
|
||||
$obj->setUsrDueDate($usrDueDate);
|
||||
$obj->setUsrCreateDate($usrCreateDate);
|
||||
$obj->setUsrUpdateDate($usrUpdateDate);
|
||||
$obj->setUsrStatus($usrStatus);
|
||||
$obj->setUsrCountry($usrCountry);
|
||||
$obj->setUsrCity($usrCity);
|
||||
$obj->setUsrLocation($usrLocation);
|
||||
$obj->setUsrAddress($usrAddress);
|
||||
$obj->setUsrPhone($usrPhone);
|
||||
$obj->setUsrFax($usrFax);
|
||||
$obj->setUsrCellular($usrCellular);
|
||||
$obj->setUsrZipCode($usrZipCode);
|
||||
$obj->setDepUid($depUid);
|
||||
$obj->setUsrPosition($usrPosition);
|
||||
$obj->setUsrResume($usrResume);
|
||||
$obj->setUsrBirthday($usrBirthday);
|
||||
$obj->setUsrRole($usrRole);
|
||||
$obj->setUsrReportsTo($usrReportsTo);
|
||||
$obj->setUsrReplacedBy($usrReplacedBy);
|
||||
$obj->setUsrUx($usrUx);
|
||||
|
||||
$obj->save();
|
||||
} catch (Exception $e) {
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation for 'DELETE' method for Rest API
|
||||
*
|
||||
* @param mixed $usrUid Primary key
|
||||
*
|
||||
* @return array $result Returns array within multiple records or a single record depending if
|
||||
* a single selection was requested passing id(s) as param
|
||||
*/
|
||||
protected function delete($usrUid)
|
||||
{
|
||||
$conn = Propel::getConnection(UsersPeer::DATABASE_NAME);
|
||||
|
||||
try {
|
||||
$conn->begin();
|
||||
|
||||
$obj = UsersPeer::retrieveByPK($usrUid);
|
||||
if (! is_object($obj)) {
|
||||
throw new RestException(412, 'Record does not exist.');
|
||||
}
|
||||
$obj->delete();
|
||||
|
||||
$conn->commit();
|
||||
} catch (Exception $e) {
|
||||
$conn->rollback();
|
||||
throw new RestException(412, $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user