function _workflow_test_entity_workflow_crud in Workflow 7.2
Test functions.
To test caches, load same object twice in a page (see d.o. issue #1572466).
File
- ./
workflow.test.inc, line 13 - Contains test functions.
Code
function _workflow_test_entity_workflow_crud() {
$ws = workflow_load_multiple();
$count1 = count($ws);
$workflow = workflow_create('test' . REQUEST_TIME);
$workflow
->save();
// Test cache: $w3 must be OK, too.
$w2 = workflow_load($workflow->wid);
$w3 = workflow_load($workflow->wid);
if ($w2 != $w3) {
// error.
}
// Test Cache: number of workflows must be OK.
$ws = workflow_load_multiple();
$count2 = count($ws);
$workflow
->delete();
$ws = workflow_load_multiple();
$count3 = count($ws);
if ($count1 === $count3 && $count2 - $count1 == 1) {
drupal_set_message(t('workflow->create/save/delete OK'));
}
else {
drupal_set_message(t('workflow->create/save/delete: error'));
}
$workflow = workflow_create('test' . REQUEST_TIME);
$s1 = $workflow
->createState('first');
$s2 = $workflow
->createState('second');
$s3 = $workflow
->createState('third');
$s1
->save();
$s2
->save();
$s2
->save();
$s3
->save();
}