123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- <?php
- /**
- * @file
- * Contains workflow\lib\entity\WorkflowUnitTest.
- */
- /**
- * Tests for the Workflow classes.
- */
- class WorkflowExampleTestCase extends DrupalWebTestCase {
- protected $workflow;
- public static function getInfo() {
- return array(
- 'name' => 'Workflow',
- 'description' => 'Ensure that the Workflow API works as expected.',
- 'group' => 'Workflow',
- );
- }
- public function setUp() {
- parent::setUp('workflow'); // Enable any modules required for the test.
- }
- /**
- * Creates a simpletest_example node using the node form.
- */
- public function testWorkflow() {
- // $workflows = workflow_load_multiple();
- // dpm($workflows, "These are the current Workflows in the system.");
- $wid = 1;
- $workflow = workflow_load_single($wid);
- $this->assertEqual($workflow->wid, $wid, t('The wid of the Workflow should be the same as we decided.'));
- $workflow = new Workflow($wid);
- $this->assertEqual($workflow->wid, $wid, t('The wid of the Workflow should be the same as we decided.'));
- // $creation_state = $workflow->getCreationState();
- // $this->assertEqual($creation_state, 1, t('The creation_state of wid 1 has value 1.'));
- }
- /*
- function testWorkflowState($sid = 2, $wid = 1) {
- $this->testId = '2';
- $wf_state = $workflow->createState('State 2');
- dpm($wf_state, 'This is state ' . $sid . ' of workflow ' . $wid);
- $workflow = $wf_state->getWorkflow();
- dpm($workflow, 'This is the workflow of sid ' . $sid);
- return;
- $this->machine->fire_event('goto2');
- $this->assertEqual($this->machine->get_current_state(), 'step2', t('Current state should change when a valid event is fired.'));
- $this->machine->fire_event('goto2');
- $this->assertEqual($this->machine->get_current_state(), 'step2', t('Event should not execute if current state is not valid for the specified event.'));
- $this->machine->fire_event('reset');
- $this->assertEqual($this->machine->get_current_state(), 'step1', t('Event should allow transitions from multiple origins.'));
- $current = $this->machine->get_current_state();
- $this->machine->fire_event('dont_do_it');
- $this->assertEqual($current, $this->machine->get_current_state(), t('State should not change when guard function returns FALSE.'));
- $this->machine->fire_event('reset');
- $this->machine->reset_logs();
- $this->machine->fire_event('goto2_with_logs');
- $this->assertEqual($this->machine->logs[0], 'guard', t('The guard condition should be the first callback executed.'));
- $this->assertEqual($this->machine->logs[1], 'before_transition', t('The before_transition callback should be the second callback executed.'));
- $this->assertEqual($this->machine->logs[2], 'on_exit', t('The on_exit callback should be the third callback executed.'));
- $this->assertEqual($this->machine->logs[3], 'on_enter', t('The on_enter callback should be the fourth callback executed.'));
- $this->assertEqual($this->machine->logs[4], 'after_transition', t('The after_transition callback should be the fifth callback executed.'));
- $this->machine->fire_event('reset');
- $events = $this->machine->get_available_events();
- $this->assertTrue(in_array('goto2', $events), t('The machine should return a list of available events.'));
- $this->assertTrue(in_array('goto3', $events), t('The machine should return a list of available events.'));
- }
- */
- }
|