Skip to content

Instantly share code, notes, and snippets.

@s001dxp
Forked from matiasmm/testExecution.php
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save s001dxp/23c8d8e2e845ba8fec35 to your computer and use it in GitHub Desktop.
Save s001dxp/23c8d8e2e845ba8fec35 to your computer and use it in GitHub Desktop.
<?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
*
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment