Skip to content

Instantly share code, notes, and snippets.

@matiasmm
Created January 17, 2011 03:45
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save matiasmm/782468 to your computer and use it in GitHub Desktop.
Save matiasmm/782468 to your computer and use it in GitHub Desktop.
Test execution
<?php
require_once 'WorkflowDefinition.php';
require_once 'Execution.php';
$wbuilder = new WfBuilder();
$workflow_definition = $wbuilder->build_workflow();
$execution = new ezcWorkflowTestExecution(1);
$execution->workflow = $workflow_definition;
//Execution starts here
$execution->start();
/*
* PROCESS STEP 1: Fill cart
* =========================
* Here we are in the first process step.
* We can not get away from here until the condition "continue_from_fill_cart == true" is satisfied.
* In this case: continue_from_fill_cart == true.
*
* This is because we are standed in a ezcWorkflowNodeInput node.
*
*
*/
var_dump($execution->getWaitingFor());
/**
* output:
* array(1) {
["continue_from_fill_cart"]=>
array(2) {
["node"]=>
bool(false)
["condition"]=>
object(ezcWorkflowConditionIsTrue)#9 (0) {
}
}
}
*/
// We provide the data requested to continue to the next Step and we resume.
$execution->resume(array('continue_from_fill_cart'=> true));
$execution->unsetVariable('continue_from_fill_cart');
/**
* AT PROCESS STEP 2: CREATE SALES ORDER
* =====================================
*/
$execution->resume(array('continue_from_create_sales_order'=> true));
$execution->unsetVariable('continue_from_create_sales_order');
/**
* AT PROCESS STEP 3: CREATE INVOICE
* =====================================
*/
$execution->resume(array('continue_from_create_invoice'=> true));
$execution->unsetVariable('continue_from_create_invoice');
/**
* AT PROCESS STEP 4: 3th party payment
* =====================================
* But the payment is not going to be ok
*/
$execution->resume(array(
'is_payment_ok' => false,
'continue_from_3th_party_payment' => true,
));
$execution->unsetVariable('continue_from_3th_party_payment');
$execution->unsetVariable('is_payment_ok');
var_dump($execution->getWaitingFor()); //output: continue_from_notify_customer
/**
* AT PROCESS STEP 5: Notify Customer
* ==================================
*/
$execution->resume(array(
'continue_from_notify_customer' => true,
));
$execution->unsetVariable('continue_from_notify_customer');
var_dump($execution->getWaitingFor()); //output: continue_from_notify_customer
/**
* AT PROCESS STEP 4 (AGAIN): 3th Party payment
* ============================================
* Now the payment is going to be ok
*/
$execution->resume(array(
'continue_from_3th_party_payment' => true,
'is_payment_ok' => true,
));
$execution->unsetVariable('continue_from_3th_party_payment');
$execution->unsetVariable('is_payment_ok');
var_dump($execution->getWaitingFor()); //output: continue_from_prepare_in_warehouse
/**
*
*
* etc etc etc
*
*
*/
@scopium
Copy link

scopium commented Aug 15, 2011

can I get the code to these files as well, i'm trying to run a sample test to see how this all works require_once 'WorkflowDefinition.php';
require_once 'Execution.php';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment