Skip to main content
Sign in
Snippets Groups Projects
Unverified Commit d853b69a authored by Tobias Reischmann's avatar Tobias Reischmann
Browse files

Copy the displaytitle upon duplicate

parent a9c868e4
No related branches found
No related tags found
No related merge requests found
......@@ -354,14 +354,19 @@ class workflow_manager {
}
/**
* Creates a workflow with a specific title. Is used to create preset workflows for trigger plugins.
* Creates a workflow with a specific title. Is used to create preset workflows for trigger plugins or for
* duplication of workflows.
*
* @param $title string title of the workflow. Usually the pluginname of the trigger.
* @param $title string title of the workflow.
* @param $displaytitle string display title of the workflow.
* @return workflow the created workflow.
*/
public static function create_workflow($title) {
public static function create_workflow($title, $displaytitle = null) {
$record = new \stdClass();
$record->title = $title;
if ($displaytitle) {
$record->displaytitle = $displaytitle;
}
$workflow = workflow::from_record($record);
self::insert_or_update($workflow);
return $workflow;
......@@ -380,7 +385,7 @@ class workflow_manager {
} catch (\coding_exception $e) {
$newtitle = $oldworkflow->title;
}
$newworkflow = self::create_workflow($newtitle);
$newworkflow = self::create_workflow($newtitle, $oldworkflow->displaytitle);
$newworkflow->rollbackdelay = $oldworkflow->rollbackdelay;
$newworkflow->finishdelay = $oldworkflow->finishdelay;
$newworkflow->delayforallworkflows = $oldworkflow->delayforallworkflows;
......
......
......@@ -74,6 +74,7 @@ class tool_lifecycle_generator extends testing_module_generator {
$record = new stdClass();
$record->id = null;
$record->title = 'myworkflow';
$record->title = 'random displaystring:' . random_string(10);
$workflow = workflow::from_record($record);
workflow_manager::insert_or_update($workflow);
foreach ($stepnames as $subpluginname) {
......
......
......@@ -74,7 +74,22 @@ class tool_lifecycle_workflow_activate_disable_duplicate_testcase extends workfl
* Test to deactivate the first workflow.
*/
public function test_deactivate_first() {
// TODO to be implemented.
workflow_manager::handle_action(action::WORKFLOW_ABORTDISABLE, $this->workflow1->id);
$this->assertFalse(workflow_manager::is_active($this->workflow1->id));
}
/**
* Test to duplicate the first workflow.
*/
public function test_duplicate_first() {
workflow_manager::handle_action(action::WORKFLOW_DUPLICATE, $this->workflow1->id);
$workflows = workflow_manager::get_workflows();
$this->assertCount(4, $workflows);
$duplicate = array_pop($workflows);
$this->assertEquals($this->workflow1->displaytitle, $duplicate->displaytitle);
$workflow1stepcount = count(\tool_lifecycle\manager\step_manager::get_step_instances($this->workflow1->id));
$duplicatestepcount = count(\tool_lifecycle\manager\step_manager::get_step_instances($duplicate->id));
$this->assertEquals($workflow1stepcount, $duplicatestepcount);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment