Adding Test Units for BpmnEvent, BpmnGateway classes
This commit is contained in:
@@ -21,43 +21,108 @@ class BpmnEvent extends BaseBpmnEvent
|
||||
public function __construct($generateUid = true)
|
||||
{
|
||||
$this->bound = new BpmnBound();
|
||||
$this->setBoundDefaults();
|
||||
}
|
||||
|
||||
public function getBound()
|
||||
{
|
||||
return $this->bound;
|
||||
}
|
||||
|
||||
private function setBoundDefaults()
|
||||
{
|
||||
$this->bound->setBouElementType(lcfirst(str_replace(__NAMESPACE__, '', __CLASS__)));
|
||||
$this->bound->setBouElement('pm_canvas');
|
||||
$this->bound->setBouContainer('bpmnDiagram');
|
||||
|
||||
$this->bound->setPrjUid($this->getPrjUid());
|
||||
$this->bound->setElementUid($this->getEvnUid());
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
||||
|
||||
if (is_object($process)) {
|
||||
$this->bound->setDiaUid($process->getDiaUid());
|
||||
}
|
||||
}
|
||||
|
||||
public static function findOneBy($field, $value)
|
||||
{
|
||||
$rows = self::findAllBy($field, $value);
|
||||
|
||||
return empty($rows) ? null : $rows[0];
|
||||
}
|
||||
|
||||
public static function findAllBy($field, $value)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$c->add($field, $value, Criteria::EQUAL);
|
||||
|
||||
return BpmnEventPeer::doSelect($c);
|
||||
}
|
||||
|
||||
public static function getAll($prjUid = null, $start = null, $limit = null, $filter = '', $changeCaseTo = CASE_UPPER)
|
||||
{
|
||||
$c = new Criteria('workflow');
|
||||
$c->addSelectColumn("BPMN_EVENT.*");
|
||||
$c->addSelectColumn("BPMN_BOUND.*");
|
||||
$c->addJoin(BpmnEventPeer::EVN_UID, BpmnBoundPeer::ELEMENT_UID, Criteria::LEFT_JOIN);
|
||||
|
||||
if (! is_null($prjUid)) {
|
||||
$c->add(BpmnEventPeer::PRJ_UID, $prjUid, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$rs = BpmnEventPeer::doSelectRS($c);
|
||||
$rs->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
|
||||
$events = array();
|
||||
|
||||
while ($rs->next()) {
|
||||
$events[] = $changeCaseTo !== CASE_UPPER ? array_change_key_case($rs->getRow(), CASE_LOWER) : $rs->getRow();
|
||||
}
|
||||
|
||||
return $events;
|
||||
}
|
||||
|
||||
// OVERRIDES
|
||||
|
||||
public function fromArray($data)
|
||||
public function setActUid($actUid)
|
||||
{
|
||||
parent::fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
|
||||
// try resolve the related bound
|
||||
if (array_key_exists('BOU_UID', $data)) {
|
||||
$bound = BpmnBoundPeer::retrieveByPK($data['BOU_UID']);
|
||||
|
||||
if (is_object($bound)) {
|
||||
$this->bound = $bound;
|
||||
}
|
||||
parent::setActUid($actUid);
|
||||
$this->bound->setElementUid($this->getEvnUid());
|
||||
}
|
||||
|
||||
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
public function setPrjUid($prjUid)
|
||||
{
|
||||
parent::setPrjUid($prjUid);
|
||||
$this->bound->setPrjUid($this->getPrjUid());
|
||||
}
|
||||
|
||||
public function setProUid($proUid)
|
||||
{
|
||||
parent::setProUid($proUid);
|
||||
|
||||
$process = BpmnProcessPeer::retrieveByPK($this->getProUid());
|
||||
$this->bound->setDiaUid($process->getDiaUid());
|
||||
}
|
||||
|
||||
public function save($con = null)
|
||||
{
|
||||
parent::save($con);
|
||||
|
||||
if (is_object($this->bound) && get_class($this->bound) == 'BpmnBound') {
|
||||
$this->bound->save($con);
|
||||
$this->setBoundDefaults();
|
||||
|
||||
if ($this->bound->getBouUid() == "") {
|
||||
$this->bound->setBouUid(\ProcessMaker\Util\Hash::generateUID());
|
||||
}
|
||||
|
||||
$this->bound->save($con);
|
||||
}
|
||||
|
||||
public function delete($con = null)
|
||||
{
|
||||
// first, delete the related bound object
|
||||
if (! is_object($this->bound)) {
|
||||
$this->bound = BpmnBound::findByElement('Event', $this->getActUid());
|
||||
if (! is_object($this->bound) || $this->bound->getBouUid() == "") {
|
||||
$this->bound = BpmnBound::findByElement('Event', $this->getEvnUid());
|
||||
}
|
||||
|
||||
if (is_object($this->bound)) {
|
||||
@@ -67,15 +132,37 @@ class BpmnEvent extends BaseBpmnEvent
|
||||
parent::delete($con);
|
||||
}
|
||||
|
||||
public function toArray($keyType = BasePeer::TYPE_PHPNAME)
|
||||
public function fromArray($data, $type = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
$data = parent::toArray($keyType);
|
||||
parent::fromArray($data, $type);
|
||||
|
||||
if (is_object($this->bound) && get_class($this->bound) == 'BpmnBound') {
|
||||
$data = array_merge($data, $this->bound->toArray($keyType));
|
||||
$bound = BpmnBound::findByElement('Event', $this->getEvnUid());
|
||||
|
||||
if (is_object($bound)) {
|
||||
$this->bound = $bound;
|
||||
} else {
|
||||
$this->bound = new BpmnBound();
|
||||
$this->bound->setBouUid(ProcessMaker\Util\Hash::generateUID());
|
||||
}
|
||||
|
||||
$this->bound->fromArray($data, BasePeer::TYPE_FIELDNAME);
|
||||
}
|
||||
|
||||
public function toArray($type = BasePeer::TYPE_FIELDNAME)
|
||||
{
|
||||
$data = parent::toArray($type);
|
||||
$bouUid = $this->bound->getBouUid();
|
||||
|
||||
if (empty($bouUid)) {
|
||||
$bound = BpmnBound::findByElement('Event', $this->getEvnUid());
|
||||
|
||||
if (is_object($bound)) {
|
||||
$this->bound = $bound;
|
||||
}
|
||||
}
|
||||
|
||||
$data = array_merge($data, $this->bound->toArray($type));
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
} // BpmnEvent
|
||||
|
||||
@@ -6,7 +6,9 @@ use ProcessMaker\Util\Hash;
|
||||
|
||||
/**
|
||||
* Class BpmnWorkflow
|
||||
*
|
||||
* @package ProcessMaker\Project\Adapter
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class BpmnWorkflow extends Project\Bpmn
|
||||
{
|
||||
@@ -252,11 +254,8 @@ class BpmnWorkflow extends Project\Bpmn
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static function mapBpmnFlowsToWorkflowRoute($flow, $flows, $gateways, $events)
|
||||
{
|
||||
$fromUid = $flow['FLO_ELEMENT_ORIGIN'];
|
||||
|
||||
@@ -4,7 +4,12 @@ namespace ProcessMaker\Project\Adapter;
|
||||
use ProcessMaker\Project;
|
||||
use ProcessMaker\Util\Hash;
|
||||
|
||||
|
||||
/**
|
||||
* Class WorkflowBpmn
|
||||
*
|
||||
* @package ProcessMaker\Project\Adapter
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class WorkflowBpmn extends Project\Workflow
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,12 @@ use \BasePeer;
|
||||
use ProcessMaker\Util\Hash;
|
||||
use ProcessMaker\Exception;
|
||||
|
||||
/**
|
||||
* Class Bpmn
|
||||
*
|
||||
* @package ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class Bpmn extends Handler
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -3,6 +3,12 @@ namespace ProcessMaker\Project;
|
||||
|
||||
use ProcessMaker\Util\Logger;
|
||||
|
||||
/**
|
||||
* Class Handler
|
||||
*
|
||||
* @package ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
abstract class Handler
|
||||
{
|
||||
public static function load($uid)
|
||||
|
||||
@@ -13,6 +13,12 @@ use \RoutePeer;
|
||||
use ProcessMaker\Util\Hash;
|
||||
use ProcessMaker\Exception;
|
||||
|
||||
/**
|
||||
* Class Workflow
|
||||
*
|
||||
* @package ProcessMaker\Project
|
||||
* @author Erik Amaru Ortiz <aortiz.erik@gmail.com, erik@colosa.com>
|
||||
*/
|
||||
class Workflow extends Handler
|
||||
{
|
||||
protected $process;
|
||||
|
||||
@@ -5,6 +5,11 @@ if (! class_exists("Propel")) {
|
||||
|
||||
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";
|
||||
@@ -107,6 +112,7 @@ class BpmnActivityTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
/**
|
||||
* @depends testNew
|
||||
* @param $activity \BpmnActivity
|
||||
*/
|
||||
public function testToArrayFromTestNew($activity)
|
||||
{
|
||||
@@ -141,7 +147,7 @@ class BpmnActivityTest extends PHPUnit_Framework_TestCase
|
||||
"ACT_REFERER" => "",
|
||||
"ACT_DEFAULT_FLOW" => "",
|
||||
"ACT_MASTER_DIAGRAM" => "",
|
||||
"DIA_UID" => "18171550f1198ddc8642045664020352",
|
||||
"DIA_UID" => self::$diaUid,
|
||||
"ELEMENT_UID" => self::$data1["ACT_UID"],
|
||||
"BOU_ELEMENT" => "pm_canvas",
|
||||
"BOU_ELEMENT_TYPE" => "bpmnActivity",
|
||||
|
||||
297
workflow/engine/src/Tests/Model/BpmnEventTest.php
Normal file
297
workflow/engine/src/Tests/Model/BpmnEventTest.php
Normal file
@@ -0,0 +1,297 @@
|
||||
<?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" => "",
|
||||
"EVN_ERROR_CODE" => "",
|
||||
"EVN_ESCALATION_NAME" => "",
|
||||
"EVN_ESCALATION_CODE" => "",
|
||||
"EVN_CONDITION" => "",
|
||||
"EVN_MESSAGE" => "",
|
||||
"EVN_OPRERATION_NAME" => "",
|
||||
"EVN_OPERATION_IMPLEMENTATION_REF" => "",
|
||||
"EVN_TIME_DATE" => "",
|
||||
"EVN_TIME_CYCLE" => "",
|
||||
"EVN_TIME_DURATION" => "",
|
||||
"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" => "",
|
||||
"EVN_ERROR_CODE" => "",
|
||||
"EVN_ESCALATION_NAME" => "",
|
||||
"EVN_ESCALATION_CODE" => "",
|
||||
"EVN_CONDITION" => "",
|
||||
"EVN_MESSAGE" => "",
|
||||
"EVN_OPRERATION_NAME" => "",
|
||||
"EVN_OPERATION_IMPLEMENTATION_REF" => "",
|
||||
"EVN_TIME_DATE" => "",
|
||||
"EVN_TIME_CYCLE" => "",
|
||||
"EVN_TIME_DURATION" => "",
|
||||
"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" => "",
|
||||
"EVN_ERROR_CODE" => "",
|
||||
"EVN_ESCALATION_NAME" => "",
|
||||
"EVN_ESCALATION_CODE" => "",
|
||||
"EVN_CONDITION" => "",
|
||||
"EVN_MESSAGE" => "",
|
||||
"EVN_OPRERATION_NAME" => "",
|
||||
"EVN_OPERATION_IMPLEMENTATION_REF" => "",
|
||||
"EVN_TIME_DATE" => "",
|
||||
"EVN_TIME_CYCLE" => "",
|
||||
"EVN_TIME_DURATION" => "",
|
||||
"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));
|
||||
}
|
||||
|
||||
}
|
||||
262
workflow/engine/src/Tests/Model/BpmnGatewayTest.php
Normal file
262
workflow/engine/src/Tests/Model/BpmnGatewayTest.php
Normal file
@@ -0,0 +1,262 @@
|
||||
<?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_GATEWAT_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_GATEWAT_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_GATEWAT_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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,12 @@ 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
|
||||
{
|
||||
function testNew()
|
||||
|
||||
@@ -7,7 +7,12 @@ 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
|
||||
{
|
||||
function testNew()
|
||||
|
||||
@@ -7,7 +7,12 @@ 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();
|
||||
|
||||
@@ -7,6 +7,12 @@ 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();
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
// 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'];
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
processIsolation="false"
|
||||
stopOnFailure="true"
|
||||
syntaxCheck="true"
|
||||
bootstrap="tests/bootstrap.php"
|
||||
bootstrap="Tests/bootstrap.php"
|
||||
>
|
||||
<testsuites>
|
||||
<testsuite name="unit">
|
||||
|
||||
Reference in New Issue
Block a user