Skip to main content
Homepage
Explore
Search or go to…
/
Sign in
Explore
Primary navigation
Project
M
moodle-tool_lifecycle
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Collapse sidebar
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
d853b69a
Unverified
Commit
d853b69a
authored
Aug 27, 2019
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
Copy the displaytitle upon duplicate
parent
a9c868e4
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
classes/manager/workflow_manager.php
+9
-4
9 additions, 4 deletions
classes/manager/workflow_manager.php
tests/generator/lib.php
+1
-0
1 addition, 0 deletions
tests/generator/lib.php
tests/workflow_activate_disable_duplicate_test.php
+16
-1
16 additions, 1 deletion
tests/workflow_activate_disable_duplicate_test.php
with
26 additions
and
5 deletions
classes/manager/workflow_manager.php
+
9
−
4
View file @
d853b69a
...
...
@@ -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
;
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/generator/lib.php
+
1
−
0
View file @
d853b69a
...
...
@@ -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
)
{
...
...
...
...
This diff is collapsed.
Click to expand it.
tests/workflow_activate_disable_duplicate_test.php
+
16
−
1
View file @
d853b69a
...
...
@@ -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
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment