HOR-3560
This commit is contained in:
@@ -1,403 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class CalendarTest
|
||||
*
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class CalendarTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $calendar;
|
||||
protected static $numCalendar = 2;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$calendar = new \ProcessMaker\BusinessModel\Calendar();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create calendars
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$arrayRecord = array();
|
||||
|
||||
//Create
|
||||
for ($i = 0; $i <= self::$numCalendar - 1; $i++) {
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "PHPUnit Calendar$i",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5),
|
||||
"CAL_WORK_HOUR" => array(
|
||||
array("DAY" => 0, "HOUR_START" => "00:00", "HOUR_END" => "00:00"),
|
||||
array("DAY" => 1, "HOUR_START" => "09:00", "HOUR_END" => "17:00")
|
||||
),
|
||||
"CAL_HOLIDAY" => array(
|
||||
array("NAME" => "holiday1", "DATE_START" => "2014-03-01", "DATE_END" => "2014-03-31"),
|
||||
array("NAME" => "holiday2", "DATE_START" => "2014-03-01", "DATE_END" => "2014-03-31")
|
||||
)
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$this->assertTrue(isset($arrayCalendar["CAL_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayCalendar;
|
||||
}
|
||||
|
||||
//Create - Japanese characters
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "私の名前(PHPUnitの)",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5)
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$this->assertTrue(isset($arrayCalendar["CAL_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayCalendar;
|
||||
|
||||
//Return
|
||||
return $arrayRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update calendars
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*/
|
||||
public function testUpdate($arrayRecord)
|
||||
{
|
||||
$arrayData = array("CAL_DESCRIPTION" => "Description...");
|
||||
|
||||
$arrayCalendar = self::$calendar->update($arrayRecord[1]["CAL_UID"], $arrayData);
|
||||
|
||||
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[1]["CAL_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], $arrayData["CAL_DESCRIPTION"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get calendars
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendars
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*/
|
||||
public function testGetCalendars($arrayRecord)
|
||||
{
|
||||
$arrayCalendar = self::$calendar->getCalendars();
|
||||
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$arrayCalendar = self::$calendar->getCalendars(null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayCalendar);
|
||||
|
||||
$arrayCalendar = self::$calendar->getCalendars(array("filter" => "PHPUnit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$this->assertEquals($arrayCalendar[0]["CAL_UID"], $arrayRecord[0]["CAL_UID"]);
|
||||
$this->assertEquals($arrayCalendar[0]["CAL_NAME"], $arrayRecord[0]["CAL_NAME"]);
|
||||
$this->assertEquals($arrayCalendar[0]["CAL_DESCRIPTION"], $arrayRecord[0]["CAL_DESCRIPTION"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get calendar
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::getCalendar
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*/
|
||||
public function testGetCalendar($arrayRecord)
|
||||
{
|
||||
//Get
|
||||
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[0]["CAL_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$this->assertEquals($arrayCalendar["CAL_UID"], $arrayRecord[0]["CAL_UID"]);
|
||||
$this->assertEquals($arrayCalendar["CAL_NAME"], $arrayRecord[0]["CAL_NAME"]);
|
||||
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], $arrayRecord[0]["CAL_DESCRIPTION"]);
|
||||
|
||||
//Get - Japanese characters
|
||||
$arrayCalendar = self::$calendar->getCalendar($arrayRecord[self::$numCalendar]["CAL_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertNotEmpty($arrayCalendar);
|
||||
|
||||
$this->assertEquals($arrayCalendar["CAL_UID"], $arrayRecord[self::$numCalendar]["CAL_UID"]);
|
||||
$this->assertEquals($arrayCalendar["CAL_NAME"], "私の名前(PHPUnitの)");
|
||||
$this->assertEquals($arrayCalendar["CAL_DESCRIPTION"], "Description");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception when data not is array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", this value must be an array.
|
||||
*/
|
||||
public function testCreateExceptionNoIsArrayData()
|
||||
{
|
||||
$arrayData = 0;
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for required data (CAL_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Undefined value for "CAL_NAME", it is required.
|
||||
*/
|
||||
public function testCreateExceptionRequiredDataCalName()
|
||||
{
|
||||
$arrayData = array(
|
||||
//"CAL_NAME" => "PHPUnit Calendar",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5)
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAL_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAL_NAME", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataCalName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5)
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAL_WORK_DAYS)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAL_WORK_DAYS", it only accepts values: "1|2|3|4|5|6|7".
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataCalWorkDays()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "PHPUnit Calendar",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(10, 2, 3, 4, 5)
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for calendar name existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The calendar name with CAL_NAME: "PHPUnit Calendar0" already exists.
|
||||
*/
|
||||
public function testCreateExceptionExistsCalName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "PHPUnit Calendar0",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5),
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception when data not is array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", this value must be an array.
|
||||
*/
|
||||
public function testUpdateExceptionNoIsArrayData()
|
||||
{
|
||||
$arrayData = 0;
|
||||
|
||||
$arrayCalendar = self::$calendar->update("", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayCalendar = self::$calendar->update("", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid calendar UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The calendar with CAL_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidCalUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "PHPUnit Calendar",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5),
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->update("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAL_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAL_NAME", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidDataCalName($arrayRecord)
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(1, 2, 3, 4, 5),
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAL_WORK_DAYS)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAL_WORK_DAYS", it only accepts values: "1|2|3|4|5|6|7".
|
||||
*/
|
||||
public function testUpdateExceptionInvalidDataCalWorkDays($arrayRecord)
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAL_NAME" => "PHPUnit Calendar",
|
||||
"CAL_DESCRIPTION" => "Description",
|
||||
"CAL_WORK_DAYS" => array(10, 2, 3, 4, 5),
|
||||
);
|
||||
|
||||
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for calendar name existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The calendar name with CAL_NAME: "PHPUnit Calendar1" already exists.
|
||||
*/
|
||||
public function testUpdateExceptionExistsCalName($arrayRecord)
|
||||
{
|
||||
$arrayData = $arrayRecord[1];
|
||||
|
||||
$arrayCalendar = self::$calendar->update($arrayRecord[0]["CAL_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete calendars
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Calendar::delete
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the calendars
|
||||
*/
|
||||
public function testDelete($arrayRecord)
|
||||
{
|
||||
foreach ($arrayRecord as $value) {
|
||||
self::$calendar->delete($value["CAL_UID"]);
|
||||
}
|
||||
|
||||
$arrayCalendar = self::$calendar->getCalendars(array("filter" => "PHPUnit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayCalendar));
|
||||
$this->assertEmpty($arrayCalendar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,392 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Cases Test
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class CasesAction13_17Test extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $oCases;
|
||||
protected $nowCountTodo = 0;
|
||||
protected $nowCountDraft = 0;
|
||||
protected $nowCountPaused = 0;
|
||||
protected $idCaseToDo = '';
|
||||
protected $idCaseDraft = '';
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
\G::loadClass('pmFunctions');
|
||||
|
||||
$usrUid = '00000000000000000000000000000001';
|
||||
$proUid = '2317283235320c1a36972b2028131767';
|
||||
$tasUid = '7983935495320c1a75e1df6068322280';
|
||||
$idCaseToDo = PMFNewCase($proUid, $usrUid, $tasUid, array());
|
||||
PMFDerivateCase($idCaseToDo, 1);
|
||||
$this->idCaseToDo = $idCaseToDo;
|
||||
|
||||
$idCaseDraft = PMFNewCase($proUid, $usrUid, $tasUid, array());
|
||||
$this->idCaseDraft = $idCaseDraft;
|
||||
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$listToDo = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
|
||||
$this->nowCountTodo = $listToDo['total'];
|
||||
|
||||
$listDraft = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
|
||||
$this->nowCountDraft = $listDraft['total'];
|
||||
|
||||
$listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused'));
|
||||
$this->nowCountPaused = $listPaused['total'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putCancelCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutCancelCaseErrorAppUidArray()
|
||||
{
|
||||
$this->oCases->putCancelCase(array(), '00000000000000000000000000000001');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putCancelCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutCancelCaseErrorAppUidIncorrect()
|
||||
{
|
||||
$this->oCases->putCancelCase('IdDoesNotExists', '00000000000000000000000000000001');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putCancelCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutCancelCaseErrorUsrUidArray()
|
||||
{
|
||||
$this->oCases->putCancelCase($this->idCaseDraft, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putCancelCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutCancelCaseErrorUsrUidIncorrect()
|
||||
{
|
||||
$this->oCases->putCancelCase($this->idCaseDraft, 'IdDoesNotExists');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in third field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putCancelCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$del_index' it must be a integer.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutCancelCaseErrorDelIndexIncorrect()
|
||||
{
|
||||
$this->oCases->putCancelCase($this->idCaseDraft, '00000000000000000000000000000001', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cancel case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putCancelCase
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutCancelCase()
|
||||
{
|
||||
$this->oCases->putCancelCase($this->idCaseDraft, '00000000000000000000000000000001');
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$listDraft = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
|
||||
$this->assertNotEquals($this->nowCountDraft, $listDraft['total']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCaseErrorAppUidArray()
|
||||
{
|
||||
$this->oCases->putPauseCase(array(), '00000000000000000000000000000001');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCaseErrorAppUidIncorrect()
|
||||
{
|
||||
$this->oCases->putPauseCase('IdDoesNotExists', '00000000000000000000000000000001');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCaseErrorUsrUidArray()
|
||||
{
|
||||
$this->oCases->putPauseCase($this->idCaseDraft, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCaseErrorUsrUidIncorrect()
|
||||
{
|
||||
$this->oCases->putPauseCase($this->idCaseDraft, 'IdDoesNotExists');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in third field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$del_index' it must be a integer.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCaseErrorDelIndexIncorrect()
|
||||
{
|
||||
$this->oCases->putPauseCase($this->idCaseDraft, '00000000000000000000000000000001', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in fourth field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The value '2014-44-44' is not a valid date for the format 'Y-m-d'.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCaseErrorDateIncorrect()
|
||||
{
|
||||
$this->oCases->putPauseCase($this->idCaseDraft, '00000000000000000000000000000001', false, '2014-44-44');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cancel case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putPauseCase
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutPauseCase()
|
||||
{
|
||||
$this->oCases->putPauseCase($this->idCaseToDo, '00000000000000000000000000000001');
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused'));
|
||||
$this->assertNotEquals($this->nowCountPaused, $listPaused['total']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putUnpauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutUnpauseCaseErrorAppUidArray()
|
||||
{
|
||||
$this->oCases->putUnpauseCase(array(), '00000000000000000000000000000001');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putUnpauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutUnpauseCaseErrorAppUidIncorrect()
|
||||
{
|
||||
$this->oCases->putUnpauseCase('IdDoesNotExists', '00000000000000000000000000000001');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putUnpauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$usr_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutUnpauseCaseErrorUsrUidArray()
|
||||
{
|
||||
$this->oCases->putUnpauseCase($this->idCaseDraft, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putUnpauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with $usr_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutUnpauseCaseErrorUsrUidIncorrect()
|
||||
{
|
||||
$this->oCases->putUnpauseCase($this->idCaseDraft, 'IdDoesNotExists');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in third field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putUnpauseCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$del_index' it must be a integer.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutUnpauseCaseErrorDelIndexIncorrect()
|
||||
{
|
||||
$this->oCases->putUnpauseCase($this->idCaseDraft, '00000000000000000000000000000001', 'string');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cancel case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::putUnpauseCase
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testPutUnpauseCase()
|
||||
{
|
||||
$this->oCases->putUnpauseCase($this->idCaseToDo, '00000000000000000000000000000001');
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$listPaused = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'paused'));
|
||||
$this->assertEquals($this->nowCountPaused, $listPaused['total']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$app_uid' it must be a string.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteCaseErrorAppUidArray()
|
||||
{
|
||||
$this->oCases->deleteCase(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The application with $app_uid: 'IdDoesNotExists' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteCaseErrorAppUidIncorrect()
|
||||
{
|
||||
$this->oCases->deleteCase('IdDoesNotExists');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for cancel case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::deleteCase
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteCase()
|
||||
{
|
||||
$this->oCases->deleteCase($this->idCaseToDo);
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
$listToDo = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
|
||||
$this->assertNotEquals($this->nowCountTodo, $listToDo['total']);
|
||||
}
|
||||
}
|
||||
@@ -1,175 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Cases Test
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $oCases;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$dataList' it must be an array.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorArray()
|
||||
{
|
||||
$this->oCases->getList(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for empty userId in array
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with userId: '' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorUserIdArray()
|
||||
{
|
||||
$this->oCases->getList(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for not exists userId in array
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with userId: 'UidInexistente' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorNotExistsUserIdArray()
|
||||
{
|
||||
$this->oCases->getList(array('userId' => 'UidInexistente'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value $action in array
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The value for $action is incorrect.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesErrorIncorrectValueArray()
|
||||
{
|
||||
$this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'incorrect'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list to do
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesToDo()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list draft
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesDraft()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'draft'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list participated
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesParticipated()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'sent'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list unassigned
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesUnassigned()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'unassigned'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get list search
|
||||
*
|
||||
* @covers \BusinessModel\Cases::getList
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetListCasesSearch()
|
||||
{
|
||||
$response = $this->oCases->getList(array('userId' => '00000000000000000000000000000001', 'action' => 'search'));
|
||||
$this->assertTrue(is_array($response));
|
||||
$this->assertTrue(is_numeric($response['totalCount']));
|
||||
$this->assertTrue(is_array($response['data']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,356 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Cases Test
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class CasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $oCases;
|
||||
protected $idCase = '';
|
||||
|
||||
protected static $usrUid = "00000000000000000000000000000001";
|
||||
protected static $usrUid2 = "00000000000000000000000000000012";
|
||||
protected static $proUid = "00000000000000000000000000000003";
|
||||
protected static $tasUid = "00000000000000000000000000000004";
|
||||
protected static $tasUid2 = "00000000000000000000000000000005";
|
||||
protected static $tasUid3 = "00000000000000000000000000000006";
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$process = new \Process();
|
||||
$process->create(array("type"=>"classicProject", "PRO_TITLE"=> "NEW TEST PHP UNIT", "PRO_DESCRIPTION"=> "465",
|
||||
"PRO_CATEGORY"=> "", "PRO_CREATE_USER"=> "00000000000000000000000000000001",
|
||||
"PRO_UID"=> self::$proUid, "USR_UID"=> "00000000000000000000000000000001"), false);
|
||||
|
||||
$task = new \Task();
|
||||
$task->create(array("TAS_START"=>"TRUE", "TAS_UID"=> self::$tasUid, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TEST PHP UNIT",
|
||||
"TAS_POSX"=> 581, "TAS_POSY"=> 47, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
|
||||
$task = new \Task();
|
||||
$task->create(array( "TAS_UID"=> self::$tasUid2, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK ONE",
|
||||
"TAS_POSX"=> 481, "TAS_POSY"=> 127, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
|
||||
$task = new \Task();
|
||||
$task->create(array( "TAS_UID"=> self::$tasUid3, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TWO",
|
||||
"TAS_POSX"=> 681, "TAS_POSY"=> 127, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
|
||||
|
||||
$nw = new \processMap();
|
||||
$nw->saveNewPattern(self::$proUid, self::$tasUid, self::$tasUid2, 'PARALLEL', true);
|
||||
$nw = new \processMap();
|
||||
$nw->saveNewPattern(self::$proUid, self::$tasUid, self::$tasUid3, 'PARALLEL', true);
|
||||
|
||||
$user = new \Users();
|
||||
$user->create(array("USR_ROLE"=> "PROCESSMAKER_ADMIN","USR_UID"=> self::$usrUid2, "USR_USERNAME"=> "dummy",
|
||||
"USR_PASSWORD"=>"21232f297a57a5a743894a0e4a801fc3", "USR_FIRSTNAME"=>"dummy_firstname", "USR_LASTNAME"=>"dummy_lastname",
|
||||
"USR_EMAIL"=>"dummy@dummy.com", "USR_DUE_DATE"=>'2020-01-01', "USR_CREATE_DATE"=>"2014-01-01 12:00:00", "USR_UPDATE_DATE"=>"2014-01-01 12:00:00",
|
||||
"USR_STATUS"=>"ACTIVE", "USR_UX"=>"NORMAL"));
|
||||
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid2, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid2, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid2, "USR_UID"=> self::$usrUid2, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid3, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid3, "USR_UID"=> self::$usrUid2, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oCases = new \ProcessMaker\BusinessModel\Cases();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid process 12345678912345678912345678912345678
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseErrorIncorrectProcessValueArray()
|
||||
{
|
||||
$this->oCases->addCase('12345678912345678912345678912345678', self::$tasUid, self::$usrUid, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of task in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Task invalid or the user is not assigned to the task
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseErrorIncorrectTaskValueArray()
|
||||
{
|
||||
$this->oCases->addCase(self::$proUid, '12345678912345678912345678912345678', self::$usrUid, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add Case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCase()
|
||||
{
|
||||
$response = $this->oCases->addCase(self::$proUid, self::$tasUid, self::$usrUid, array());
|
||||
$this->assertTrue(is_object($response));
|
||||
$aResponse = json_decode(json_encode($response), true);
|
||||
return $aResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getTaskCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Incorrect or unavailable information about this case: 12345678912345678912345678912345678
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetTaskCaseErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->getTaskCase('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get Task Case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getTaskCase
|
||||
* @depends testAddCase
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetTaskCase(array $aResponse)
|
||||
{
|
||||
$response = $this->oCases->getTaskCase($aResponse['app_uid'], self::$usrUid);
|
||||
$this->assertTrue(is_array($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCaseInfoErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->getCaseInfo('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get Case Info
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::getCaseInfo
|
||||
* @depends testAddCase
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCaseInfo(array $aResponse)
|
||||
{
|
||||
$response = $this->oCases->getCaseInfo($aResponse['app_uid'], self::$usrUid);
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of user delegation in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase
|
||||
* @depends testAddCase
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid Case Delegation index for this user
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateReassignCaseErrorIncorrectUserValueArray(array $aResponse)
|
||||
{
|
||||
$this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid, self::$usrUid2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application with app_uid: 12345678912345678912345678912345678 doesn't exist
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateReassignCaseErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->updateReassignCase('12345678912345678912345678912345678', self::$usrUid, null, self::$usrUid2, self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test put reassign case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateReassignCase
|
||||
* @depends testAddCase
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateReassignCase(array $aResponse)
|
||||
{
|
||||
$response = $this->oCases->updateReassignCase($aResponse['app_uid'], self::$usrUid, null, self::$usrUid2, self::$usrUid);
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add Case to test route case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseRouteCase()
|
||||
{
|
||||
$response = $this->oCases->addCase(self::$proUid, self::$tasUid, self::$usrUid, array());
|
||||
$this->assertTrue(is_object($response));
|
||||
$aResponseRouteCase = json_decode(json_encode($response), true);
|
||||
return $aResponseRouteCase;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateRouteCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The row '12345678912345678912345678912345678, ' in table AppDelegation doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateRouteCaseErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oCases->updateRouteCase('12345678912345678912345678912345678', self::$usrUid, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test put route case
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::updateRouteCase
|
||||
* @depends testAddCaseRouteCase
|
||||
* @param array $aResponseRouteCase
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateRouteCase(array $aResponseRouteCase)
|
||||
{
|
||||
$response = $this->oCases->updateRouteCase($aResponseRouteCase['app_uid'], self::$usrUid, null);
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of process in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid process 12345678912345678912345678912345678
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseImpersonateErrorIncorrectProcessValueArray()
|
||||
{
|
||||
$this->oCases->addCaseImpersonate('12345678912345678912345678912345678', self::$usrUid2, self::$tasUid, array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of task in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCase
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage User not registered! 12345678912345678912345678912345678!!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseImpersonateErrorIncorrectTaskValueArray()
|
||||
{
|
||||
$this->oCases->addCaseImpersonate(self::$proUid, '12345678912345678912345678912345678', self::$tasUid, array());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test add Case impersonate
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases::addCaseImpersonate
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCaseImpersonate()
|
||||
{
|
||||
$response = $this->oCases->addCaseImpersonate(self::$proUid, self::$usrUid2, self::$tasUid, array());
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$assign = new \TaskUser();
|
||||
$assign->remove(self::$tasUid, self::$usrUid, 1,1);
|
||||
|
||||
$task = new \Task();
|
||||
$task->remove(self::$tasUid);
|
||||
|
||||
$task = new \Task();
|
||||
$task->remove(self::$tasUid2);
|
||||
|
||||
$task = new \Task();
|
||||
$task->remove(self::$tasUid3);
|
||||
|
||||
$process = new \Process();
|
||||
$process->remove(self::$proUid);
|
||||
|
||||
$criteria = new \Criteria("workflow");
|
||||
$criteria->addSelectColumn(\RoutePeer::PRO_UID);
|
||||
$criteria->add(\RoutePeer::PRO_UID, self::$proUid, \Criteria::EQUAL);
|
||||
\ProcessFilesPeer::doDelete($criteria);
|
||||
|
||||
$user = new \Users();
|
||||
$user->remove(self::$usrUid2);
|
||||
|
||||
$oConnection = \Propel::getConnection( \UsersPeer::DATABASE_NAME );
|
||||
try {
|
||||
$oUser = \UsersPeer::retrieveByPK( self::$usrUid2 );
|
||||
if (! is_null( $oUser )) {
|
||||
$oConnection->begin();
|
||||
$oUser->delete();
|
||||
$oConnection->commit();
|
||||
}
|
||||
} catch (Exception $oError) {
|
||||
$oConnection->rollback();
|
||||
throw ($oError);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,354 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Department Test
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class DepartmentTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $oDepartment;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oDepartment = new \ProcessMaker\BusinessModel\Department();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$dep_data' it must be an array.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArray()
|
||||
{
|
||||
$this->oDepartment->saveDepartment(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for type in second field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for '$create' it must be a boolean.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorBoolean()
|
||||
{
|
||||
$this->oDepartment->saveDepartment(array('1'),array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for empty array in first field the function
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The field '$dep_data' is empty.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArrayEmpty()
|
||||
{
|
||||
$this->oDepartment->saveDepartment(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for create department with nonexistent dep_parent
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The departament with dep_parent: 'testUidDepartment' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArrayDepParentExist()
|
||||
{
|
||||
$data = array('dep_parent' => 'testUidDepartment');
|
||||
$this->oDepartment->saveDepartment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for create department with nonexistent dep_manager
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The user with dep_manager: 'testUidUser' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArrayDepManagerExist()
|
||||
{
|
||||
$data = array('dep_manager' => 'testUidUser');
|
||||
$this->oDepartment->saveDepartment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for create department with incorrect dep_status
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The departament with dep_status: 'SUPER ACTIVO' is incorrect.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArrayDepStatus()
|
||||
{
|
||||
$data = array('dep_status' => 'SUPER ACTIVO');
|
||||
$this->oDepartment->saveDepartment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for create department untitled
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The field dep_title is required.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArrayDepTitleEmpty()
|
||||
{
|
||||
$data = array('dep_status' => 'ACTIVE');
|
||||
$this->oDepartment->saveDepartment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save department parent
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentParent()
|
||||
{
|
||||
$data = array('dep_title' => 'Departamento Padre');
|
||||
$dep_data = $this->oDepartment->saveDepartment($data);
|
||||
$this->assertTrue(is_array($dep_data));
|
||||
$this->assertTrue(isset($dep_data['dep_uid']));
|
||||
$this->assertEquals($dep_data['dep_parent'], '');
|
||||
$this->assertEquals($dep_data['dep_title'], 'Departamento Padre');
|
||||
$this->assertEquals($dep_data['dep_status'], 'ACTIVE');
|
||||
$this->assertEquals($dep_data['dep_manager'], '');
|
||||
$this->assertEquals($dep_data['has_children'], 0);
|
||||
return $dep_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for create department with title exist
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The departament with dep_title: 'Departamento Padre' already exists.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentErrorArrayDepTitleRepeated(array $dep_data)
|
||||
{
|
||||
$data = array('dep_title' => 'Departamento Padre');
|
||||
$this->oDepartment->saveDepartment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for create department untitled
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The departament with dep_uid: 'testUidDepartment' does not exist.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateDepartmentErrorArrayDepUidExist()
|
||||
{
|
||||
$data = array('dep_uid' => 'testUidDepartment');
|
||||
$this->oDepartment->saveDepartment($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save department child
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testCreateDepartmentChild(array $dep_data)
|
||||
{
|
||||
$data = array(
|
||||
'dep_title' => 'Departamento Child',
|
||||
'dep_parent' => $dep_data['dep_uid'],
|
||||
'dep_status' => 'INACTIVE',
|
||||
'dep_manager' => '00000000000000000000000000000001'
|
||||
);
|
||||
$child_data = $this->oDepartment->saveDepartment($data);
|
||||
$this->assertTrue(is_array($child_data));
|
||||
$this->assertTrue(isset($child_data['dep_uid']));
|
||||
$this->assertEquals($child_data['dep_parent'], $dep_data['dep_uid']);
|
||||
$this->assertEquals($child_data['dep_title'], 'Departamento Child');
|
||||
$this->assertEquals($child_data['dep_status'], 'INACTIVE');
|
||||
$this->assertEquals($child_data['dep_manager'], '00000000000000000000000000000001');
|
||||
$this->assertEquals($child_data['has_children'], 0);
|
||||
return $child_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for update department with title exist
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @depends testCreateDepartmentChild
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @param array $child_data, Data for child department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::saveDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The departament with dep_title: 'Departamento Padre' already exists.
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testUpdateDepartmentErrorArrayDepTitleRepeated(array $dep_data, array $child_data)
|
||||
{
|
||||
$dataUpdate = array (
|
||||
'dep_uid' => $child_data['dep_uid'],
|
||||
'dep_title' => 'Departamento Padre'
|
||||
);
|
||||
$this->oDepartment->saveDepartment($dataUpdate, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get departments array
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @depends testCreateDepartmentChild
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @param array $child_data, Data for child department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::getDepartments
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetDepartments(array $dep_data, array $child_data)
|
||||
{
|
||||
$arrayDepartments = $this->oDepartment->getDepartments();
|
||||
$this->assertTrue(is_array($arrayDepartments));
|
||||
$this->assertEquals(count($arrayDepartments), 1);
|
||||
$this->assertTrue(is_array($arrayDepartments[0]['dep_children']));
|
||||
$this->assertEquals(count($arrayDepartments[0]['dep_children']), 1);
|
||||
|
||||
$dataParent = $arrayDepartments[0];
|
||||
$this->assertEquals($dep_data['dep_parent'], $dataParent['dep_parent']);
|
||||
$this->assertEquals($dep_data['dep_title'], $dataParent['dep_title']);
|
||||
$this->assertEquals($dep_data['dep_status'], $dataParent['dep_status']);
|
||||
$this->assertEquals($dep_data['dep_manager'], $dataParent['dep_manager']);
|
||||
|
||||
$dataChild = $arrayDepartments[0]['dep_children'][0];
|
||||
$this->assertEquals($child_data['dep_parent'], $dataChild['dep_parent']);
|
||||
$this->assertEquals($child_data['dep_title'], $dataChild['dep_title']);
|
||||
$this->assertEquals($child_data['dep_status'], $dataChild['dep_status']);
|
||||
$this->assertEquals($child_data['dep_manager'], $dataChild['dep_manager']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get department array
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::getDepartment
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetDepartment(array $dep_data)
|
||||
{
|
||||
$dataParent = $this->oDepartment->getDepartment($dep_data['dep_uid']);
|
||||
$this->assertTrue(is_array($dataParent));
|
||||
|
||||
$this->assertEquals($dep_data['dep_parent'], $dataParent['dep_parent']);
|
||||
$this->assertEquals($dep_data['dep_title'], $dataParent['dep_title']);
|
||||
$this->assertEquals($dep_data['dep_status'], $dataParent['dep_status']);
|
||||
$this->assertEquals($dep_data['dep_manager'], $dataParent['dep_manager']);
|
||||
}
|
||||
|
||||
// TODO: Assigned Users to department
|
||||
public function testDeleteDepartmentErrorUsersSelections()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for delete department with children
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @depends testCreateDepartmentChild
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @param array $child_data, Data for child department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::deleteDepartment
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Can not delete the department, it has a children department.
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteDepartmentErrorDepartmentParent(array $dep_data, array $child_data)
|
||||
{
|
||||
$this->oDepartment->deleteDepartment($dep_data['dep_uid']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get departments array
|
||||
*
|
||||
* @depends testCreateDepartmentParent
|
||||
* @depends testCreateDepartmentChild
|
||||
* @param array $dep_data, Data for parent department
|
||||
* @param array $child_data, Data for child department
|
||||
* @covers \ProcessMaker\BusinessModel\Department::deleteDepartment
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testDeleteDepartments(array $dep_data, array $child_data)
|
||||
{
|
||||
$this->oDepartment->deleteDepartment($child_data['dep_uid']);
|
||||
$this->oDepartment->deleteDepartment($dep_data['dep_uid']);
|
||||
$dataParent = $this->oDepartment->getDepartments();
|
||||
$this->assertTrue(empty($dataParent));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,204 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Documents Cases Test
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class InputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $oInputDocument;
|
||||
protected $idCase = '';
|
||||
|
||||
protected static $usrUid = "00000000000000000000000000000001";
|
||||
protected static $proUid = "00000000000000000000000000000002";
|
||||
protected static $tasUid = "00000000000000000000000000000003";
|
||||
protected static $inpUid = "00000000000000000000000000000004";
|
||||
protected static $steUid = "00000000000000000000000000000005";
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$process = new \Process();
|
||||
$process->create(array("type"=>"classicProject", "PRO_TITLE"=> "NEW TEST PHP UNIT", "PRO_DESCRIPTION"=> "465",
|
||||
"PRO_CATEGORY"=> "", "PRO_CREATE_USER"=> "00000000000000000000000000000001",
|
||||
"PRO_UID"=> self::$proUid, "USR_UID"=> "00000000000000000000000000000001"), false);
|
||||
|
||||
$task = new \Task();
|
||||
$task->create(array("TAS_START"=>"TRUE", "TAS_UID"=> self::$tasUid, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TEST PHP UNIT",
|
||||
"TAS_POSX"=> 581, "TAS_POSY"=> 17, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
|
||||
|
||||
$inputDocument = new \InputDocument();
|
||||
$inputDocument->create(array("INP_DOC_UID"=> self::$inpUid, "PRO_UID"=> self::$proUid, "INP_DOC_TITLE"=> "INPUTDOCUMENT TEST UNIT", "INP_DOC_FORM_NEEDED"=> "VIRTUAL",
|
||||
"INP_DOC_ORIGINAL"=> "ORIGINAL", "INP_DOC_DESCRIPTION"=> "", "INP_DOC_VERSIONING"=> "",
|
||||
"INP_DOC_DESTINATION_PATH"=> "", "INP_DOC_TAGS"=> "INPUT", "ACCEPT"=> "Save", "BTN_CANCEL"=>"Cancel"));
|
||||
|
||||
$step = new \Step();
|
||||
$step->create(array( "PRO_UID"=> self::$proUid, "TAS_UID"=> self::$tasUid, "STEP_UID"=> self::$steUid, "STEP_TYPE_OBJ" => "INPUT_DOCUMENT", "STEP_UID_OBJ" =>self::$inpUid));
|
||||
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$assign = new \TaskUser();
|
||||
$assign->remove(self::$tasUid, self::$usrUid, 1,1);
|
||||
|
||||
$step = new \Step();
|
||||
$step->remove(self::$steUid);
|
||||
|
||||
$inputDocument = new \InputDocument();
|
||||
$inputDocument->remove(self::$inpUid);
|
||||
|
||||
$task = new \Task();
|
||||
$task->remove(self::$tasUid);
|
||||
|
||||
$process = new \Process();
|
||||
$process->remove(self::$proUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oInputDocument = new \ProcessMaker\BusinessModel\Cases\InputDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add a test InputDocument
|
||||
*
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddInputDocument()
|
||||
{
|
||||
\G::loadClass('pmFunctions');
|
||||
$idCase = PMFNewCase(self::$proUid, self::$usrUid, self::$tasUid, array());
|
||||
$case = new \Cases();
|
||||
$appDocUid = $case->addInputDocument(self::$inpUid, $appDocUid = \G::generateUniqueID(), '', 'INPUT',
|
||||
'PHPUNIT TEST', '', $idCase, \AppDelegation::getCurrentIndex($idCase),
|
||||
self::$tasUid, self::$usrUid, "xmlform", PATH_DATA_SITE.'db.php',
|
||||
0, PATH_DATA_SITE.'db.php');
|
||||
$aResponse = array();
|
||||
$aResponse = array_merge(array("idCase" => $idCase, "appDocUid" => $appDocUid, "inpDocUid" => self::$inpUid), $aResponse);
|
||||
return $aResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of case in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocuments
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentsErrorIncorrectCaseValueArray()
|
||||
{
|
||||
$this->oInputDocument->getCasesInputDocuments('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get InputDocuments
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocuments
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocuments(array $aResponse)
|
||||
{
|
||||
$response = $this->oInputDocument->getCasesInputDocuments($aResponse["idCase"], self::$usrUid);
|
||||
$this->assertTrue(is_array($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of task in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentErrorIncorrectCaseValueArray(array $aResponse)
|
||||
{
|
||||
$this->oInputDocument->getCasesInputDocument('12345678912345678912345678912345678', self::$usrUid, $aResponse["appDocUid"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of input document in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This input document with id: 12345678912345678912345678912345678 doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocumentErrorIncorrectInputDocumentValueArray(array $aResponse)
|
||||
{
|
||||
$this->oInputDocument->getCasesInputDocument($aResponse["idCase"], self::$usrUid, '12345678912345678912345678912345678');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get InputDocument
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::getCasesInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesInputDocument(array $aResponse)
|
||||
{
|
||||
$response = $this->oInputDocument->getCasesInputDocument($aResponse["idCase"], self::$usrUid, $aResponse["appDocUid"]);
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of input document in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::removeInputDocument
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This input document with id: 12345678912345678912345678912345678 doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testRemoveInputDocumentErrorIncorrectApplicationValueArray()
|
||||
{
|
||||
$this->oInputDocument->removeInputDocument('12345678912345678912345678912345678');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove InputDocument
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\InputDocument::removeInputDocument
|
||||
* @depends testAddInputDocument
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testRemoveInputDocument(array $aResponse)
|
||||
{
|
||||
$response = $this->oInputDocument->removeInputDocument($aResponse["appDocUid"]);
|
||||
$this->assertTrue(empty($response));
|
||||
}
|
||||
}
|
||||
@@ -1,212 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once (__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class Documents Cases Test
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @protected
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class OutputDocumentsCasesTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $oOutputDocument;
|
||||
protected $idCase = '';
|
||||
|
||||
protected static $usrUid = "00000000000000000000000000000001";
|
||||
protected static $proUid = "00000000000000000000000000000002";
|
||||
protected static $tasUid = "00000000000000000000000000000003";
|
||||
protected static $outUid = "00000000000000000000000000000004";
|
||||
protected static $steUid = "00000000000000000000000000000005";
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$process = new \Process();
|
||||
$process->create(array("type"=>"classicProject", "PRO_TITLE"=> "NEW TEST PHP UNIT", "PRO_DESCRIPTION"=> "465",
|
||||
"PRO_CATEGORY"=> "", "PRO_CREATE_USER"=> "00000000000000000000000000000001",
|
||||
"PRO_UID"=> self::$proUid, "USR_UID"=> "00000000000000000000000000000001"), false);
|
||||
|
||||
$task = new \Task();
|
||||
$task->create(array("TAS_START"=>"TRUE", "TAS_UID"=> self::$tasUid, "PRO_UID"=> self::$proUid, "TAS_TITLE" => "NEW TASK TEST PHP UNIT",
|
||||
"TAS_POSX"=> 581, "TAS_POSY"=> 17, "TAS_WIDTH"=> 165, "TAS_HEIGHT"=> 40), false);
|
||||
|
||||
$outputDocument = new \OutputDocument();
|
||||
$outputDocument->create(array("OUT_DOC_UID"=> self::$outUid, "PRO_UID"=> self::$proUid, "OUT_DOC_TITLE"=> "NEW OUPUT TEST", "OUT_DOC_FILENAME"=> "NEW_OUPUT_TEST",
|
||||
"OUT_DOC_DESCRIPTION"=> "", "OUT_DOC_REPORT_GENERATOR"=> "HTML2PDF", "OUT_DOC_REPORT_GENERATOR_label"=> "HTML2PDF (Old Version)",
|
||||
"OUT_DOC_LANDSCAPE"=> "", "OUT_DOC_LANDSCAPE_label"=> "Portrait", "OUT_DOC_GENERATE"=> "BOTH", "OUT_DOC_GENERATE_label"=> "BOTH",
|
||||
"OUT_DOC_VERSIONING"=> "", "OUT_DOC_VERSIONING_label"=> "NO", "OUT_DOC_MEDIA"=> "Letter", "OUT_DOC_MEDIA_label"=> "Letter",
|
||||
"OUT_DOC_LEFT_MARGIN"=> "", "OUT_DOC_RIGHT_MARGIN"=> "", "OUT_DOC_TOP_MARGIN"=> "", "OUT_DOC_BOTTOM_MARGIN"=> "",
|
||||
"OUT_DOC_DESTINATION_PATH"=> "", "OUT_DOC_TAGS"=> "", "OUT_DOC_PDF_SECURITY_ENABLED"=> "0", "OUT_DOC_PDF_SECURITY_ENABLED_label"=> "Disabled",
|
||||
"OUT_DOC_PDF_SECURITY_OPEN_PASSWORD"=>"", "OUT_DOC_PDF_SECURITY_OWNER_PASSWORD"=> "", "OUT_DOC_PDF_SECURITY_PERMISSIONS"=> "",
|
||||
"OUT_DOC_OPEN_TYPE"=> "0", "OUT_DOC_OPEN_TYPE_label"=> "Download the file", "BTN_CANCEL"=> "Cancel", "ACCEPT"=> "Save"));
|
||||
|
||||
$step = new \Step();
|
||||
$step->create(array( "PRO_UID"=> self::$proUid, "TAS_UID"=> self::$tasUid, "STEP_UID"=> self::$steUid, "STEP_TYPE_OBJ" => "OUTPUT_DOCUMENT", "STEP_UID_OBJ" =>self::$outUid));
|
||||
|
||||
$assign = new \TaskUser();
|
||||
$assign->create(array("TAS_UID"=> self::$tasUid, "USR_UID"=> self::$usrUid, "TU_TYPE"=> "1", "TU_RELATION"=> 1));
|
||||
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$assign = new \TaskUser();
|
||||
$assign->remove(self::$tasUid, self::$usrUid, 1,1);
|
||||
|
||||
$step = new \Step();
|
||||
$step->remove(self::$steUid);
|
||||
|
||||
$outputDocument = new \OutputDocument();
|
||||
$outputDocument->remove(self::$outUid);
|
||||
|
||||
$task = new \Task();
|
||||
$task->remove(self::$tasUid);
|
||||
|
||||
$process = new \Process();
|
||||
$process->remove(self::$proUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$this->oOutputDocument = new \ProcessMaker\BusinessModel\Cases\OutputDocument();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test add OutputDocument
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::addCasesOutputDocument
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testAddCasesOutputDocument()
|
||||
{
|
||||
\G::loadClass('pmFunctions');
|
||||
$idCase = PMFNewCase(self::$proUid, self::$usrUid, self::$tasUid, array());
|
||||
$response = $this->oOutputDocument->addCasesOutputDocument($idCase, self::$outUid, self::$usrUid);
|
||||
$this->assertTrue(is_object($response));
|
||||
$aResponse = json_decode(json_encode($response), true);
|
||||
$aResponse = array_merge(array("idCase" => $idCase), $aResponse);
|
||||
return $aResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of application in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocuments
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesOutputDocumentsErrorIncorrectApplicationValueArray()
|
||||
{
|
||||
$this->oOutputDocument->getCasesOutputDocuments('12345678912345678912345678912345678', self::$usrUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get OutputDocuments
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocuments
|
||||
* @depends testAddCasesOutputDocument
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesOutputDocuments(array $aResponse)
|
||||
{
|
||||
$response = $this->oOutputDocument->getCasesOutputDocuments($aResponse["idCase"], self::$usrUid);
|
||||
$this->assertTrue(is_array($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of application in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
|
||||
* @depends testAddCasesOutputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The Application row '12345678912345678912345678912345678' doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesOutputDocumentErrorIncorrectApplicationValueArray(array $aResponse)
|
||||
{
|
||||
$this->oOutputDocument->getCasesOutputDocument('12345678912345678912345678912345678', self::$usrUid, $aResponse["app_doc_uid"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of output document in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
|
||||
* @depends testAddCasesOutputDocument
|
||||
* @param array $aResponse
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesOutputDocumentErrorIncorrectOutputDocumentValueArray(array $aResponse)
|
||||
{
|
||||
$this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], self::$usrUid, '12345678912345678912345678912345678');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get OutputDocument
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::getCasesOutputDocument
|
||||
* @depends testAddCasesOutputDocument
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testGetCasesOutputDocument(array $aResponse)
|
||||
{
|
||||
$response = $this->oOutputDocument->getCasesOutputDocument($aResponse["idCase"], self::$usrUid, $aResponse["app_doc_uid"]);
|
||||
$this->assertTrue(is_object($response));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test error for incorrect value of output document in array
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::removeOutputDocument
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This output document with id: 12345678912345678912345678912345678 doesn't exist!
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testRemoveOutputDocumentErrorIncorrectOutputDocumentValueArray()
|
||||
{
|
||||
$this->oOutputDocument->removeOutputDocument('12345678912345678912345678912345678');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test remove OutputDocument
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Cases\OutputDocument::removeOutputDocument
|
||||
* @depends testAddCasesOutputDocument
|
||||
* @param array $aResponse
|
||||
*
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function testRemoveOutputDocument(array $aResponse)
|
||||
{
|
||||
$response = $this->oOutputDocument->removeOutputDocument($aResponse["app_doc_uid"]);
|
||||
$this->assertTrue(empty($response));
|
||||
|
||||
//remove Case
|
||||
$case = new \Cases();
|
||||
$case->removeCase( $aResponse["idCase"] );
|
||||
}
|
||||
}
|
||||
@@ -1,320 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
require_once(__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class ProcessCategoryTest
|
||||
*
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class ProcessCategoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $category;
|
||||
protected static $numCategory = 2;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$category = new \ProcessMaker\BusinessModel\ProcessCategory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$arrayRecord = array();
|
||||
|
||||
//Create
|
||||
for ($i = 0; $i <= self::$numCategory - 1; $i++) {
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "PHPUnit My Category " . $i
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertTrue(isset($arrayCategory["CAT_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayCategory;
|
||||
}
|
||||
|
||||
//Create - Japanese characters
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "テスト(PHPUnitの)",
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertTrue(isset($arrayCategory["CAT_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayCategory;
|
||||
|
||||
//Return
|
||||
return $arrayRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testUpdate(array $arrayRecord)
|
||||
{
|
||||
$arrayData = array("CAT_NAME" => "PHPUnit My Category 1...");
|
||||
|
||||
$arrayCategory = self::$category->update($arrayRecord[1]["CAT_UID"], $arrayData);
|
||||
|
||||
$arrayCategory = self::$category->getCategory($arrayRecord[1]["CAT_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory["CAT_NAME"], $arrayData["CAT_NAME"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::getCategories
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testGetCategories(array $arrayRecord)
|
||||
{
|
||||
$arrayCategory = self::$category->getCategories();
|
||||
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$arrayCategory = self::$category->getCategories(null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayCategory);
|
||||
|
||||
$arrayCategory = self::$category->getCategories(array("filter" => "PHPUnit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory[0]["CAT_UID"], $arrayRecord[0]["CAT_UID"]);
|
||||
$this->assertEquals($arrayCategory[0]["CAT_NAME"], $arrayRecord[0]["CAT_NAME"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get category
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::getCategory
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testGetCategory(array $arrayRecord)
|
||||
{
|
||||
//Get
|
||||
$arrayCategory = self::$category->getCategory($arrayRecord[0]["CAT_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory["CAT_UID"], $arrayRecord[0]["CAT_UID"]);
|
||||
$this->assertEquals($arrayCategory["CAT_NAME"], $arrayRecord[0]["CAT_NAME"]);
|
||||
|
||||
//Get - Japanese characters
|
||||
$arrayCategory = self::$category->getCategory($arrayRecord[self::$numCategory]["CAT_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertNotEmpty($arrayCategory);
|
||||
|
||||
$this->assertEquals($arrayCategory["CAT_UID"], $arrayRecord[self::$numCategory]["CAT_UID"]);
|
||||
$this->assertEquals($arrayCategory["CAT_NAME"], "テスト(PHPUnitの)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for required data (CAT_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Undefined value for "CAT_NAME", it is required.
|
||||
*/
|
||||
public function testCreateExceptionRequiredDataCatName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAMEX" => "PHPUnit My Category N"
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAT_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAT_NAME", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataCatName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => ""
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for category name existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category name with CAT_NAME: "PHPUnit My Category 0" already exists.
|
||||
*/
|
||||
public function testCreateExceptionExistsCatName()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "PHPUnit My Category 0"
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayCategory = self::$category->update("", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid category UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category with CAT_UID: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' does not exist.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidCatUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => "PHPUnit My Category N"
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->update("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (CAT_NAME)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "CAT_NAME", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidDataCatName(array $arrayRecord)
|
||||
{
|
||||
$arrayData = array(
|
||||
"CAT_NAME" => ""
|
||||
);
|
||||
|
||||
$arrayCategory = self::$category->update($arrayRecord[0]["CAT_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for category name existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category name with CAT_NAME: "PHPUnit My Category 0" already exists.
|
||||
*/
|
||||
public function testUpdateExceptionExistsCatName(array $arrayRecord)
|
||||
{
|
||||
$arrayData = $arrayRecord[0];
|
||||
|
||||
$arrayCategory = self::$category->update($arrayRecord[1]["CAT_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete categories
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::delete
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the categories
|
||||
*/
|
||||
public function testDelete(array $arrayRecord)
|
||||
{
|
||||
foreach ($arrayRecord as $value) {
|
||||
self::$category->delete($value["CAT_UID"]);
|
||||
}
|
||||
|
||||
$arrayCategory = self::$category->getCategories(array("filter" => "PHPUnit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayCategory));
|
||||
$this->assertEmpty($arrayCategory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid category UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\ProcessCategory::delete
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The category with CAT_UID: 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' does not exist.
|
||||
*/
|
||||
public function testDeleteExceptionInvalidCatUid()
|
||||
{
|
||||
self::$category->delete("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,208 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel\Role;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
require_once(__DIR__ . "/../../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class PermissionTest
|
||||
*
|
||||
* @package Tests\BusinessModel\Role
|
||||
*/
|
||||
class PermissionTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $role;
|
||||
protected static $roleUid = "";
|
||||
|
||||
protected static $rolePermission;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
//Role
|
||||
self::$role = new \ProcessMaker\BusinessModel\Role();
|
||||
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "PHPUNIT_MY_ROLE_0",
|
||||
"ROL_NAME" => "PHPUnit My Role 0"
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
|
||||
self::$roleUid = $arrayRole["ROL_UID"];
|
||||
|
||||
//Role and Permission
|
||||
self::$rolePermission = new \ProcessMaker\BusinessModel\Role\Permission();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
self::$role->delete(self::$roleUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assign permissions to role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::create
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$arrayRecord = array();
|
||||
|
||||
//Permission
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "AVAILABLE-PERMISSIONS", array("filter" => "V"));
|
||||
|
||||
$this->assertNotEmpty($arrayPermission);
|
||||
|
||||
//Role and Permission - Create
|
||||
foreach ($arrayPermission as $value) {
|
||||
$perUid = $value["PER_UID"];
|
||||
|
||||
$arrayRolePermission = self::$rolePermission->create(self::$roleUid, array("PER_UID" => $perUid));
|
||||
|
||||
$this->assertTrue(is_array($arrayRolePermission));
|
||||
$this->assertNotEmpty($arrayRolePermission);
|
||||
|
||||
$this->assertTrue(isset($arrayRolePermission["ROL_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayRolePermission;
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get assigned permissions to role
|
||||
* Test get available permissions to assign to role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::getPermissions
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the role-permission
|
||||
*/
|
||||
public function testGetPermissions(array $arrayRecord)
|
||||
{
|
||||
//PERMISSIONS
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "PERMISSIONS");
|
||||
|
||||
$this->assertNotEmpty($arrayPermission);
|
||||
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "PERMISSIONS", null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayPermission);
|
||||
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "PERMISSIONS", array("filter" => "V"));
|
||||
|
||||
$this->assertTrue(is_array($arrayPermission));
|
||||
$this->assertNotEmpty($arrayPermission);
|
||||
|
||||
$this->assertEquals($arrayPermission[0]["PER_UID"], $arrayRecord[0]["PER_UID"]);
|
||||
|
||||
//AVAILABLE-PERMISSIONS
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "AVAILABLE-PERMISSIONS", null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayPermission);
|
||||
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "AVAILABLE-PERMISSIONS", array("filter" => "V"));
|
||||
|
||||
$this->assertEmpty($arrayPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayRolePermission = self::$rolePermission->create(self::$roleUid, $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid role UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The role with ROL_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist.
|
||||
*/
|
||||
public function testCreateExceptionInvalidRolUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"USR_UID" => "",
|
||||
);
|
||||
|
||||
$arrayRolePermission = self::$rolePermission->create("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (PER_UID)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "PER_UID", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataPerUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"PER_UID" => "",
|
||||
);
|
||||
|
||||
$arrayRolePermission = self::$rolePermission->create(self::$roleUid, $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unassign permissions of the role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::delete
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the role-permission
|
||||
*/
|
||||
public function testDelete(array $arrayRecord)
|
||||
{
|
||||
foreach ($arrayRecord as $value) {
|
||||
$perUid = $value["PER_UID"];
|
||||
|
||||
self::$rolePermission->delete(self::$roleUid, $perUid);
|
||||
}
|
||||
|
||||
$arrayPermission = self::$rolePermission->getPermissions(self::$roleUid, "PERMISSIONS", array("filter" => "V"));
|
||||
|
||||
$this->assertTrue(is_array($arrayPermission));
|
||||
$this->assertEmpty($arrayPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid permission UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\Permission::delete
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The permission with PER_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist.
|
||||
*/
|
||||
public function testDeleteExceptionInvalidPerUid()
|
||||
{
|
||||
self::$rolePermission->delete(self::$roleUid, "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,225 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel\Role;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
require_once(__DIR__ . "/../../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class UserTest
|
||||
*
|
||||
* @package Tests\BusinessModel\Role
|
||||
*/
|
||||
class UserTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $user;
|
||||
protected static $roleUser;
|
||||
protected static $numUser = 2;
|
||||
protected static $roleUid = "00000000000000000000000000000002"; //PROCESSMAKER_ADMIN
|
||||
|
||||
protected static $arrayUsrUid = array();
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$user = new \ProcessMaker\BusinessModel\User();
|
||||
self::$roleUser = new \ProcessMaker\BusinessModel\Role\User();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
foreach (self::$arrayUsrUid as $value) {
|
||||
$usrUid = $value;
|
||||
|
||||
self::$user->delete($usrUid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test assign users to role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::create
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$arrayRecord = array();
|
||||
|
||||
//User
|
||||
$arrayAux = explode("-", date("Y-m-d"));
|
||||
$dueDate = date("Y-m-d", mktime(0, 0, 0, $arrayAux[1], $arrayAux[2] + 5, $arrayAux[0]));
|
||||
|
||||
for ($i = 0; $i <= self::$numUser - 1; $i++) {
|
||||
$arrayData = array(
|
||||
"USR_USERNAME" => "userphpunit" . $i,
|
||||
"USR_FIRSTNAME" => "userphpunit" . $i,
|
||||
"USR_LASTNAME" => "userphpunit" . $i,
|
||||
"USR_EMAIL" => "userphpunit@email.com" . $i,
|
||||
"USR_COUNTRY" => "",
|
||||
"USR_ADDRESS" => "",
|
||||
"USR_PHONE" => "",
|
||||
"USR_ZIP_CODE" => "",
|
||||
"USR_POSITION" => "",
|
||||
"USR_REPLACED_BY" => "",
|
||||
"USR_DUE_DATE" => $dueDate,
|
||||
"USR_ROLE" => "PROCESSMAKER_OPERATOR",
|
||||
"USR_STATUS" => "ACTIVE",
|
||||
"USR_NEW_PASS" => "userphpunit" . $i,
|
||||
"USR_CNF_PASS" => "userphpunit" . $i
|
||||
);
|
||||
|
||||
$arrayUser = array_change_key_case(self::$user->create($arrayData), CASE_UPPER);
|
||||
|
||||
self::$arrayUsrUid[] = $arrayUser["USR_UID"];
|
||||
$arrayRecord[] = $arrayUser;
|
||||
}
|
||||
|
||||
//Role and User - Create
|
||||
foreach ($arrayRecord as $value) {
|
||||
$usrUid = $value["USR_UID"];
|
||||
|
||||
$arrayRoleUser = self::$roleUser->create(self::$roleUid, array("USR_UID" => $usrUid));
|
||||
|
||||
$this->assertTrue(is_array($arrayRoleUser));
|
||||
$this->assertNotEmpty($arrayRoleUser);
|
||||
|
||||
$this->assertTrue(isset($arrayRoleUser["ROL_UID"]));
|
||||
}
|
||||
|
||||
//Return
|
||||
return $arrayRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get assigned users to role
|
||||
* Test get available users to assign to role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::getUsers
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the users
|
||||
*/
|
||||
public function testGetUsers(array $arrayRecord)
|
||||
{
|
||||
//USERS
|
||||
$arrayUser = self::$roleUser->getUsers(self::$roleUid, "USERS");
|
||||
|
||||
$this->assertNotEmpty($arrayUser);
|
||||
|
||||
$arrayUser = self::$roleUser->getUsers(self::$roleUid, "USERS", null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayUser);
|
||||
|
||||
$arrayUser = self::$roleUser->getUsers(self::$roleUid, "USERS", array("filter" => "userphpunit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayUser));
|
||||
$this->assertNotEmpty($arrayUser);
|
||||
|
||||
$this->assertEquals($arrayUser[0]["USR_UID"], $arrayRecord[0]["USR_UID"]);
|
||||
$this->assertEquals($arrayUser[0]["USR_USERNAME"], $arrayRecord[0]["USR_USERNAME"]);
|
||||
|
||||
//AVAILABLE-USERS
|
||||
$arrayUser = self::$roleUser->getUsers(self::$roleUid, "AVAILABLE-USERS", null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayUser);
|
||||
|
||||
$arrayUser = self::$roleUser->getUsers(self::$roleUid, "AVAILABLE-USERS", array("filter" => "userphpunit"));
|
||||
|
||||
$this->assertEmpty($arrayUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayRoleUser = self::$roleUser->create(self::$roleUid, $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid role UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The role with ROL_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist.
|
||||
*/
|
||||
public function testCreateExceptionInvalidRolUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"USR_UID" => "",
|
||||
);
|
||||
|
||||
$arrayRoleUser = self::$roleUser->create("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (USR_UID)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "USR_UID", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataUsrUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"USR_UID" => "",
|
||||
);
|
||||
|
||||
$arrayRoleUser = self::$roleUser->create(self::$roleUid, $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test unassign users of the role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::delete
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the users
|
||||
*/
|
||||
public function testDelete(array $arrayRecord)
|
||||
{
|
||||
foreach ($arrayRecord as $value) {
|
||||
$usrUid = $value["USR_UID"];
|
||||
|
||||
self::$roleUser->delete(self::$roleUid, $usrUid);
|
||||
}
|
||||
|
||||
$arrayUser = self::$roleUser->getUsers(self::$roleUid, "USERS", array("filter" => "userphpunit"));
|
||||
|
||||
$this->assertTrue(is_array($arrayUser));
|
||||
$this->assertEmpty($arrayUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for administrator's role can't be changed
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role\User::delete
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The administrator's role can't be changed!
|
||||
*/
|
||||
public function testDeleteExceptionAdminRoleCantChanged()
|
||||
{
|
||||
self::$roleUser->delete(self::$roleUid, "00000000000000000000000000000001");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,330 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\BusinessModel;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
require_once(__DIR__ . "/../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class RoleTest
|
||||
*
|
||||
* @package Tests\BusinessModel
|
||||
*/
|
||||
class RoleTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $role;
|
||||
protected static $numRole = 2;
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
self::$role = new \ProcessMaker\BusinessModel\Role();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test create roles
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::create
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function testCreate()
|
||||
{
|
||||
$arrayRecord = array();
|
||||
|
||||
//Create
|
||||
for ($i = 0; $i <= self::$numRole - 1; $i++) {
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "PHPUNIT_MY_ROLE_" . $i,
|
||||
"ROL_NAME" => "PHPUnit My Role " . $i
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$this->assertTrue(isset($arrayRole["ROL_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayRole;
|
||||
}
|
||||
|
||||
//Create - Japanese characters
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "PHPUNIT_MY_ROLE_" . self::$numRole,
|
||||
"ROL_NAME" => "テスト(PHPUnitの)",
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$this->assertTrue(isset($arrayRole["ROL_UID"]));
|
||||
|
||||
$arrayRecord[] = $arrayRole;
|
||||
|
||||
//Return
|
||||
return $arrayRecord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test update roles
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the roles
|
||||
*/
|
||||
public function testUpdate(array $arrayRecord)
|
||||
{
|
||||
$arrayData = array("ROL_NAME" => "PHPUnit My Role ...");
|
||||
|
||||
$arrayRole = self::$role->update($arrayRecord[1]["ROL_UID"], $arrayData);
|
||||
|
||||
$arrayRole = self::$role->getRole($arrayRecord[1]["ROL_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$this->assertEquals($arrayRole["ROL_NAME"], $arrayData["ROL_NAME"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get roles
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::getRoles
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the roles
|
||||
*/
|
||||
public function testGetRoles(array $arrayRecord)
|
||||
{
|
||||
$arrayRole = self::$role->getRoles();
|
||||
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$arrayRole = self::$role->getRoles(null, null, null, 0, 0);
|
||||
|
||||
$this->assertEmpty($arrayRole);
|
||||
|
||||
$arrayRole = self::$role->getRoles(array("filter" => "PHPUNIT"));
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$this->assertEquals($arrayRole[0]["ROL_UID"], $arrayRecord[0]["ROL_UID"]);
|
||||
$this->assertEquals($arrayRole[0]["ROL_CODE"], $arrayRecord[0]["ROL_CODE"]);
|
||||
$this->assertEquals($arrayRole[0]["ROL_NAME"], $arrayRecord[0]["ROL_NAME"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test get role
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::getRole
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the roles
|
||||
*/
|
||||
public function testGetRole(array $arrayRecord)
|
||||
{
|
||||
//Get
|
||||
$arrayRole = self::$role->getRole($arrayRecord[0]["ROL_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$this->assertEquals($arrayRole["ROL_UID"], $arrayRecord[0]["ROL_UID"]);
|
||||
$this->assertEquals($arrayRole["ROL_CODE"], $arrayRecord[0]["ROL_CODE"]);
|
||||
$this->assertEquals($arrayRole["ROL_NAME"], $arrayRecord[0]["ROL_NAME"]);
|
||||
|
||||
//Get - Japanese characters
|
||||
$arrayRole = self::$role->getRole($arrayRecord[self::$numRole]["ROL_UID"]);
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertNotEmpty($arrayRole);
|
||||
|
||||
$this->assertEquals($arrayRole["ROL_UID"], $arrayRecord[self::$numRole]["ROL_UID"]);
|
||||
$this->assertEquals($arrayRole["ROL_CODE"], "PHPUNIT_MY_ROLE_" . self::$numRole);
|
||||
$this->assertEquals($arrayRole["ROL_NAME"], "テスト(PHPUnitの)");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for required data (ROL_CODE)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Undefined value for "ROL_CODE", it is required.
|
||||
*/
|
||||
public function testCreateExceptionRequiredDataRolCode()
|
||||
{
|
||||
$arrayData = array(
|
||||
//"ROL_CODE" => "PHPUNIT_MY_ROLE_N",
|
||||
"ROL_NAME" => "PHPUnit My Role N"
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (ROL_CODE)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "ROL_CODE", it can not be empty.
|
||||
*/
|
||||
public function testCreateExceptionInvalidDataRolCode()
|
||||
{
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "",
|
||||
"ROL_NAME" => "PHPUnit My Role N"
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for role code existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::create
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The role code with ROL_CODE: "PHPUNIT_MY_ROLE_0" already exists.
|
||||
*/
|
||||
public function testCreateExceptionExistsRolCode()
|
||||
{
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "PHPUNIT_MY_ROLE_0",
|
||||
"ROL_NAME" => "PHPUnit My Role 0"
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->create($arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionEmptyData()
|
||||
{
|
||||
$arrayData = array();
|
||||
|
||||
$arrayRole = self::$role->update("", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid role UID
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::update
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The role with ROL_UID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx does not exist.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidRolUid()
|
||||
{
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "PHPUNIT_MY_ROLE_N",
|
||||
"ROL_NAME" => "PHPUnit My Role N"
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->update("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid data (ROL_CODE)
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the roles
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "ROL_CODE", it can not be empty.
|
||||
*/
|
||||
public function testUpdateExceptionInvalidDataRolCode(array $arrayRecord)
|
||||
{
|
||||
$arrayData = array(
|
||||
"ROL_CODE" => "",
|
||||
"ROL_NAME" => "PHPUnit My Role 0"
|
||||
);
|
||||
|
||||
$arrayRole = self::$role->update($arrayRecord[0]["ROL_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for role code existing
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::update
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the roles
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The role code with ROL_CODE: "PHPUNIT_MY_ROLE_1" already exists.
|
||||
*/
|
||||
public function testUpdateExceptionExistsRolCode(array $arrayRecord)
|
||||
{
|
||||
$arrayData = $arrayRecord[1];
|
||||
|
||||
$arrayRole = self::$role->update($arrayRecord[0]["ROL_UID"], $arrayData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test delete roles
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::delete
|
||||
*
|
||||
* @depends testCreate
|
||||
* @param array $arrayRecord Data of the roles
|
||||
*/
|
||||
public function testDelete(array $arrayRecord)
|
||||
{
|
||||
foreach ($arrayRecord as $value) {
|
||||
self::$role->delete($value["ROL_UID"]);
|
||||
}
|
||||
|
||||
$arrayRole = self::$role->getRoles(array("filter" => "PHPUNIT"));
|
||||
|
||||
$this->assertTrue(is_array($arrayRole));
|
||||
$this->assertEmpty($arrayRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for role UID that cannot be deleted
|
||||
*
|
||||
* @covers \ProcessMaker\BusinessModel\Role::delete
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage This role cannot be deleted while it still has some assigned users.
|
||||
*/
|
||||
public function testDeleteExceptionCannotDeleted()
|
||||
{
|
||||
self::$role->delete("00000000000000000000000000000002");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
<?php
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../bootstrap.php";
|
||||
}
|
||||
|
||||
use \BpmnActivity;
|
||||
|
||||
/**
|
||||
* Class BpmnActivityTest
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class BpmnActivityTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $prjUid = "00000000000000000000000000000001";
|
||||
protected static $diaUid = "18171550f1198ddc8642045664020352";
|
||||
protected static $proUid = "155064020352f1198ddc864204561817";
|
||||
|
||||
protected static $data1;
|
||||
protected static $data2;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$project = new \BpmnProject();
|
||||
$project->setPrjUid(self::$prjUid);
|
||||
$project->setPrjName("Dummy Project");
|
||||
$project->save();
|
||||
|
||||
$process = new \BpmnDiagram();
|
||||
$process->setDiaUid(self::$diaUid);
|
||||
$process->setPrjUid(self::$prjUid);
|
||||
$process->save();
|
||||
|
||||
$process = new \BpmnProcess();
|
||||
$process->setProUid(self::$proUid);
|
||||
$process->setPrjUid(self::$prjUid);
|
||||
$process->setDiaUid(self::$diaUid);
|
||||
$process->save();
|
||||
|
||||
self::$data1 = array(
|
||||
"ACT_UID" => "864215906402045618170352f1198ddc",
|
||||
"PRJ_UID" => self::$prjUid,
|
||||
"PRO_UID" => self::$proUid,
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => "51",
|
||||
"BOU_Y" => "52"
|
||||
);
|
||||
|
||||
self::$data2 = array(
|
||||
"ACT_UID" => "70352f1198ddc8642159064020456181",
|
||||
"PRJ_UID" => self::$prjUid,
|
||||
"PRO_UID" => self::$proUid,
|
||||
"ACT_NAME" => "Activity #2",
|
||||
"BOU_X" => "53",
|
||||
"BOU_Y" => "54"
|
||||
);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$activities = BpmnActivity::findAllBy(BpmnActivityPeer::PRJ_UID, self::$prjUid);
|
||||
foreach ($activities as $activity) {
|
||||
$activity->delete();
|
||||
}
|
||||
|
||||
$bounds = BpmnBound::findAllBy(BpmnBoundPeer::PRJ_UID, self::$prjUid);
|
||||
foreach ($bounds as $bound) {
|
||||
$bound->delete();
|
||||
}
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK(self::$proUid);
|
||||
$process->delete();
|
||||
|
||||
$diagram = BpmnDiagramPeer::retrieveByPK(self::$diaUid);
|
||||
$diagram->delete();
|
||||
|
||||
$project = BpmnProjectPeer::retrieveByPK(self::$prjUid);
|
||||
$project->delete();
|
||||
}
|
||||
|
||||
public function testNew()
|
||||
{
|
||||
$activity = new BpmnActivity();
|
||||
$activity->setActUid(self::$data1["ACT_UID"]);
|
||||
$activity->setPrjUid(self::$data1["PRJ_UID"]);
|
||||
$activity->setProUid(self::$data1["PRO_UID"]);
|
||||
$activity->setActName(self::$data1["ACT_NAME"]);
|
||||
$activity->getBound()->setBouX(self::$data1["BOU_X"]);
|
||||
$activity->getBound()->setBouY(self::$data1["BOU_Y"]);
|
||||
$activity->save();
|
||||
|
||||
$activity2 = BpmnActivityPeer::retrieveByPK($activity->getActUid());
|
||||
|
||||
$this->assertNotNull($activity2);
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function testNewUsingFromArray()
|
||||
{
|
||||
$activity = new BpmnActivity();
|
||||
$activity->fromArray(self::$data2);
|
||||
|
||||
$activity->save();
|
||||
|
||||
$activity2 = BpmnActivityPeer::retrieveByPK($activity->getActUid());
|
||||
|
||||
$this->assertNotNull($activity2);
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param $activity \BpmnActivity
|
||||
*/
|
||||
public function testToArrayFromTestNew($activity)
|
||||
{
|
||||
$expected = array(
|
||||
"ACT_UID" => self::$data1["ACT_UID"],
|
||||
"PRJ_UID" => self::$data1["PRJ_UID"],
|
||||
"PRO_UID" => self::$data1["PRO_UID"],
|
||||
"ACT_NAME" => self::$data1["ACT_NAME"],
|
||||
"ACT_TYPE" => "TASK",
|
||||
"ACT_IS_FOR_COMPENSATION" => "0",
|
||||
"ACT_START_QUANTITY" => "1",
|
||||
"ACT_COMPLETION_QUANTITY" => "1",
|
||||
"ACT_TASK_TYPE" => "EMPTY",
|
||||
"ACT_IMPLEMENTATION" => "",
|
||||
"ACT_INSTANTIATE" => "0",
|
||||
"ACT_SCRIPT_TYPE" => "",
|
||||
"ACT_SCRIPT" => "",
|
||||
"ACT_LOOP_TYPE" => "NONE",
|
||||
"ACT_TEST_BEFORE" => "0",
|
||||
"ACT_LOOP_MAXIMUM" => "0",
|
||||
"ACT_LOOP_CONDITION" => "",
|
||||
"ACT_LOOP_CARDINALITY" => "0",
|
||||
"ACT_LOOP_BEHAVIOR" => "NONE",
|
||||
"ACT_IS_ADHOC" => "0",
|
||||
"ACT_IS_COLLAPSED" => "1",
|
||||
"ACT_COMPLETION_CONDITION" => "",
|
||||
"ACT_ORDERING" => "PARALLEL",
|
||||
"ACT_CANCEL_REMAINING_INSTANCES" => "1",
|
||||
"ACT_PROTOCOL" => "",
|
||||
"ACT_METHOD" => "",
|
||||
"ACT_IS_GLOBAL" => "0",
|
||||
"ACT_REFERER" => "",
|
||||
"ACT_DEFAULT_FLOW" => "",
|
||||
"ACT_MASTER_DIAGRAM" => "",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data1["ACT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnActivity",
|
||||
"BOU_X" => self::$data1["BOU_X"],
|
||||
"BOU_Y" => self::$data1["BOU_Y"],
|
||||
"BOU_WIDTH" => "0",
|
||||
"BOU_HEIGHT" => "0",
|
||||
"BOU_REL_POSITION" => "0",
|
||||
"BOU_SIZE_IDENTICAL" => "0",
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $activity->toArray();
|
||||
$bouUid = $result["BOU_UID"];
|
||||
|
||||
$this->assertNotEmpty($bouUid);
|
||||
$this->assertEquals(32, strlen($bouUid));
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNewUsingFromArray
|
||||
*/
|
||||
public function testToArrayFromTestNewUsingFromArray($activity)
|
||||
{
|
||||
$expected = array(
|
||||
"ACT_UID" => self::$data2["ACT_UID"],
|
||||
"PRJ_UID" => self::$data2["PRJ_UID"],
|
||||
"PRO_UID" => self::$data2["PRO_UID"],
|
||||
"ACT_NAME" => self::$data2["ACT_NAME"],
|
||||
"ACT_TYPE" => "TASK",
|
||||
"ACT_IS_FOR_COMPENSATION" => "0",
|
||||
"ACT_START_QUANTITY" => "1",
|
||||
"ACT_COMPLETION_QUANTITY" => "1",
|
||||
"ACT_TASK_TYPE" => "EMPTY",
|
||||
"ACT_IMPLEMENTATION" => "",
|
||||
"ACT_INSTANTIATE" => "0",
|
||||
"ACT_SCRIPT_TYPE" => "",
|
||||
"ACT_SCRIPT" => "",
|
||||
"ACT_LOOP_TYPE" => "NONE",
|
||||
"ACT_TEST_BEFORE" => "0",
|
||||
"ACT_LOOP_MAXIMUM" => "0",
|
||||
"ACT_LOOP_CONDITION" => "",
|
||||
"ACT_LOOP_CARDINALITY" => "0",
|
||||
"ACT_LOOP_BEHAVIOR" => "NONE",
|
||||
"ACT_IS_ADHOC" => "0",
|
||||
"ACT_IS_COLLAPSED" => "1",
|
||||
"ACT_COMPLETION_CONDITION" => "",
|
||||
"ACT_ORDERING" => "PARALLEL",
|
||||
"ACT_CANCEL_REMAINING_INSTANCES" => "1",
|
||||
"ACT_PROTOCOL" => "",
|
||||
"ACT_METHOD" => "",
|
||||
"ACT_IS_GLOBAL" => "0",
|
||||
"ACT_REFERER" => "",
|
||||
"ACT_DEFAULT_FLOW" => "",
|
||||
"ACT_MASTER_DIAGRAM" => "",
|
||||
"DIA_UID" => "18171550f1198ddc8642045664020352",
|
||||
"ELEMENT_UID" => self::$data2["ACT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnActivity",
|
||||
"BOU_X" => self::$data2["BOU_X"],
|
||||
"BOU_Y" => self::$data2["BOU_Y"],
|
||||
"BOU_WIDTH" => "0",
|
||||
"BOU_HEIGHT" => "0",
|
||||
"BOU_REL_POSITION" => "0",
|
||||
"BOU_SIZE_IDENTICAL" => "0",
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $activity->toArray();
|
||||
$bouUid = $result["BOU_UID"];
|
||||
|
||||
$this->assertNotEmpty($bouUid);
|
||||
$this->assertEquals(32, strlen($bouUid));
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testToArray()
|
||||
{
|
||||
$activity = BpmnActivityPeer::retrieveByPK(self::$data1["ACT_UID"]);
|
||||
|
||||
$expected = array(
|
||||
"ACT_UID" => self::$data1["ACT_UID"],
|
||||
"PRJ_UID" => self::$data1["PRJ_UID"],
|
||||
"PRO_UID" => self::$data1["PRO_UID"],
|
||||
"ACT_NAME" => self::$data1["ACT_NAME"],
|
||||
"ACT_TYPE" => "TASK",
|
||||
"ACT_IS_FOR_COMPENSATION" => "0",
|
||||
"ACT_START_QUANTITY" => "1",
|
||||
"ACT_COMPLETION_QUANTITY" => "1",
|
||||
"ACT_TASK_TYPE" => "EMPTY",
|
||||
"ACT_IMPLEMENTATION" => "",
|
||||
"ACT_INSTANTIATE" => "0",
|
||||
"ACT_SCRIPT_TYPE" => "",
|
||||
"ACT_SCRIPT" => "",
|
||||
"ACT_LOOP_TYPE" => "NONE",
|
||||
"ACT_TEST_BEFORE" => "0",
|
||||
"ACT_LOOP_MAXIMUM" => "0",
|
||||
"ACT_LOOP_CONDITION" => "",
|
||||
"ACT_LOOP_CARDINALITY" => "0",
|
||||
"ACT_LOOP_BEHAVIOR" => "NONE",
|
||||
"ACT_IS_ADHOC" => "0",
|
||||
"ACT_IS_COLLAPSED" => "1",
|
||||
"ACT_COMPLETION_CONDITION" => "",
|
||||
"ACT_ORDERING" => "PARALLEL",
|
||||
"ACT_CANCEL_REMAINING_INSTANCES" => "1",
|
||||
"ACT_PROTOCOL" => "",
|
||||
"ACT_METHOD" => "",
|
||||
"ACT_IS_GLOBAL" => "0",
|
||||
"ACT_REFERER" => "",
|
||||
"ACT_DEFAULT_FLOW" => "",
|
||||
"ACT_MASTER_DIAGRAM" => "",
|
||||
"DIA_UID" => "18171550f1198ddc8642045664020352",
|
||||
"ELEMENT_UID" => self::$data1["ACT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnActivity",
|
||||
"BOU_X" => self::$data1["BOU_X"],
|
||||
"BOU_Y" => self::$data1["BOU_Y"],
|
||||
"BOU_WIDTH" => "0",
|
||||
"BOU_HEIGHT" => "0",
|
||||
"BOU_REL_POSITION" => "0",
|
||||
"BOU_SIZE_IDENTICAL" => "0",
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $activity->toArray();
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testNewUsingFromArray
|
||||
* @param $activity1 \BpmnActivity
|
||||
* @param $activity2 \BpmnActivity
|
||||
*/
|
||||
public function testDelete($activity1, $activity2)
|
||||
{
|
||||
$actUid = $activity1->getActUid();
|
||||
$activity = BpmnActivityPeer::retrieveByPK($actUid);
|
||||
$activity->delete();
|
||||
|
||||
$this->assertNull(BpmnActivityPeer::retrieveByPK($actUid));
|
||||
// the previous call must delete the bound object related to activity too.
|
||||
$this->assertNull(BpmnBound::findByElement("Activity", $actUid));
|
||||
|
||||
|
||||
$actUid = $activity2->getActUid();
|
||||
$activity = BpmnActivityPeer::retrieveByPK($actUid);
|
||||
$activity->delete();
|
||||
|
||||
$this->assertNull(BpmnActivityPeer::retrieveByPK($actUid));
|
||||
// the previous call must delete the bound object related to activity too.
|
||||
$this->assertNull(BpmnBound::findByElement("Activity", $actUid));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,297 +0,0 @@
|
||||
<?php
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../bootstrap.php";
|
||||
}
|
||||
|
||||
use \BpmnEvent;
|
||||
|
||||
/**
|
||||
* Class BpmnEventTest
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class BpmnEventTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $prjUid = "00000000000000000000000000000001";
|
||||
protected static $diaUid = "18171550f1198ddc8642045664020352";
|
||||
protected static $proUid = "155064020352f1198ddc864204561817";
|
||||
|
||||
protected static $data1;
|
||||
protected static $data2;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$project = new \BpmnProject();
|
||||
$project->setPrjUid(self::$prjUid);
|
||||
$project->setPrjName("Dummy Project");
|
||||
$project->save();
|
||||
|
||||
$process = new \BpmnDiagram();
|
||||
$process->setDiaUid(self::$diaUid);
|
||||
$process->setPrjUid(self::$prjUid);
|
||||
$process->save();
|
||||
|
||||
$process = new \BpmnProcess();
|
||||
$process->setProUid(self::$proUid);
|
||||
$process->setPrjUid(self::$prjUid);
|
||||
$process->setDiaUid(self::$diaUid);
|
||||
$process->save();
|
||||
|
||||
self::$data1 = array(
|
||||
"EVN_UID" => "864215906402045618170352f1198ddc",
|
||||
"PRJ_UID" => self::$prjUid,
|
||||
"PRO_UID" => self::$proUid,
|
||||
"EVN_NAME" => "Event #1",
|
||||
"EVN_TYPE" => "START",
|
||||
"BOU_X" => 51,
|
||||
"BOU_Y" => 52
|
||||
);
|
||||
|
||||
self::$data2 = array(
|
||||
"EVN_UID" => "70352f1198ddc8642159064020456181",
|
||||
"PRJ_UID" => self::$prjUid,
|
||||
"PRO_UID" => self::$proUid,
|
||||
"EVN_NAME" => "Event #2",
|
||||
"EVN_TYPE" => "END",
|
||||
"BOU_X" => 53,
|
||||
"BOU_Y" => 54
|
||||
);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$events = BpmnEvent::findAllBy(BpmnEventPeer::PRJ_UID, self::$prjUid);
|
||||
foreach ($events as $event) {
|
||||
$event->delete();
|
||||
}
|
||||
|
||||
$bounds = BpmnBound::findAllBy(BpmnBoundPeer::PRJ_UID, self::$prjUid);
|
||||
foreach ($bounds as $bound) {
|
||||
$bound->delete();
|
||||
}
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK(self::$proUid);
|
||||
$process->delete();
|
||||
|
||||
$diagram = BpmnDiagramPeer::retrieveByPK(self::$diaUid);
|
||||
$diagram->delete();
|
||||
|
||||
$project = BpmnProjectPeer::retrieveByPK(self::$prjUid);
|
||||
$project->delete();
|
||||
}
|
||||
|
||||
public function testNew()
|
||||
{
|
||||
$event = new BpmnEvent();
|
||||
$event->setEvnUid(self::$data1["EVN_UID"]);
|
||||
$event->setPrjUid(self::$data1["PRJ_UID"]);
|
||||
$event->setProUid(self::$data1["PRO_UID"]);
|
||||
$event->setEvnName(self::$data1["EVN_NAME"]);
|
||||
$event->setEvnType(self::$data1["EVN_TYPE"]);
|
||||
$event->getBound()->setBouX(self::$data1["BOU_X"]);
|
||||
$event->getBound()->setBouY(self::$data1["BOU_Y"]);
|
||||
$event->save();
|
||||
|
||||
$event2 = BpmnEventPeer::retrieveByPK($event->getEvnUid());
|
||||
|
||||
$this->assertNotNull($event2);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
public function testNewUsingFromArray()
|
||||
{
|
||||
$event = new BpmnEvent();
|
||||
$event->fromArray(self::$data2);
|
||||
$event->save();
|
||||
|
||||
$event2 = BpmnEventPeer::retrieveByPK($event->getEvnUid());
|
||||
|
||||
$this->assertNotNull($event2);
|
||||
|
||||
return $event;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param $event \BpmnEvent
|
||||
*/
|
||||
public function testToArrayFromTestNew($event)
|
||||
{
|
||||
$expected = array(
|
||||
"EVN_UID" => self::$data1["EVN_UID"],
|
||||
"PRJ_UID" => self::$data1["PRJ_UID"],
|
||||
"PRO_UID" => self::$data1["PRO_UID"],
|
||||
"EVN_NAME" => self::$data1["EVN_NAME"],
|
||||
"EVN_TYPE" => self::$data1["EVN_TYPE"],
|
||||
"EVN_MARKER" => "EMPTY",
|
||||
"EVN_IS_INTERRUPTING" => 1,
|
||||
"EVN_ATTACHED_TO" => "",
|
||||
"EVN_CANCEL_ACTIVITY" => 0,
|
||||
"EVN_ACTIVITY_REF" => "",
|
||||
"EVN_WAIT_FOR_COMPLETION" => 1,
|
||||
"EVN_ERROR_NAME" => null,
|
||||
"EVN_ERROR_CODE" => null,
|
||||
"EVN_ESCALATION_NAME" => null,
|
||||
"EVN_ESCALATION_CODE" => null,
|
||||
"EVN_CONDITION" => null,
|
||||
"EVN_MESSAGE" => null,
|
||||
"EVN_OPERATION_NAME" => null,
|
||||
"EVN_OPERATION_IMPLEMENTATION_REF" => null,
|
||||
"EVN_TIME_DATE" => null,
|
||||
"EVN_TIME_CYCLE" => null,
|
||||
"EVN_TIME_DURATION" => null,
|
||||
"EVN_BEHAVIOR" => "CATCH",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data1["EVN_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnEvent",
|
||||
"BOU_X" => self::$data1["BOU_X"],
|
||||
"BOU_Y" => self::$data1["BOU_Y"],
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0,
|
||||
"BOU_REL_POSITION" => 0,
|
||||
"BOU_SIZE_IDENTICAL" => 0,
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $event->toArray();
|
||||
$bouUid = $result["BOU_UID"];
|
||||
|
||||
$this->assertNotEmpty($bouUid);
|
||||
$this->assertEquals(32, strlen($bouUid));
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNewUsingFromArray
|
||||
* @param $event \BpmnEvent
|
||||
*/
|
||||
public function testToArrayFromTestNewUsingFromArray($event)
|
||||
{
|
||||
$expected = array(
|
||||
"EVN_UID" => self::$data2["EVN_UID"],
|
||||
"PRJ_UID" => self::$data2["PRJ_UID"],
|
||||
"PRO_UID" => self::$data2["PRO_UID"],
|
||||
"EVN_NAME" => self::$data2["EVN_NAME"],
|
||||
"EVN_TYPE" => self::$data2["EVN_TYPE"],
|
||||
"EVN_MARKER" => "EMPTY",
|
||||
"EVN_IS_INTERRUPTING" => 1,
|
||||
"EVN_ATTACHED_TO" => "",
|
||||
"EVN_CANCEL_ACTIVITY" => 0,
|
||||
"EVN_ACTIVITY_REF" => "",
|
||||
"EVN_WAIT_FOR_COMPLETION" => 1,
|
||||
"EVN_ERROR_NAME" => null,
|
||||
"EVN_ERROR_CODE" => null,
|
||||
"EVN_ESCALATION_NAME" => null,
|
||||
"EVN_ESCALATION_CODE" => null,
|
||||
"EVN_CONDITION" => null,
|
||||
"EVN_MESSAGE" => null,
|
||||
"EVN_OPERATION_NAME" => null,
|
||||
"EVN_OPERATION_IMPLEMENTATION_REF" => null,
|
||||
"EVN_TIME_DATE" => null,
|
||||
"EVN_TIME_CYCLE" => null,
|
||||
"EVN_TIME_DURATION" => null,
|
||||
"EVN_BEHAVIOR" => "CATCH",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data2["EVN_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnEvent",
|
||||
"BOU_X" => self::$data2["BOU_X"],
|
||||
"BOU_Y" => self::$data2["BOU_Y"],
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0,
|
||||
"BOU_REL_POSITION" => 0,
|
||||
"BOU_SIZE_IDENTICAL" => 0,
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $event->toArray();
|
||||
$bouUid = $result["BOU_UID"];
|
||||
|
||||
$this->assertNotEmpty($bouUid);
|
||||
$this->assertEquals(32, strlen($bouUid));
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testToArray()
|
||||
{
|
||||
$event = BpmnEventPeer::retrieveByPK(self::$data1["EVN_UID"]);
|
||||
|
||||
$expected = array(
|
||||
"EVN_UID" => self::$data1["EVN_UID"],
|
||||
"PRJ_UID" => self::$data1["PRJ_UID"],
|
||||
"PRO_UID" => self::$data1["PRO_UID"],
|
||||
"EVN_NAME" => self::$data1["EVN_NAME"],
|
||||
"EVN_TYPE" => self::$data1["EVN_TYPE"],
|
||||
"EVN_MARKER" => "EMPTY",
|
||||
"EVN_IS_INTERRUPTING" => 1,
|
||||
"EVN_ATTACHED_TO" => "",
|
||||
"EVN_CANCEL_ACTIVITY" => 0,
|
||||
"EVN_ACTIVITY_REF" => "",
|
||||
"EVN_WAIT_FOR_COMPLETION" => 1,
|
||||
"EVN_ERROR_NAME" => null,
|
||||
"EVN_ERROR_CODE" => null,
|
||||
"EVN_ESCALATION_NAME" => null,
|
||||
"EVN_ESCALATION_CODE" => null,
|
||||
"EVN_CONDITION" => null,
|
||||
"EVN_MESSAGE" => null,
|
||||
"EVN_OPERATION_NAME" => null,
|
||||
"EVN_OPERATION_IMPLEMENTATION_REF" => null,
|
||||
"EVN_TIME_DATE" => null,
|
||||
"EVN_TIME_CYCLE" => null,
|
||||
"EVN_TIME_DURATION" => null,
|
||||
"EVN_BEHAVIOR" => "CATCH",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data1["EVN_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnEvent",
|
||||
"BOU_X" => self::$data1["BOU_X"],
|
||||
"BOU_Y" => self::$data1["BOU_Y"],
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0,
|
||||
"BOU_REL_POSITION" => 0,
|
||||
"BOU_SIZE_IDENTICAL" => 0,
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $event->toArray();
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testNewUsingFromArray
|
||||
* @param $event1 \BpmnEvent
|
||||
* @param $event2 \BpmnEvent
|
||||
*/
|
||||
public function testDelete($event1, $event2)
|
||||
{
|
||||
$gatUid = $event1->getEvnUid();
|
||||
$event = BpmnEventPeer::retrieveByPK($gatUid);
|
||||
$event->delete();
|
||||
|
||||
$this->assertNull(BpmnEventPeer::retrieveByPK($gatUid));
|
||||
// the previous call must delete the bound object related to activity too.
|
||||
$this->assertNull(BpmnBound::findByElement("Event", $gatUid));
|
||||
|
||||
|
||||
$gatUid = $event2->getEvnUid();
|
||||
$event = BpmnEventPeer::retrieveByPK($gatUid);
|
||||
$event->delete();
|
||||
|
||||
$this->assertNull(BpmnEventPeer::retrieveByPK($gatUid));
|
||||
// the previous call must delete the bound object related to activity too.
|
||||
$this->assertNull(BpmnBound::findByElement("Event", $gatUid));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,262 +0,0 @@
|
||||
<?php
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../bootstrap.php";
|
||||
}
|
||||
|
||||
use \BpmnGateway;
|
||||
|
||||
|
||||
/**
|
||||
* Class BpmnGatewayTest
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class BpmnGatewayTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $prjUid = "00000000000000000000000000000001";
|
||||
protected static $diaUid = "18171550f1198ddc8642045664020352";
|
||||
protected static $proUid = "155064020352f1198ddc864204561817";
|
||||
|
||||
protected static $data1;
|
||||
protected static $data2;
|
||||
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$project = new \BpmnProject();
|
||||
$project->setPrjUid(self::$prjUid);
|
||||
$project->setPrjName("Dummy Project");
|
||||
$project->save();
|
||||
|
||||
$process = new \BpmnDiagram();
|
||||
$process->setDiaUid(self::$diaUid);
|
||||
$process->setPrjUid(self::$prjUid);
|
||||
$process->save();
|
||||
|
||||
$process = new \BpmnProcess();
|
||||
$process->setProUid(self::$proUid);
|
||||
$process->setPrjUid(self::$prjUid);
|
||||
$process->setDiaUid(self::$diaUid);
|
||||
$process->save();
|
||||
|
||||
self::$data1 = array(
|
||||
"GAT_UID" => "864215906402045618170352f1198ddc",
|
||||
"PRJ_UID" => self::$prjUid,
|
||||
"PRO_UID" => self::$proUid,
|
||||
"GAT_NAME" => "Gateway #1",
|
||||
"GAT_TYPE" => "SELECTION",
|
||||
"BOU_X" => 51,
|
||||
"BOU_Y" => 52
|
||||
);
|
||||
|
||||
self::$data2 = array(
|
||||
"GAT_UID" => "70352f1198ddc8642159064020456181",
|
||||
"PRJ_UID" => self::$prjUid,
|
||||
"PRO_UID" => self::$proUid,
|
||||
"GAT_NAME" => "Gateway #2",
|
||||
"GAT_TYPE" => "EVALUATION",
|
||||
"BOU_X" => 53,
|
||||
"BOU_Y" => 54
|
||||
);
|
||||
}
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$gateways = BpmnGateway::findAllBy(BpmnGatewayPeer::PRJ_UID, self::$prjUid);
|
||||
foreach ($gateways as $gateway) {
|
||||
$gateway->delete();
|
||||
}
|
||||
|
||||
$bounds = BpmnBound::findAllBy(BpmnBoundPeer::PRJ_UID, self::$prjUid);
|
||||
foreach ($bounds as $bound) {
|
||||
$bound->delete();
|
||||
}
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK(self::$proUid);
|
||||
$process->delete();
|
||||
|
||||
$diagram = BpmnDiagramPeer::retrieveByPK(self::$diaUid);
|
||||
$diagram->delete();
|
||||
|
||||
$project = BpmnProjectPeer::retrieveByPK(self::$prjUid);
|
||||
$project->delete();
|
||||
}
|
||||
|
||||
public function testNew()
|
||||
{
|
||||
$gateway = new BpmnGateway();
|
||||
$gateway->setGatUid(self::$data1["GAT_UID"]);
|
||||
$gateway->setPrjUid(self::$data1["PRJ_UID"]);
|
||||
$gateway->setProUid(self::$data1["PRO_UID"]);
|
||||
$gateway->setGatName(self::$data1["GAT_NAME"]);
|
||||
$gateway->setGatType(self::$data1["GAT_TYPE"]);
|
||||
$gateway->getBound()->setBouX(self::$data1["BOU_X"]);
|
||||
$gateway->getBound()->setBouY(self::$data1["BOU_Y"]);
|
||||
$gateway->save();
|
||||
|
||||
$gateway2 = BpmnGatewayPeer::retrieveByPK($gateway->getGatUid());
|
||||
|
||||
$this->assertNotNull($gateway2);
|
||||
|
||||
return $gateway;
|
||||
}
|
||||
|
||||
public function testNewUsingFromArray()
|
||||
{
|
||||
$gateway = new BpmnGateway();
|
||||
$gateway->fromArray(self::$data2);
|
||||
$gateway->save();
|
||||
|
||||
$gateway2 = BpmnGatewayPeer::retrieveByPK($gateway->getGatUid());
|
||||
|
||||
$this->assertNotNull($gateway2);
|
||||
|
||||
return $gateway;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param $gateway \BpmnGateway
|
||||
*/
|
||||
public function testToArrayFromTestNew($gateway)
|
||||
{
|
||||
$expected = array(
|
||||
"GAT_UID" => self::$data1["GAT_UID"],
|
||||
"PRJ_UID" => self::$data1["PRJ_UID"],
|
||||
"PRO_UID" => self::$data1["PRO_UID"],
|
||||
"GAT_NAME" => self::$data1["GAT_NAME"],
|
||||
"GAT_TYPE" => self::$data1["GAT_TYPE"],
|
||||
"GAT_DIRECTION" => "UNSPECIFIED",
|
||||
"GAT_INSTANTIATE" => 0,
|
||||
"GAT_EVENT_GATEWAY_TYPE" => 'NONE',
|
||||
"GAT_ACTIVATION_COUNT" => 0,
|
||||
"GAT_WAITING_FOR_START" => 1,
|
||||
"GAT_DEFAULT_FLOW" => "",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data1["GAT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnGateway",
|
||||
"BOU_X" => self::$data1["BOU_X"],
|
||||
"BOU_Y" => self::$data1["BOU_Y"],
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0,
|
||||
"BOU_REL_POSITION" => 0,
|
||||
"BOU_SIZE_IDENTICAL" => 0,
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $gateway->toArray();
|
||||
$bouUid = $result["BOU_UID"];
|
||||
|
||||
$this->assertNotEmpty($bouUid);
|
||||
$this->assertEquals(32, strlen($bouUid));
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNewUsingFromArray
|
||||
* @param $gateway \BpmnGateway
|
||||
*/
|
||||
public function testToArrayFromTestNewUsingFromArray($gateway)
|
||||
{
|
||||
$expected = array(
|
||||
"GAT_UID" => self::$data2["GAT_UID"],
|
||||
"PRJ_UID" => self::$data2["PRJ_UID"],
|
||||
"PRO_UID" => self::$data2["PRO_UID"],
|
||||
"GAT_NAME" => self::$data2["GAT_NAME"],
|
||||
"GAT_TYPE" => self::$data2["GAT_TYPE"],
|
||||
"GAT_DIRECTION" => "UNSPECIFIED",
|
||||
"GAT_INSTANTIATE" => 0,
|
||||
"GAT_EVENT_GATEWAY_TYPE" => 'NONE',
|
||||
"GAT_ACTIVATION_COUNT" => 0,
|
||||
"GAT_WAITING_FOR_START" => 1,
|
||||
"GAT_DEFAULT_FLOW" => "",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data2["GAT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnGateway",
|
||||
"BOU_X" => self::$data2["BOU_X"],
|
||||
"BOU_Y" => self::$data2["BOU_Y"],
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0,
|
||||
"BOU_REL_POSITION" => 0,
|
||||
"BOU_SIZE_IDENTICAL" => 0,
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $gateway->toArray();
|
||||
$bouUid = $result["BOU_UID"];
|
||||
|
||||
$this->assertNotEmpty($bouUid);
|
||||
$this->assertEquals(32, strlen($bouUid));
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testToArray()
|
||||
{
|
||||
$gateway = BpmnGatewayPeer::retrieveByPK(self::$data1["GAT_UID"]);
|
||||
|
||||
$expected = array(
|
||||
"GAT_UID" => self::$data1["GAT_UID"],
|
||||
"PRJ_UID" => self::$data1["PRJ_UID"],
|
||||
"PRO_UID" => self::$data1["PRO_UID"],
|
||||
"GAT_NAME" => self::$data1["GAT_NAME"],
|
||||
"GAT_TYPE" => self::$data1["GAT_TYPE"],
|
||||
"GAT_DIRECTION" => "UNSPECIFIED",
|
||||
"GAT_INSTANTIATE" => 0,
|
||||
"GAT_EVENT_GATEWAY_TYPE" => 'NONE',
|
||||
"GAT_ACTIVATION_COUNT" => 0,
|
||||
"GAT_WAITING_FOR_START" => 1,
|
||||
"GAT_DEFAULT_FLOW" => "",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data1["GAT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnGateway",
|
||||
"BOU_X" => self::$data1["BOU_X"],
|
||||
"BOU_Y" => self::$data1["BOU_Y"],
|
||||
"BOU_WIDTH" => 0,
|
||||
"BOU_HEIGHT" => 0,
|
||||
"BOU_REL_POSITION" => 0,
|
||||
"BOU_SIZE_IDENTICAL" => 0,
|
||||
"BOU_CONTAINER" => "bpmnDiagram"
|
||||
);
|
||||
|
||||
$result = $gateway->toArray();
|
||||
|
||||
unset($result["BOU_UID"]);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testNewUsingFromArray
|
||||
* @param $gateway1 \BpmnGateway
|
||||
* @param $gateway2 \BpmnGateway
|
||||
*/
|
||||
public function testDelete($gateway1, $gateway2)
|
||||
{
|
||||
$gatUid = $gateway1->getGatUid();
|
||||
$gateway = BpmnGatewayPeer::retrieveByPK($gatUid);
|
||||
$gateway->delete();
|
||||
|
||||
$this->assertNull(BpmnGatewayPeer::retrieveByPK($gatUid));
|
||||
// the previous call must delete the bound object related to activity too.
|
||||
$this->assertNull(BpmnBound::findByElement("Gateway", $gatUid));
|
||||
|
||||
|
||||
$gatUid = $gateway2->getGatUid();
|
||||
$gateway = BpmnGatewayPeer::retrieveByPK($gatUid);
|
||||
$gateway->delete();
|
||||
|
||||
$this->assertNull(BpmnGatewayPeer::retrieveByPK($gatUid));
|
||||
// the previous call must delete the bound object related to activity too.
|
||||
$this->assertNull(BpmnBound::findByElement("Gateway", $gatUid));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Exporter;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once(__DIR__ . "/../../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class XmlExporterTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class XmlExporterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $exporter;
|
||||
protected static $projectUid = "";
|
||||
protected static $filePmx = "";
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$json = "
|
||||
{
|
||||
\"prj_name\": \"" . \ProcessMaker\Util\Common::generateUID() . "\",
|
||||
\"prj_author\": \"00000000000000000000000000000001\",
|
||||
\"diagrams\": [
|
||||
{
|
||||
\"dia_uid\": \"\",
|
||||
\"activities\": [],
|
||||
\"events\": [],
|
||||
\"gateways\": [],
|
||||
\"flows\": [],
|
||||
\"artifacts\": [],
|
||||
\"laneset\": [],
|
||||
\"lanes\": []
|
||||
}
|
||||
]
|
||||
}
|
||||
";
|
||||
|
||||
$arrayResult = \ProcessMaker\Project\Adapter\BpmnWorkflow::createFromStruct(json_decode($json, true));
|
||||
|
||||
self::$projectUid = $arrayResult[0]["new_uid"];
|
||||
self::$filePmx = PATH_DOCUMENT . "output" . PATH_SEP . self::$projectUid . ".pmx";
|
||||
|
||||
self::$exporter = new \ProcessMaker\Exporter\XmlExporter(self::$projectUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete project
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
$bpmnWf = \ProcessMaker\Project\Adapter\BpmnWorkflow::load(self::$projectUid);
|
||||
$bpmnWf->remove();
|
||||
|
||||
unlink(self::$filePmx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test export
|
||||
*
|
||||
* @covers \ProcessMaker\Exporter\XmlExporter::export
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function testExport()
|
||||
{
|
||||
$strXml = self::$exporter->export();
|
||||
|
||||
$this->assertTrue(is_string($strXml));
|
||||
$this->assertNotEmpty($strXml);
|
||||
|
||||
return $strXml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test build
|
||||
*
|
||||
* @covers \ProcessMaker\Exporter\XmlExporter::build
|
||||
*
|
||||
* @depends testExport
|
||||
* @param string $strXml Data xml
|
||||
*/
|
||||
public function testBuild($strXml)
|
||||
{
|
||||
//DOMDocument
|
||||
$doc = new \DOMDocument();
|
||||
$doc->loadXML($strXml);
|
||||
|
||||
$nodeRoot = $doc->getElementsByTagName("ProcessMaker-Project")->item(0);
|
||||
$uid = "";
|
||||
|
||||
//Node meta
|
||||
$nodeMeta = $nodeRoot->getElementsByTagName("metadata")->item(0)->getElementsByTagName("meta");
|
||||
|
||||
$this->assertNotEmpty($nodeMeta);
|
||||
|
||||
foreach ($nodeMeta as $value) {
|
||||
$node = $value;
|
||||
|
||||
if ($node->hasAttribute("key") && $node->getAttribute("key") == "uid") {
|
||||
$uid = $node->nodeValue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals(self::$projectUid, $uid);
|
||||
|
||||
//Node definition
|
||||
$nodeDefinition = $nodeRoot->getElementsByTagName("definition");
|
||||
|
||||
$this->assertNotEmpty($nodeDefinition);
|
||||
|
||||
foreach ($nodeDefinition as $value) {
|
||||
$node = $value;
|
||||
|
||||
if ($node->hasAttribute("class")) {
|
||||
$this->assertContains($node->getAttribute("class"), array("BPMN", "workflow"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test saveExport
|
||||
*
|
||||
* @covers \ProcessMaker\Exporter\XmlExporter::saveExport
|
||||
*/
|
||||
public function testSaveExport()
|
||||
{
|
||||
self::$exporter->saveExport(self::$filePmx);
|
||||
|
||||
$this->assertTrue(file_exists(self::$filePmx));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getTextNode
|
||||
*
|
||||
* @covers \ProcessMaker\Exporter\XmlExporter::getTextNode
|
||||
*/
|
||||
public function testGetTextNode()
|
||||
{
|
||||
//Is not implemented. Method getTextNode() is private
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid project uid
|
||||
*
|
||||
* @covers \ProcessMaker\Exporter\XmlExporter::__construct
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Project "ProcessMaker\Project\Bpmn" with UID: 0, does not exist.
|
||||
*/
|
||||
public function test__constructExceptionInvalidProjectUid()
|
||||
{
|
||||
$exporter = new \ProcessMaker\Exporter\XmlExporter("0");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,216 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Importer;
|
||||
|
||||
if (!class_exists("Propel")) {
|
||||
include_once(__DIR__ . "/../../bootstrap.php");
|
||||
}
|
||||
|
||||
/**
|
||||
* Class XmlImporterTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project
|
||||
*/
|
||||
class XmlImporterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $importer;
|
||||
protected static $projectUid = "";
|
||||
protected static $filePmx = "";
|
||||
|
||||
protected static $arrayPrjUid = array();
|
||||
|
||||
/**
|
||||
* Set class for test
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
$json = "
|
||||
{
|
||||
\"prj_name\": \"" . \ProcessMaker\Util\Common::generateUID() . "\",
|
||||
\"prj_author\": \"00000000000000000000000000000001\",
|
||||
\"diagrams\": [
|
||||
{
|
||||
\"dia_uid\": \"\",
|
||||
\"activities\": [],
|
||||
\"events\": [],
|
||||
\"gateways\": [],
|
||||
\"flows\": [],
|
||||
\"artifacts\": [],
|
||||
\"laneset\": [],
|
||||
\"lanes\": []
|
||||
}
|
||||
]
|
||||
}
|
||||
";
|
||||
|
||||
$arrayResult = \ProcessMaker\Project\Adapter\BpmnWorkflow::createFromStruct(json_decode($json, true));
|
||||
|
||||
self::$projectUid = $arrayResult[0]["new_uid"];
|
||||
self::$filePmx = PATH_DOCUMENT . "input" . PATH_SEP . self::$projectUid . ".pmx";
|
||||
|
||||
$exporter = new \ProcessMaker\Exporter\XmlExporter(self::$projectUid);
|
||||
$exporter->saveExport(self::$filePmx);
|
||||
|
||||
$bpmnWf = \ProcessMaker\Project\Adapter\BpmnWorkflow::load(self::$projectUid);
|
||||
$bpmnWf->remove();
|
||||
|
||||
self::$importer = new \ProcessMaker\Importer\XmlImporter();
|
||||
self::$importer->setSourceFile(self::$filePmx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete projects
|
||||
*
|
||||
* @coversNothing
|
||||
*/
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
foreach (self::$arrayPrjUid as $value) {
|
||||
$prjUid = $value;
|
||||
|
||||
$bpmnWf = \ProcessMaker\Project\Adapter\BpmnWorkflow::load($prjUid);
|
||||
$bpmnWf->remove();
|
||||
}
|
||||
|
||||
unlink(self::$filePmx);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test load
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::load
|
||||
*/
|
||||
public function testLoad()
|
||||
{
|
||||
$arrayData = self::$importer->load();
|
||||
|
||||
$this->assertTrue(is_array($arrayData));
|
||||
$this->assertNotEmpty($arrayData);
|
||||
|
||||
$this->assertArrayHasKey("tables", $arrayData);
|
||||
$this->assertArrayHasKey("files", $arrayData);
|
||||
|
||||
$this->assertEquals($arrayData["tables"]["bpmn"]["project"][0]["prj_uid"], self::$projectUid);
|
||||
$this->assertEquals($arrayData["tables"]["workflow"]["process"][0]["PRO_UID"], self::$projectUid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test getTextNode
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::getTextNode
|
||||
*/
|
||||
public function testGetTextNode()
|
||||
{
|
||||
//Is not implemented. Method getTextNode() is private
|
||||
}
|
||||
|
||||
/**
|
||||
* Test import
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::import
|
||||
*/
|
||||
public function testImport()
|
||||
{
|
||||
$prjUid = self::$importer->import();
|
||||
self::$arrayPrjUid[] = $prjUid;
|
||||
|
||||
$this->assertNotNull(\BpmnProjectPeer::retrieveByPK($prjUid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test importPostFile
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::importPostFile
|
||||
*/
|
||||
public function testImportPostFile()
|
||||
{
|
||||
self::$importer->setSaveDir(PATH_DOCUMENT . "input");
|
||||
|
||||
$arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => self::$projectUid . ".pmx"), "KEEP");
|
||||
self::$arrayPrjUid[] = $arrayData["PRJ_UID"];
|
||||
|
||||
$this->assertNotNull(\BpmnProjectPeer::retrieveByPK($arrayData["PRJ_UID"]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception when the project exists
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::import
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Project already exists, you need set an action to continue. Available actions: [project.import.create_new|project.import.override|project.import.disable_and_create_new|project.import.keep_without_changing_and_create_new].
|
||||
*/
|
||||
public function testImportExceptionProjectExists()
|
||||
{
|
||||
$prjUid = self::$importer->import();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for empty data
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::importPostFile
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "$arrayData", it can not be empty.
|
||||
*/
|
||||
public function testImportPostFileExceptionEmptyData()
|
||||
{
|
||||
$arrayData = self::$importer->importPostFile(array());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid extension
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::importPostFile
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The file extension not is "pmx"
|
||||
*/
|
||||
public function testImportPostFileExceptionInvalidExtension()
|
||||
{
|
||||
$arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => "file.pm"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for file does not exist
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::importPostFile
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage The file with PROJECT_FILE: "file.pmx" does not exist.
|
||||
*/
|
||||
public function testImportPostFileExceptionFileNotExists()
|
||||
{
|
||||
$arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => "file.pmx"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception for invalid option
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::importPostFile
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Invalid value for "OPTION", it only accepts values: "CREATE|OVERWRITE|DISABLE|KEEP".
|
||||
*/
|
||||
public function testImportPostFileExceptionInvalidOption()
|
||||
{
|
||||
$arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => "file.pmx"), "CREATED");
|
||||
}
|
||||
|
||||
/**
|
||||
* Test exception when the project exists
|
||||
*
|
||||
* @covers \ProcessMaker\Importer\XmlImporter::importPostFile
|
||||
*
|
||||
* @expectedException Exception
|
||||
* @expectedExceptionMessage Project already exists, you need set an action to continue. Available actions: [CREATE|OVERWRITE|DISABLE|KEEP].
|
||||
*/
|
||||
public function testImportPostFileExceptionProjectExists()
|
||||
{
|
||||
self::$importer->setSaveDir(PATH_DOCUMENT . "input");
|
||||
|
||||
$arrayData = self::$importer->importPostFile(array("PROJECT_FILE" => self::$projectUid . ".pmx"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,713 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Project\Adapter;
|
||||
|
||||
use \ProcessMaker\Project;
|
||||
use \ProcessMaker\Exception;
|
||||
|
||||
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../../../bootstrap.php";
|
||||
}
|
||||
|
||||
/**
|
||||
* Class BpmnWorkflowTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project\Adapter
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class BpmnWorkflowTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $uids = array();
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
//return false;
|
||||
//cleaning DB
|
||||
foreach (self::$uids as $prjUid) {
|
||||
$bwap = Project\Adapter\BpmnWorkflow::load($prjUid);
|
||||
$bwap->remove();
|
||||
}
|
||||
}
|
||||
|
||||
function testNew()
|
||||
{
|
||||
$data = array(
|
||||
"PRJ_NAME" => "Test Bpmn/Workflow Project #1.". rand(1, 100),
|
||||
"PRJ_DESCRIPTION" => "Description for - Test BPMN Project #1." . rand(1, 100),
|
||||
"PRJ_AUTHOR" => "00000000000000000000000000000001"
|
||||
);
|
||||
|
||||
$bwap = new Project\Adapter\BpmnWorkflow($data);
|
||||
|
||||
try {
|
||||
$bp = Project\Bpmn::load($bwap->getUid());
|
||||
} catch (\Exception $e){
|
||||
$bp = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
} catch (\Exception $e){
|
||||
$wp = null;
|
||||
}
|
||||
|
||||
self::$uids[] = $bwap->getUid();
|
||||
|
||||
$this->assertNotNull($bp);
|
||||
$this->assertNotNull($wp);
|
||||
$this->assertEquals($bp->getUid(), $wp->getUid());
|
||||
|
||||
$project = $bp->getProject();
|
||||
$process = $wp->getProcess();
|
||||
|
||||
$this->assertEquals($project["PRJ_NAME"], $process["PRO_TITLE"]);
|
||||
$this->assertEquals($project["PRJ_DESCRIPTION"], $process["PRO_DESCRIPTION"]);
|
||||
$this->assertEquals($project["PRJ_AUTHOR"], $process["PRO_CREATE_USER"]);
|
||||
|
||||
return $bwap;
|
||||
}
|
||||
|
||||
function testCreate()
|
||||
{
|
||||
$data = array(
|
||||
"PRJ_NAME" => "Test Bpmn/Workflow Project #2",
|
||||
"PRJ_DESCRIPTION" => "Description for - Test BPMN Project #2",
|
||||
"PRJ_AUTHOR" => "00000000000000000000000000000001"
|
||||
);
|
||||
|
||||
$bwap = new Project\Adapter\BpmnWorkflow();
|
||||
$bwap->create($data);
|
||||
|
||||
try {
|
||||
$bp = Project\Bpmn::load($bwap->getUid());
|
||||
} catch (\Exception $e){
|
||||
$bp = null;
|
||||
}
|
||||
|
||||
try {
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
} catch (\Exception $e){
|
||||
$wp = null;
|
||||
}
|
||||
|
||||
$this->assertNotEmpty($bp);
|
||||
$this->assertNotEmpty($wp);
|
||||
$this->assertEquals($bp->getUid(), $wp->getUid());
|
||||
|
||||
$project = $bp->getProject();
|
||||
$process = $wp->getProcess();
|
||||
|
||||
$this->assertEquals($project["PRJ_NAME"], $process["PRO_TITLE"]);
|
||||
$this->assertEquals($project["PRJ_DESCRIPTION"], $process["PRO_DESCRIPTION"]);
|
||||
$this->assertEquals($project["PRJ_AUTHOR"], $process["PRO_CREATE_USER"]);
|
||||
|
||||
return $bwap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
*/
|
||||
function testRemove(Project\Adapter\BpmnWorkflow $bwap)
|
||||
{
|
||||
$prjUid = $bwap->getUid();
|
||||
$bwap->remove();
|
||||
$bp = $wp = null;
|
||||
|
||||
try {
|
||||
$bp = Project\Bpmn::load($prjUid);
|
||||
} catch (Exception\ProjectNotFound $e) {}
|
||||
|
||||
try {
|
||||
$wp = Project\Workflow::load($prjUid);
|
||||
} catch (Exception\ProjectNotFound $e) {}
|
||||
|
||||
$this->assertNull($bp);
|
||||
$this->assertNull($wp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Testing Project's Activity
|
||||
*/
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @return string
|
||||
*/
|
||||
function testAddActivity($bwap)
|
||||
{
|
||||
// before add activity, we need to add a diagram and process to the project
|
||||
$bwap->addDiagram();
|
||||
$bwap->addProcess();
|
||||
|
||||
// add the new activity
|
||||
$actUid = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => "50",
|
||||
"BOU_Y" => "50"
|
||||
));
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
|
||||
$activity = $bwap->getActivity($actUid);
|
||||
$task = $wp->getTask($actUid);
|
||||
|
||||
$this->assertEquals($activity["ACT_NAME"], $task["TAS_TITLE"]);
|
||||
$this->assertEquals($activity["BOU_X"], $task["TAS_POSX"]);
|
||||
$this->assertEquals($activity["BOU_Y"], $task["TAS_POSY"]);
|
||||
|
||||
return $actUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testAddActivity
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @param string $actUid
|
||||
*/
|
||||
function testUpdateActivity($bwap, $actUid)
|
||||
{
|
||||
$updatedData = array(
|
||||
"ACT_NAME" => "Activity #1 - (Modified)",
|
||||
"BOU_X" => 122,
|
||||
"BOU_Y" => 250
|
||||
);
|
||||
|
||||
$bwap->updateActivity($actUid, $updatedData);
|
||||
$activity = $bwap->getActivity($actUid);
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
$task = $wp->getTask($actUid);
|
||||
|
||||
$this->assertEquals($activity["ACT_NAME"], $task["TAS_TITLE"]);
|
||||
$this->assertEquals($activity["BOU_X"], $task["TAS_POSX"]);
|
||||
$this->assertEquals($activity["BOU_Y"], $task["TAS_POSY"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testAddActivity
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @param string $actUid
|
||||
*/
|
||||
function testRemoveActivity($bwap, $actUid)
|
||||
{
|
||||
$bwap->removeActivity($actUid);
|
||||
$activity = $bwap->getActivity($actUid);
|
||||
|
||||
$this->assertNull($activity);
|
||||
}
|
||||
|
||||
/*
|
||||
* Testing Project's Flows
|
||||
*/
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @return string
|
||||
*/
|
||||
function testAddActivityToActivityFlow($bwap)
|
||||
{
|
||||
$actUid1 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => 122,
|
||||
"BOU_Y" => 222
|
||||
));
|
||||
$actUid2 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #2",
|
||||
"BOU_X" => 322,
|
||||
"BOU_Y" => 422
|
||||
));
|
||||
|
||||
$flowData = array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $actUid1,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $actUid2,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 326,
|
||||
'FLO_Y1' => 146,
|
||||
'FLO_X2' => 461,
|
||||
'FLO_Y2' => 146,
|
||||
);
|
||||
|
||||
$flowUid = $bwap->addFlow($flowData);
|
||||
$bwap->mapBpmnFlowsToWorkflowRoutes();
|
||||
|
||||
$route = \Route::findOneBy(array(
|
||||
\RoutePeer::TAS_UID => $actUid1,
|
||||
\RoutePeer::ROU_NEXT_TASK => $actUid2
|
||||
));
|
||||
|
||||
$this->assertNotNull($route);
|
||||
$this->assertTrue(is_string($flowUid));
|
||||
$this->assertEquals(32, strlen($flowUid));
|
||||
$this->assertEquals($route->getRouNextTask(), $actUid2);
|
||||
$this->assertEquals($route->getRouType(), "SEQUENTIAL");
|
||||
|
||||
return array("flow_uid" => $flowUid, "activitiesUid" => array($actUid1, $actUid2));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testAddActivityToActivityFlow
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @param array $input
|
||||
*/
|
||||
function testRemoveActivityToActivityFlow($bwap, $input)
|
||||
{
|
||||
$bwap->removeFlow($input["flow_uid"]);
|
||||
$this->assertNull($bwap->getFlow($input["flow_uid"]));
|
||||
|
||||
$route = \Route::findOneBy(array(
|
||||
\RoutePeer::TAS_UID => $input["activitiesUid"][0],
|
||||
\RoutePeer::ROU_NEXT_TASK => $input["activitiesUid"][1]
|
||||
));
|
||||
|
||||
$this->assertNull($route);
|
||||
|
||||
// cleaning
|
||||
$bwap->removeActivity($input["activitiesUid"][0]);
|
||||
$bwap->removeActivity($input["activitiesUid"][1]);
|
||||
|
||||
$this->assertCount(0, $bwap->getActivities());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
*/
|
||||
function testActivityToInclusiveGatewayToActivityFlowsSingle($bwap)
|
||||
{
|
||||
$actUid1 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => 198,
|
||||
"BOU_Y" => 56
|
||||
));
|
||||
$actUid2 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #2",
|
||||
"BOU_X" => 198,
|
||||
"BOU_Y" => 250
|
||||
));
|
||||
$gatUid = $bwap->addGateway(array(
|
||||
"GAT_NAME" => "Gateway #1",
|
||||
"GAT_TYPE" => "INCLUSIVE",
|
||||
"GAT_DIRECTION" => "DIVERGING",
|
||||
"BOU_X" => 256,
|
||||
"BOU_Y" => 163
|
||||
));
|
||||
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $actUid1,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $gatUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway',
|
||||
'FLO_X1' => 273,
|
||||
'FLO_Y1' => 273,
|
||||
'FLO_X2' => 163,
|
||||
'FLO_Y2' => 163,
|
||||
));
|
||||
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $gatUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway',
|
||||
'FLO_ELEMENT_DEST' => $actUid2,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 273,
|
||||
'FLO_Y1' => 273,
|
||||
'FLO_X2' => 249,
|
||||
'FLO_Y2' => 249,
|
||||
));
|
||||
|
||||
$bwap->mapBpmnFlowsToWorkflowRoutes();
|
||||
|
||||
$this->assertCount(2, $bwap->getActivities());
|
||||
$this->assertCount(1, $bwap->getGateways());
|
||||
$this->assertCount(2, $bwap->getFlows());
|
||||
|
||||
$flows1 = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid);
|
||||
$flows2 = \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid);
|
||||
|
||||
$this->assertCount(1, $flows1);
|
||||
$this->assertCount(1, $flows2);
|
||||
$this->assertEquals($flows1[0]->getFloElementOrigin(), $actUid1);
|
||||
$this->assertEquals($flows2[0]->getFloElementDest(), $actUid2);
|
||||
|
||||
// cleaning
|
||||
$this->resetProject($bwap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
*/
|
||||
function testActivityToInclusiveGatewayToActivityFlowsMultiple($bwap)
|
||||
{
|
||||
$actUid1 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => 311,
|
||||
"BOU_Y" => 26
|
||||
));
|
||||
$actUid2 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #2",
|
||||
"BOU_X" => 99,
|
||||
"BOU_Y" => 200
|
||||
));
|
||||
$actUid3 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #3",
|
||||
"BOU_X" => 310,
|
||||
"BOU_Y" => 200
|
||||
));
|
||||
$actUid4 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #4",
|
||||
"BOU_X" => 542,
|
||||
"BOU_Y" => 200
|
||||
));
|
||||
$gatUid = $bwap->addGateway(array(
|
||||
"GAT_NAME" => "Gateway #1",
|
||||
"GAT_TYPE" => "INCLUSIVE",
|
||||
"GAT_DIRECTION" => "DIVERGING",
|
||||
"BOU_X" => 369,
|
||||
"BOU_Y" => 123
|
||||
));
|
||||
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $actUid1,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $gatUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway',
|
||||
'FLO_X1' => 386,
|
||||
'FLO_Y1' => 174,
|
||||
'FLO_X2' => 206,
|
||||
'FLO_Y2' => 206,
|
||||
));
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $gatUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway',
|
||||
'FLO_ELEMENT_DEST' => $actUid2,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 273,
|
||||
'FLO_Y1' => 273,
|
||||
'FLO_X2' => 249,
|
||||
'FLO_Y2' => 249,
|
||||
));
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $gatUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway',
|
||||
'FLO_ELEMENT_DEST' => $actUid3,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 386,
|
||||
'FLO_Y1' => 174,
|
||||
'FLO_X2' => 206,
|
||||
'FLO_Y2' => 206,
|
||||
));
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $gatUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway',
|
||||
'FLO_ELEMENT_DEST' => $actUid4,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 386,
|
||||
'FLO_Y1' => 617,
|
||||
'FLO_X2' => 207,
|
||||
'FLO_Y2' => 207,
|
||||
));
|
||||
|
||||
$bwap->mapBpmnFlowsToWorkflowRoutes();
|
||||
|
||||
$this->assertCount(4, $bwap->getActivities());
|
||||
$this->assertCount(1, $bwap->getGateways());
|
||||
$this->assertCount(4, $bwap->getFlows());
|
||||
$this->assertCount(1, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid));
|
||||
$this->assertCount(3, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid));
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
|
||||
$this->assertCount(4, $wp->getTasks());
|
||||
$this->assertCount(3, $wp->getRoutes());
|
||||
$this->assertCount(3, \Route::findAllBy(\RoutePeer::TAS_UID, $actUid1));
|
||||
$this->assertCount(1, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid2));
|
||||
$this->assertCount(1, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid3));
|
||||
$this->assertCount(1, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid4));
|
||||
|
||||
return array($actUid2, $actUid3, $actUid4);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testActivityToInclusiveGatewayToActivityFlowsMultiple
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @param array $activitiesUid
|
||||
*/
|
||||
function testActivityToInclusiveGatewayToActivityFlowsMultipleJoin($bwap, $activitiesUid)
|
||||
{
|
||||
$gatUid = $bwap->addGateway(array(
|
||||
"GAT_NAME" => "Gateway #2",
|
||||
"GAT_TYPE" => "INCLUSIVE",
|
||||
"GAT_DIRECTION" => "CONVERGING",
|
||||
"BOU_X" => 369,
|
||||
"BOU_Y" => 338
|
||||
));
|
||||
$actUid5 = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #5",
|
||||
"BOU_X" => 312,
|
||||
"BOU_Y" => 464
|
||||
));
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $activitiesUid[0],
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $gatUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway',
|
||||
'FLO_X1' => 174,
|
||||
'FLO_Y1' => 365,
|
||||
'FLO_X2' => 355,
|
||||
'FLO_Y2' => 355,
|
||||
));
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $activitiesUid[1],
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $gatUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway',
|
||||
'FLO_X1' => 385,
|
||||
'FLO_Y1' => 382,
|
||||
'FLO_X2' => 338,
|
||||
'FLO_Y2' => 338,
|
||||
));
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $activitiesUid[2],
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $gatUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnGateway',
|
||||
'FLO_X1' => 617,
|
||||
'FLO_Y1' => 398,
|
||||
'FLO_X2' => 355,
|
||||
'FLO_Y2' => 355,
|
||||
));
|
||||
|
||||
$bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $gatUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnGateway',
|
||||
'FLO_ELEMENT_DEST' => $actUid5,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 382,
|
||||
'FLO_Y1' => 387,
|
||||
'FLO_X2' => 463,
|
||||
'FLO_Y2' => 463,
|
||||
));
|
||||
|
||||
$bwap->mapBpmnFlowsToWorkflowRoutes();
|
||||
|
||||
$this->assertCount(8, $bwap->getFlows());
|
||||
$this->assertCount(5, $bwap->getActivities());
|
||||
$this->assertCount(2, $bwap->getGateways());
|
||||
$this->assertCount(3, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_DEST, $gatUid));
|
||||
$this->assertCount(1, \BpmnFlow::findAllBy(\BpmnFlowPeer::FLO_ELEMENT_ORIGIN, $gatUid));
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
|
||||
$this->assertCount(5, $wp->getTasks());
|
||||
$this->assertCount(6, $wp->getRoutes());
|
||||
|
||||
$this->assertCount(1, \Route::findAllBy(\RoutePeer::TAS_UID, $activitiesUid[0]));
|
||||
$this->assertCount(1, \Route::findAllBy(\RoutePeer::TAS_UID, $activitiesUid[1]));
|
||||
$this->assertCount(1, \Route::findAllBy(\RoutePeer::TAS_UID, $activitiesUid[2]));
|
||||
$this->assertCount(3, \Route::findAllBy(\RoutePeer::ROU_NEXT_TASK, $actUid5));
|
||||
|
||||
// cleaning
|
||||
$this->resetProject($bwap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @return string
|
||||
*/
|
||||
function testSetStartEvent($bwap)
|
||||
{
|
||||
$actUid = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => 312,
|
||||
"BOU_Y" => 464
|
||||
));
|
||||
$evnUid = $bwap->addEvent(array(
|
||||
"EVN_NAME" => "Event #1",
|
||||
"EVN_TYPE" => "START",
|
||||
"BOU_X" => 369,
|
||||
"BOU_Y" => 338,
|
||||
"EVN_MARKER" => "MESSAGE",
|
||||
"EVN_MESSAGE" => "LEAD"
|
||||
));
|
||||
$floUid = $bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $evnUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnEvent',
|
||||
'FLO_ELEMENT_DEST' => $actUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnActivity',
|
||||
'FLO_X1' => 174,
|
||||
'FLO_Y1' => 365,
|
||||
'FLO_X2' => 355,
|
||||
'FLO_Y2' => 355,
|
||||
));
|
||||
|
||||
$this->assertCount(1, $bwap->getActivities());
|
||||
$this->assertCount(1, $bwap->getEvents());
|
||||
$this->assertCount(1, $bwap->getFlows());
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
$task = $wp->getTask($actUid);
|
||||
|
||||
$this->assertCount(1, $wp->getTasks());
|
||||
$this->assertCount(0, $wp->getRoutes());
|
||||
$this->assertNotNull($task);
|
||||
|
||||
$this->assertEquals($task["TAS_START"], "TRUE");
|
||||
|
||||
return $floUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testSetStartEvent
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @param string $floUid
|
||||
*/
|
||||
function testUnsetStartEvent($bwap, $floUid)
|
||||
{
|
||||
$bwap->removeFlow($floUid);
|
||||
|
||||
$this->assertCount(1, $bwap->getActivities());
|
||||
$this->assertCount(1, $bwap->getEvents());
|
||||
$this->assertCount(0, $bwap->getFlows());
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertCount(1, $tasks);
|
||||
$this->assertCount(0, $wp->getRoutes());
|
||||
$this->assertEquals($tasks[0]["TAS_START"], "FALSE");
|
||||
|
||||
// cleaning
|
||||
$this->resetProject($bwap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
*/
|
||||
function testSetEndEvent($bwap)
|
||||
{
|
||||
$actUid = $bwap->addActivity(array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => 312,
|
||||
"BOU_Y" => 464
|
||||
));
|
||||
$evnUid = $bwap->addEvent(array(
|
||||
"EVN_NAME" => "Event #1",
|
||||
"EVN_TYPE" => "END",
|
||||
"BOU_X" => 369,
|
||||
"BOU_Y" => 338,
|
||||
"EVN_MARKER" => "MESSAGE",
|
||||
"EVN_MESSAGE" => "LEAD"
|
||||
));
|
||||
$floUid = $bwap->addFlow(array(
|
||||
'FLO_TYPE' => 'SEQUENCE',
|
||||
'FLO_ELEMENT_ORIGIN' => $actUid,
|
||||
'FLO_ELEMENT_ORIGIN_TYPE' => 'bpmnActivity',
|
||||
'FLO_ELEMENT_DEST' => $evnUid,
|
||||
'FLO_ELEMENT_DEST_TYPE' => 'bpmnEvent',
|
||||
'FLO_X1' => 174,
|
||||
'FLO_Y1' => 365,
|
||||
'FLO_X2' => 355,
|
||||
'FLO_Y2' => 355,
|
||||
));
|
||||
|
||||
$this->assertCount(1, $bwap->getActivities());
|
||||
$this->assertCount(1, $bwap->getEvents());
|
||||
$this->assertCount(1, $bwap->getFlows());
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
$task = $wp->getTask($actUid);
|
||||
|
||||
$this->assertCount(1, $wp->getTasks());
|
||||
$this->assertCount(1, $wp->getRoutes());
|
||||
$this->assertNotNull($task);
|
||||
|
||||
$routes = \Route::findAllBy(\RoutePeer::TAS_UID, $task["TAS_UID"]);
|
||||
|
||||
$this->assertCount(1, $routes);
|
||||
$this->assertEquals($routes[0]->getRouNextTask(), "-1");
|
||||
|
||||
return $floUid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @depends testSetEndEvent
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
* @param $floUid
|
||||
*/
|
||||
function testUnsetEndEvent($bwap, $floUid)
|
||||
{
|
||||
$bwap->removeFlow($floUid);
|
||||
|
||||
$this->assertCount(1, $bwap->getActivities());
|
||||
$this->assertCount(1, $bwap->getEvents());
|
||||
$this->assertCount(0, $bwap->getFlows());
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
|
||||
$this->assertCount(1, $wp->getTasks());
|
||||
$this->assertCount(0, $wp->getRoutes());
|
||||
|
||||
// cleaning
|
||||
$this->resetProject($bwap);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \ProcessMaker\Project\Adapter\BpmnWorkflow $bwap
|
||||
*/
|
||||
protected function resetProject(\ProcessMaker\Project\Adapter\BpmnWorkflow $bwap)
|
||||
{
|
||||
// cleaning
|
||||
$activities = $bwap->getActivities();
|
||||
foreach ($activities as $activity) {
|
||||
$bwap->removeActivity($activity["ACT_UID"]);
|
||||
}
|
||||
$events = $bwap->getEvents();
|
||||
foreach ($events as $event) {
|
||||
$bwap->removeEvent($event["EVN_UID"]);
|
||||
}
|
||||
$gateways = $bwap->getGateways();
|
||||
foreach ($gateways as $gateway) {
|
||||
$bwap->removeGateway($gateway["GAT_UID"]);
|
||||
}
|
||||
$flows = $bwap->getFlows();
|
||||
foreach ($flows as $flow) {
|
||||
$bwap->removeFlow($flow["FLO_UID"]);
|
||||
}
|
||||
|
||||
// verifying that project is cleaned
|
||||
$this->assertCount(0, $bwap->getActivities());
|
||||
$this->assertCount(0, $bwap->getEvents());
|
||||
$this->assertCount(0, $bwap->getGateways());
|
||||
$this->assertCount(0, $bwap->getFlows());
|
||||
|
||||
$wp = Project\Workflow::load($bwap->getUid());
|
||||
|
||||
$this->assertCount(0, $wp->getTasks());
|
||||
$this->assertCount(0, $wp->getRoutes());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Project\Adapter;
|
||||
|
||||
use \ProcessMaker\Project;
|
||||
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../../../bootstrap.php";
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowBpmnTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project\Adapter
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class WorkflowBpmnTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $uids = array();
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
//cleaning DB
|
||||
foreach (self::$uids as $prjUid) {
|
||||
$wbpa = Project\Adapter\WorkflowBpmn::load($prjUid);
|
||||
$wbpa->remove();
|
||||
}
|
||||
}
|
||||
|
||||
function testNew()
|
||||
{
|
||||
$data = array(
|
||||
"PRO_TITLE" => "Test Workflow/Bpmn Project #1",
|
||||
"PRO_DESCRIPTION" => "Description for - Test Project #1",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
);
|
||||
|
||||
$wbap = new Project\Adapter\WorkflowBpmn($data);
|
||||
|
||||
try {
|
||||
$bp = Project\Bpmn::load($wbap->getUid());
|
||||
} catch (\Exception $e){die($e->getMessage());}
|
||||
|
||||
try {
|
||||
$wp = Project\Workflow::load($wbap->getUid());
|
||||
} catch (\Exception $e){}
|
||||
|
||||
self::$uids[] = $wbap->getUid();
|
||||
|
||||
$this->assertNotNull($bp);
|
||||
$this->assertNotNull($wp);
|
||||
$this->assertEquals($bp->getUid(), $wp->getUid());
|
||||
|
||||
$project = $bp->getProject();
|
||||
$process = $wp->getProcess();
|
||||
|
||||
$this->assertEquals($project["PRJ_NAME"], $process["PRO_TITLE"]);
|
||||
$this->assertEquals($project["PRJ_DESCRIPTION"], $process["PRO_DESCRIPTION"]);
|
||||
$this->assertEquals($project["PRJ_AUTHOR"], $process["PRO_CREATE_USER"]);
|
||||
}
|
||||
|
||||
function testCreate()
|
||||
{
|
||||
$data = array(
|
||||
"PRO_TITLE" => "Test Workflow/Bpmn Project #2",
|
||||
"PRO_DESCRIPTION" => "Description for - Test Project #2",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
);
|
||||
$wbap = new Project\Adapter\WorkflowBpmn();
|
||||
$wbap->create($data);
|
||||
|
||||
try {
|
||||
$bp = Project\Bpmn::load($wbap->getUid());
|
||||
} catch (\Exception $e){}
|
||||
|
||||
try {
|
||||
$wp = Project\Workflow::load($wbap->getUid());
|
||||
} catch (\Exception $e){}
|
||||
|
||||
self::$uids[] = $wbap->getUid();
|
||||
|
||||
$this->assertNotEmpty($bp);
|
||||
$this->assertNotEmpty($wp);
|
||||
$this->assertEquals($bp->getUid(), $wp->getUid());
|
||||
|
||||
$project = $bp->getProject();
|
||||
$process = $wp->getProcess();
|
||||
|
||||
$this->assertEquals($project["PRJ_NAME"], $process["PRO_TITLE"]);
|
||||
$this->assertEquals($project["PRJ_DESCRIPTION"], $process["PRO_DESCRIPTION"]);
|
||||
$this->assertEquals($project["PRJ_AUTHOR"], $process["PRO_CREATE_USER"]);
|
||||
}
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Project;
|
||||
|
||||
use \ProcessMaker\Project;
|
||||
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../../bootstrap.php";
|
||||
}
|
||||
|
||||
/**
|
||||
* Class BpmnTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class BpmnTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $prjUids = array();
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
//return;
|
||||
|
||||
//cleaning DB
|
||||
foreach (self::$prjUids as $prjUid) {
|
||||
$bp = Project\Bpmn::load($prjUid);
|
||||
$bp->remove();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$data = array(
|
||||
"PRJ_NAME" => "Test BPMN Project #1",
|
||||
"PRJ_DESCRIPTION" => "Description for - Test BPMN Project #1",
|
||||
"PRJ_AUTHOR" => "00000000000000000000000000000001"
|
||||
);
|
||||
|
||||
// Create a new Project\Bpmn and save to DB
|
||||
$bp = new Project\Bpmn($data);
|
||||
$projectData = $bp->getProject();
|
||||
self::$prjUids[] = $bp->getUid();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($value, $projectData[$key]);
|
||||
}
|
||||
|
||||
return $bp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @var $bp \ProcessMaker\Project\Bpmn
|
||||
*/
|
||||
public function testAddDiagram($bp)
|
||||
{
|
||||
$data = array(
|
||||
"DIA_NAME" => "Sample Diagram #1"
|
||||
);
|
||||
|
||||
// Save to DB
|
||||
$bp->addDiagram($data);
|
||||
|
||||
// Load from DB
|
||||
$diagramData = $bp->getDiagram();
|
||||
|
||||
$this->assertEquals($data["DIA_NAME"], $diagramData["DIA_NAME"]);
|
||||
$this->assertEquals($bp->getUid(), $diagramData["PRJ_UID"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @var $bp \ProcessMaker\Project\Bpmn
|
||||
*/
|
||||
public function testAddProcess($bp)
|
||||
{
|
||||
$data = array(
|
||||
"PRO_NAME" => "Sample Process #1"
|
||||
);
|
||||
|
||||
$diagramData = $bp->getDiagram();
|
||||
|
||||
// Save to DB
|
||||
$bp->addProcess($data);
|
||||
|
||||
// Load from DB
|
||||
$processData = $bp->getProcess();
|
||||
|
||||
$this->assertEquals($data["PRO_NAME"], $processData["PRO_NAME"]);
|
||||
$this->assertEquals($bp->getUid(), $processData["PRJ_UID"]);
|
||||
$this->assertEquals($diagramData['DIA_UID'], $processData["DIA_UID"]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @var $bp \ProcessMaker\Project\Bpmn
|
||||
*/
|
||||
public function testAddActivity($bp)
|
||||
{
|
||||
$data = array(
|
||||
"ACT_NAME" => "Activity #1",
|
||||
"BOU_X" => "50",
|
||||
"BOU_Y" => "50"
|
||||
);
|
||||
|
||||
// Save to DB
|
||||
$bp->addActivity($data);
|
||||
|
||||
// Load from DB
|
||||
$activities = $bp->getActivities();
|
||||
|
||||
$this->assertCount(1, $activities);
|
||||
|
||||
$activityData = $activities[0];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($value, $activityData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @param $bp \ProcessMaker\Project\Bpmn
|
||||
* @return array
|
||||
*/
|
||||
public function testAddActivityWithUid($bp)
|
||||
{
|
||||
$actUid = "f1198ddc864204561817155064020352";
|
||||
|
||||
$data = array(
|
||||
"ACT_UID" => $actUid,
|
||||
"ACT_NAME" => "Activity #X",
|
||||
"BOU_X" => "50",
|
||||
"BOU_Y" => "50"
|
||||
);
|
||||
|
||||
// Save to DB
|
||||
$bp->addActivity($data);
|
||||
|
||||
// Load from DB
|
||||
$activities = $bp->getActivities();
|
||||
|
||||
$uids = array();
|
||||
|
||||
foreach ($activities as $activity) {
|
||||
array_push($uids, $activity["ACT_UID"]);
|
||||
}
|
||||
|
||||
$this->assertTrue(in_array($actUid, $uids));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @depends testAddActivityWithUid
|
||||
* @param $bp \ProcessMaker\Project\Bpmn
|
||||
* @param $data
|
||||
*/
|
||||
public function testGetActivity($bp, $data)
|
||||
{
|
||||
// Load from DB
|
||||
$activityData = $bp->getActivity($data["ACT_UID"]);
|
||||
|
||||
// in data is set a determined UID for activity created in previous step
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($value, $activityData[$key]);
|
||||
}
|
||||
|
||||
// Testing with an invalid uid
|
||||
$this->assertNull($bp->getActivity("INVALID-UID"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @depends testAddActivityWithUid
|
||||
* @param $bp \ProcessMaker\Project\Bpmn
|
||||
* @param $data
|
||||
*/
|
||||
public function testUpdateActivity($bp, $data)
|
||||
{
|
||||
$updateData = array(
|
||||
"ACT_NAME" => "Activity #X (Updated)",
|
||||
"BOU_X" => "251",
|
||||
"BOU_Y" => "252"
|
||||
);
|
||||
|
||||
// Save to DB
|
||||
$bp->updateActivity($data["ACT_UID"], $updateData);
|
||||
|
||||
// Load from DB
|
||||
$activityData = $bp->getActivity($data["ACT_UID"]);
|
||||
|
||||
foreach ($updateData as $key => $value) {
|
||||
$this->assertEquals($value, $activityData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
* @depends testAddActivityWithUid
|
||||
* @param $bp \ProcessMaker\Project\Bpmn
|
||||
* @param $data
|
||||
*/
|
||||
public function testRemoveActivity($bp, $data)
|
||||
{
|
||||
$this->assertCount(2, $bp->getActivities());
|
||||
|
||||
$bp->removeActivity($data["ACT_UID"]);
|
||||
|
||||
$this->assertCount(1, $bp->getActivities());
|
||||
}
|
||||
|
||||
public function testGetActivities()
|
||||
{
|
||||
// Create a new Project\Bpmn and save to DB
|
||||
$bp = new Project\Bpmn(array(
|
||||
"PRJ_NAME" => "Test BPMN Project #2",
|
||||
"PRJ_DESCRIPTION" => "Description for - Test BPMN Project #1",
|
||||
"PRJ_AUTHOR" => "00000000000000000000000000000001"
|
||||
));
|
||||
$bp->addDiagram();
|
||||
$bp->addProcess();
|
||||
|
||||
$this->assertCount(0, $bp->getActivities());
|
||||
|
||||
// Save to DB
|
||||
$bp->addActivity(array(
|
||||
"ACT_NAME" => "Activity #2",
|
||||
"BOU_X" => "50",
|
||||
"BOU_Y" => "50"
|
||||
));
|
||||
|
||||
$bp->addActivity(array(
|
||||
"ACT_NAME" => "Activity #3",
|
||||
"BOU_X" => "50",
|
||||
"BOU_Y" => "50"
|
||||
));
|
||||
|
||||
$this->assertCount(2, $bp->getActivities());
|
||||
|
||||
return $bp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testGetActivities
|
||||
* @param $bp \ProcessMaker\Project\Bpmn
|
||||
* @return null|\ProcessMaker\Project\Bpmn
|
||||
*/
|
||||
public function testLoad($bp)
|
||||
{
|
||||
$prjUid = $bp->getUid();
|
||||
$bp2 = Project\Bpmn::load($prjUid);
|
||||
|
||||
$this->assertNotNull($bp2);
|
||||
$this->assertEquals($bp->getActivities(), $bp2->getActivities());
|
||||
$this->assertEquals($bp->getDiagram(), $bp2->getDiagram());
|
||||
$this->assertEquals($bp->getProcess(), $bp2->getProcess());
|
||||
|
||||
return $bp2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testLoad
|
||||
* @param $bp \ProcessMaker\Project\Bpmn
|
||||
* @expectedException \ProcessMaker\Exception\ProjectNotFound
|
||||
* @expectedExceptionCode 20
|
||||
*/
|
||||
public function testRemove($bp)
|
||||
{
|
||||
$prjUid = $bp->getUid();
|
||||
$bp->remove();
|
||||
|
||||
Project\Bpmn::load($prjUid);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,287 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Project;
|
||||
|
||||
use \ProcessMaker\Project;
|
||||
|
||||
if (! class_exists("Propel")) {
|
||||
include_once __DIR__ . "/../../bootstrap.php";
|
||||
}
|
||||
|
||||
/**
|
||||
* Class WorkflowTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class WorkflowTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected static $proUids = array();
|
||||
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
//cleaning DB
|
||||
foreach (self::$proUids as $proUid) {
|
||||
$wp = Project\Workflow::load($proUid);
|
||||
$wp->remove();
|
||||
}
|
||||
}
|
||||
|
||||
public function testCreate()
|
||||
{
|
||||
$data = array(
|
||||
"PRO_TITLE" => "Test Project #1",
|
||||
"PRO_DESCRIPTION" => "Description for - Test Project #1",
|
||||
"PRO_CATEGORY" => "",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
);
|
||||
|
||||
$wp = new Project\Workflow($data);
|
||||
self::$proUids[] = $wp->getUid();
|
||||
|
||||
$processData = $wp->getProcess();
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($data[$key], $processData[$key]);
|
||||
}
|
||||
|
||||
return $wp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testAddTask($wp)
|
||||
{
|
||||
$data = array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_DESCRIPTION" => "Description for task #1",
|
||||
"TAS_POSX" => "50",
|
||||
"TAS_POSY" => "50",
|
||||
"TAS_WIDTH" => "100",
|
||||
"TAS_HEIGHT" => "25"
|
||||
);
|
||||
|
||||
$tasUid = $wp->addTask($data);
|
||||
|
||||
$taskData = $wp->getTask($tasUid);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($data[$key], $taskData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testUpdateTask($wp)
|
||||
{
|
||||
$data = array(
|
||||
"TAS_TITLE" => "task #1 (updated)",
|
||||
"TAS_POSX" => "150",
|
||||
"TAS_POSY" => "250"
|
||||
);
|
||||
|
||||
// at this time, there is only one task
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
|
||||
$wp->updateTask($tasks[0]['TAS_UID'], $data);
|
||||
$taskData = $wp->getTask($tasks[0]['TAS_UID']);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
$this->assertEquals($data[$key], $taskData[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testRemoveTask($wp)
|
||||
{
|
||||
$tasUid = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "150",
|
||||
"TAS_POSY" => "250"
|
||||
));
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$wp->removeTask($tasUid);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCreate
|
||||
*/
|
||||
public function testGetTasks($wp)
|
||||
{
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "250",
|
||||
"TAS_POSY" => "250"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #3",
|
||||
"TAS_POSX" => "350",
|
||||
"TAS_POSY" => "350"
|
||||
));
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(3, $tasks);
|
||||
|
||||
$wp->removeTask($tasUid1);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(2, $tasks);
|
||||
|
||||
$wp->removeTask($tasUid2);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(1, $tasks);
|
||||
|
||||
$wp->removeTask($tasks[0]['TAS_UID']);
|
||||
|
||||
$tasks = $wp->getTasks();
|
||||
$this->assertInternalType('array', $tasks);
|
||||
$this->assertCount(0, $tasks);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public function testAddRoute()
|
||||
{
|
||||
$wp = new Project\Workflow(array(
|
||||
"PRO_TITLE" => "Test Project #2 (Sequential)",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
));
|
||||
|
||||
self::$proUids[] = $wp->getUid();
|
||||
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_POSX" => "410",
|
||||
"TAS_POSY" => "61"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "159",
|
||||
"TAS_POSY" => "370"
|
||||
));
|
||||
|
||||
$rouUid = $wp->addRoute($tasUid1, $tasUid2, "SEQUENTIAL");
|
||||
|
||||
$routeSaved = $wp->getRoute($rouUid);
|
||||
|
||||
$this->assertEquals($tasUid1, $routeSaved['TAS_UID']);
|
||||
$this->assertEquals($tasUid2, $routeSaved['ROU_NEXT_TASK']);
|
||||
$this->assertEquals("SEQUENTIAL", $routeSaved['ROU_TYPE']);
|
||||
}
|
||||
|
||||
public function testAddSelectRoute()
|
||||
{
|
||||
$wp = new Project\Workflow(array(
|
||||
"PRO_TITLE" => "Test Project #3 (Select)",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
));
|
||||
self::$proUids[] = $wp->getUid();
|
||||
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_POSX" => "410",
|
||||
"TAS_POSY" => "61"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "159",
|
||||
"TAS_POSY" => "370"
|
||||
));
|
||||
$tasUid3 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #3",
|
||||
"TAS_POSX" => "670",
|
||||
"TAS_POSY" => "372"
|
||||
));
|
||||
|
||||
$wp->addSelectRoute($tasUid1, array($tasUid2, $tasUid3));
|
||||
}
|
||||
|
||||
public function testCompleteWorkflowProject()
|
||||
{
|
||||
$wp = new Project\Workflow(array(
|
||||
"PRO_TITLE" => "Test Complete Project #4",
|
||||
"PRO_CREATE_USER" => "00000000000000000000000000000001"
|
||||
));
|
||||
|
||||
$tasUid1 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #1",
|
||||
"TAS_POSX" => "406",
|
||||
"TAS_POSY" => "71"
|
||||
));
|
||||
$tasUid2 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #2",
|
||||
"TAS_POSX" => "188",
|
||||
"TAS_POSY" => "240"
|
||||
));
|
||||
$tasUid3 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #3",
|
||||
"TAS_POSX" => "406",
|
||||
"TAS_POSY" => "239"
|
||||
));
|
||||
$tasUid4 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #4",
|
||||
"TAS_POSX" => "294",
|
||||
"TAS_POSY" => "366"
|
||||
));
|
||||
$tasUid5 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #5",
|
||||
"TAS_POSX" => "640",
|
||||
"TAS_POSY" => "240"
|
||||
));
|
||||
$tasUid6 = $wp->addTask(array(
|
||||
"TAS_TITLE" => "task #6",
|
||||
"TAS_POSX" => "640",
|
||||
"TAS_POSY" => "359"
|
||||
));
|
||||
|
||||
|
||||
$wp->addRoute($tasUid1, $tasUid2, "PARALLEL");
|
||||
$wp->addRoute($tasUid1, $tasUid3, "PARALLEL");
|
||||
$wp->addRoute($tasUid1, $tasUid5, "PARALLEL");
|
||||
|
||||
$wp->addRoute($tasUid2, $tasUid4, "SEC-JOIN");
|
||||
$wp->addRoute($tasUid3, $tasUid4, "SEC-JOIN");
|
||||
|
||||
$wp->addRoute($tasUid5, $tasUid6, "EVALUATE");
|
||||
$wp->addRoute($tasUid5, "-1", "EVALUATE");
|
||||
|
||||
$wp->setStartTask($tasUid1);
|
||||
|
||||
$wp->setEndTask($tasUid4);
|
||||
$wp->setEndTask($tasUid6);
|
||||
|
||||
return $wp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testCompleteWorkflowProject
|
||||
* @param $wp \ProcessMaker\Project\Workflow
|
||||
* @expectedException \ProcessMaker\Exception\ProjectNotFound
|
||||
* @expectedExceptionCode 20
|
||||
*/
|
||||
public function testRemove($wp)
|
||||
{
|
||||
$proUid = $wp->getUid();
|
||||
$wp->remove();
|
||||
|
||||
Project\Workflow::load($proUid);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?php
|
||||
namespace Tests\ProcessMaker\Util;
|
||||
|
||||
|
||||
use ProcessMaker\Util;
|
||||
|
||||
/**
|
||||
* Class XmlExporterTest
|
||||
*
|
||||
* @package Tests\ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class XmlExporterTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
function testGetLastVersion()
|
||||
{
|
||||
$lastVer = Util\Common::getLastVersion(__DIR__."/../../fixtures/files_struct/first/sample-*.txt");
|
||||
$this->assertEquals(3, $lastVer);
|
||||
}
|
||||
|
||||
function testGetLastVersionSec()
|
||||
{
|
||||
$lastVer = Util\Common::getLastVersion(__DIR__."/../../fixtures/files_struct/second/sample-*.txt");
|
||||
|
||||
$this->assertEquals(5, $lastVer);
|
||||
}
|
||||
|
||||
function testGetLastVersionThr()
|
||||
{
|
||||
$lastVer = Util\Common::getLastVersion(__DIR__."/../../fixtures/files_struct/third/sample-*.txt");
|
||||
|
||||
$this->assertEquals("3.1.9", $lastVer);
|
||||
}
|
||||
|
||||
/**
|
||||
* Negative test, no matched files found
|
||||
*/
|
||||
function testGetLastVersionOther()
|
||||
{
|
||||
$lastVer = Util\Common::getLastVersion(sys_get_temp_dir()."/sample-*.txt");
|
||||
|
||||
$this->assertEquals(0, $lastVer);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
<?php
|
||||
|
||||
include "pm-bootstrap.php";
|
||||
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
|
||||
pm_home_dir = "/Users/erik/devel/colosa/processmaker"
|
||||
workspace = workflow
|
||||
lang = en
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1 +0,0 @@
|
||||
file sample-1.txt
|
||||
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// pm-bootstrap.php
|
||||
//
|
||||
|
||||
/*
|
||||
* PmBootstrap for Test Unit Suite
|
||||
*
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
|
||||
$config = parse_ini_file(__DIR__ . DIRECTORY_SEPARATOR . "config.ini");
|
||||
|
||||
$workspace = $config['workspace'];
|
||||
$lang = $config['lang'];
|
||||
$processMakerHome = $config['pm_home_dir'];
|
||||
$rootDir = realpath($processMakerHome) . DIRECTORY_SEPARATOR;
|
||||
|
||||
require $rootDir . "framework/src/Maveriks/Util/ClassLoader.php";
|
||||
|
||||
$loader = Maveriks\Util\ClassLoader::getInstance();
|
||||
$loader->add($rootDir . 'framework/src/', "Maveriks");
|
||||
$loader->add($rootDir . 'workflow/engine/src/', "ProcessMaker");
|
||||
$loader->add($rootDir . 'workflow/engine/src/');
|
||||
|
||||
// add vendors to autoloader
|
||||
$loader->add($rootDir . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2");
|
||||
$loader->addClass("Bootstrap", $rootDir . 'gulliver/system/class.bootstrap.php');
|
||||
|
||||
$loader->addModelClassPath($rootDir . "workflow/engine/classes/model/");
|
||||
|
||||
$app = new Maveriks\WebApplication();
|
||||
$app->setRootDir($rootDir);
|
||||
$app->loadEnvironment($workspace);
|
||||
Reference in New Issue
Block a user