Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
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
?
Snippets
Groups
Projects
Show more breadcrumbs
elc
moodle-tool_lifecycle
Commits
7012b288
Unverified
Commit
7012b288
authored
6 years ago
by
Tobias Reischmann
Browse files
Options
Downloads
Patches
Plain Diff
Alter categorie trigger tests to support where trigger statements
parent
a0e4f661
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
trigger/categories/tests/trigger_test.php
+51
-15
51 additions, 15 deletions
trigger/categories/tests/trigger_test.php
with
51 additions
and
15 deletions
trigger/categories/tests/trigger_test.php
+
51
−
15
View file @
7012b288
...
...
@@ -16,6 +16,7 @@
namespace
tool_lifecycle\trigger
;
use
tool_lifecycle
\processor
;
use
tool_lifecycle\response\trigger_response
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
...
...
@@ -40,12 +41,17 @@ class tool_lifecycle_trigger_categories_testcase extends \advanced_testcase {
private
$category
;
private
$childcategory
;
/**@var processor*/
private
$processor
;
public
function
setUp
()
{
$this
->
resetAfterTest
(
true
);
$this
->
setAdminUser
();
$generator
=
$this
->
getDataGenerator
();
$this
->
processor
=
new
processor
();
$this
->
category
=
$generator
->
create_category
();
$othercategory
=
$generator
->
create_category
();
$this
->
childcategory
=
$generator
->
create_category
(
array
(
'parent'
=>
$this
->
category
->
id
));
...
...
@@ -67,11 +73,21 @@ class tool_lifecycle_trigger_categories_testcase extends \advanced_testcase {
$course
=
$this
->
getDataGenerator
()
->
create_course
(
array
(
'category'
=>
$this
->
category
->
id
));
$trigger
=
new
categories
();
$response
=
$trigger
->
check_course
(
$course
,
$this
->
excludetrigger
->
id
);
$this
->
assertEquals
(
$response
,
trigger_response
::
next
());
$response
=
$trigger
->
check_course
(
$course
,
$this
->
includetrigger
->
id
);
$this
->
assertEquals
(
$response
,
trigger_response
::
trigger
());
$recordset
=
$this
->
processor
->
get_course_recordset
([
$this
->
excludetrigger
],[]);
foreach
(
$recordset
as
$element
)
{
$this
->
assertNotEquals
(
$course
->
id
,
$element
->
id
,
'The course should have been excluded by the trigger'
);
}
$recordset
->
close
();
$recordset
=
$this
->
processor
->
get_course_recordset
([
$this
->
includetrigger
],[]);
$found
=
false
;
foreach
(
$recordset
as
$element
)
{
if
(
$course
->
id
===
$element
->
id
){
$found
=
true
;
break
;
}
}
$this
->
assertTrue
(
$found
,
'The course should not have been excluded by the trigger'
);
$recordset
->
close
();
}
/**
...
...
@@ -81,11 +97,21 @@ class tool_lifecycle_trigger_categories_testcase extends \advanced_testcase {
$course
=
$this
->
getDataGenerator
()
->
create_course
(
array
(
'category'
=>
$this
->
childcategory
->
id
));
$trigger
=
new
categories
();
$response
=
$trigger
->
check_course
(
$course
,
$this
->
excludetrigger
->
id
);
$this
->
assertEquals
(
$response
,
trigger_response
::
next
());
$response
=
$trigger
->
check_course
(
$course
,
$this
->
includetrigger
->
id
);
$this
->
assertEquals
(
$response
,
trigger_response
::
trigger
());
$recordset
=
$this
->
processor
->
get_course_recordset
([
$this
->
excludetrigger
],[]);
foreach
(
$recordset
as
$element
)
{
$this
->
assertNotEquals
(
$course
->
id
,
$element
->
id
,
'The course should have been excluded by the trigger'
);
}
$recordset
->
close
();
$recordset
=
$this
->
processor
->
get_course_recordset
([
$this
->
includetrigger
],[]);
$found
=
false
;
foreach
(
$recordset
as
$element
)
{
if
(
$course
->
id
===
$element
->
id
){
$found
=
true
;
break
;
}
}
$this
->
assertTrue
(
$found
,
'The course should not have been excluded by the trigger'
);
$recordset
->
close
();
}
/**
...
...
@@ -94,10 +120,20 @@ class tool_lifecycle_trigger_categories_testcase extends \advanced_testcase {
public
function
test_course_not_within_cat
()
{
$course
=
$this
->
getDataGenerator
()
->
create_course
();
$trigger
=
new
categories
();
$response
=
$trigger
->
check_course
(
$course
,
$this
->
excludetrigger
->
id
);
$this
->
assertEquals
(
$response
,
trigger_response
::
trigger
());
$response
=
$trigger
->
check_course
(
$course
,
$this
->
includetrigger
->
id
);
$this
->
assertEquals
(
$response
,
trigger_response
::
next
());
$recordset
=
$this
->
processor
->
get_course_recordset
([
$this
->
includetrigger
],[]);
foreach
(
$recordset
as
$element
)
{
$this
->
assertNotEquals
(
$course
->
id
,
$element
->
id
,
'The course should have been excluded by the trigger'
);
}
$recordset
->
close
();
$recordset
=
$this
->
processor
->
get_course_recordset
([
$this
->
excludetrigger
],[]);
$found
=
false
;
foreach
(
$recordset
as
$element
)
{
if
(
$course
->
id
===
$element
->
id
){
$found
=
true
;
break
;
}
}
$this
->
assertTrue
(
$found
,
'The course should not have been excluded by the trigger'
);
$recordset
->
close
();
}
}
\ No newline at end of file
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
register
or
sign in
to comment