Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
moodle-qtype_stack
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-qtype_stack
Commits
db4e460e
Commit
db4e460e
authored
1 year ago
by
ScottVerbeek
Browse files
Options
Downloads
Patches
Plain Diff
issue #1095: Add namespace to some test files
parent
7e3b1cfd
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
tests/api_tests_stateful_test.php
+10
-8
10 additions, 8 deletions
tests/api_tests_stateful_test.php
tests/editform_test.php
+20
-18
20 additions, 18 deletions
tests/editform_test.php
tests/restore_logic_test.php
+5
-3
5 additions, 3 deletions
tests/restore_logic_test.php
with
35 additions
and
29 deletions
tests/api_tests_stateful_test.php
+
10
−
8
View file @
db4e460e
...
...
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Stateful. If not, see <http://www.gnu.org/licenses/>.
namespace
qtype_stack
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
// Unit tests to check that the requirements of a related software
...
...
@@ -49,7 +51,7 @@ require_once(__DIR__ . '/../stack/cas/evaluatable_object.interfaces.php');
* @group qtype_stateful
* @group qtype_stack_compatibility
*/
class
api_tests_stateful_test
extends
qtype_stack_testcase
{
class
api_tests_stateful_test
extends
\
qtype_stack_testcase
{
public
function
test_security_map_path
()
{
$this
->
assertTrue
(
file_exists
(
__DIR__
.
'/../stack/cas/security-map.json'
));
...
...
@@ -93,20 +95,20 @@ class api_tests_stateful_test extends qtype_stack_testcase {
$this
->
assertTrue
(
method_exists
(
'stack_utils'
,
'eliminate_strings'
));
$this
->
assertTrue
(
method_exists
(
'stack_utils'
,
'list_to_array'
));
$this
->
assertTrue
(
isset
(
stack_utils
::
get_config
()
->
stackmaximaversion
));
$this
->
assertEquals
(
'"\"foo"'
,
stack_utils
::
php_string_to_maxima_string
(
'"foo'
));
$this
->
assertEquals
(
'"foo'
,
stack_utils
::
maxima_string_to_php_string
(
'"\"foo"'
));
$this
->
assertEquals
(
'["","",1+""]'
,
stack_utils
::
eliminate_strings
(
'["foo","bar",1+"baz"]'
));
$this
->
assertEquals
([
"foo"
,
"bar"
,
"baz"
],
stack_utils
::
all_substring_strings
(
'["foo","bar",1+"baz"]'
));
$this
->
assertTrue
(
isset
(
\
stack_utils
::
get_config
()
->
stackmaximaversion
));
$this
->
assertEquals
(
'"\"foo"'
,
\
stack_utils
::
php_string_to_maxima_string
(
'"foo'
));
$this
->
assertEquals
(
'"foo'
,
\
stack_utils
::
maxima_string_to_php_string
(
'"\"foo"'
));
$this
->
assertEquals
(
'["","",1+""]'
,
\
stack_utils
::
eliminate_strings
(
'["foo","bar",1+"baz"]'
));
$this
->
assertEquals
([
"foo"
,
"bar"
,
"baz"
],
\
stack_utils
::
all_substring_strings
(
'["foo","bar",1+"baz"]'
));
}
public
function
test_maxima_parser_utils
()
{
$this
->
assertTrue
(
method_exists
(
'maxima_parser_utils'
,
'parse'
));
$this
->
assertTrue
(
method_exists
(
'maxima_parser_utils'
,
'variable_usage_finder'
));
$ast
=
maxima_parser_utils
::
parse
(
'x:y+sqrt(y)'
);
$ast
=
\
maxima_parser_utils
::
parse
(
'x:y+sqrt(y)'
);
$update
=
[
'read'
=>
[
'z'
=>
true
]];
$usage
=
maxima_parser_utils
::
variable_usage_finder
(
$ast
,
$update
);
$usage
=
\
maxima_parser_utils
::
variable_usage_finder
(
$ast
,
$update
);
$this
->
assertEquals
([
'z'
=>
true
,
'y'
=>
true
],
$usage
[
'read'
]);
$this
->
assertEquals
([
'x'
=>
true
],
$usage
[
'write'
]);
$this
->
assertEquals
([
'sqrt'
=>
true
],
$usage
[
'calls'
]);
...
...
This diff is collapsed.
Click to expand it.
tests/editform_test.php
+
20
−
18
View file @
db4e460e
...
...
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace
qtype_stack
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
global
$CFG
;
...
...
@@ -29,22 +31,22 @@ require_once(__DIR__ . '/../edit_stack_form.php');
* @group qtype_stack
* @covers \qtype_stack_edit_form
*/
class
editform_test
extends
qtype_stack_edit_form
{
class
editform_test
extends
\
qtype_stack_edit_form
{
public
function
__construct
(
$questiontext
,
$specificfeedback
)
{
global
$USER
;
$syscontext
=
context_system
::
instance
();
$syscontext
=
\
context_system
::
instance
();
$category
=
question_make_default_categories
(
array
(
$syscontext
));
$fakequestion
=
new
stdClass
();
$fakequestion
=
new
\
stdClass
();
$fakequestion
->
qtype
=
'stack'
;
$fakequestion
->
category
=
$category
->
id
;
$fakequestion
->
contextid
=
$syscontext
->
id
;
$fakequestion
->
createdby
=
$USER
->
id
;
$fakequestion
->
modifiedby
=
$USER
->
id
;
$fakequestion
->
questiontext
=
$questiontext
;
$fakequestion
->
options
=
new
stdClass
();
$fakequestion
->
options
=
new
\
stdClass
();
$fakequestion
->
options
->
specificfeedback
=
$specificfeedback
;
$fakequestion
->
formoptions
=
new
stdClass
();
$fakequestion
->
formoptions
=
new
\
stdClass
();
$fakequestion
->
formoptions
->
movecontext
=
null
;
$fakequestion
->
formoptions
->
repeatelements
=
true
;
$fakequestion
->
inputs
=
null
;
...
...
@@ -52,9 +54,9 @@ class editform_test extends qtype_stack_edit_form {
if
(
class_exists
(
'\core_question\local\bank\question_edit_contexts'
))
{
$contexts
=
new
\core_question\local\bank\question_edit_contexts
(
$syscontext
);
}
else
{
$contexts
=
new
question_edit_contexts
(
$syscontext
);
$contexts
=
new
\
question_edit_contexts
(
$syscontext
);
}
parent
::
__construct
(
new
moodle_url
(
'/'
),
$fakequestion
,
$category
,
$contexts
);
parent
::
__construct
(
new
\
moodle_url
(
'/'
),
$fakequestion
,
$category
,
$contexts
);
}
}
...
...
@@ -67,31 +69,31 @@ class editform_test extends qtype_stack_edit_form {
* @group qtype_stack
* @covers \qtype_stack_edit_form
*/
class
qtype_stack_edit_form_test
extends
advanced_testcase
{
class
qtype_stack_edit_form_test
extends
\
advanced_testcase
{
protected
function
get_form
(
$questiontext
,
$specificfeedback
)
{
$this
->
setAdminUser
();
$this
->
resetAfterTest
();
return
new
qtype_stack_edit_form_testable
(
$questiontext
,
$specificfeedback
);
return
new
\
qtype_stack_edit_form_testable
(
$questiontext
,
$specificfeedback
);
}
public
function
test_get_input_names_from_question_text_default
()
{
$form
=
$this
->
get_form
(
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
,
qtype_stack_edit_form
::
DEFAULT_SPECIFIC_FEEDBACK
);
$qtype
=
new
qtype_stack
();
$form
=
$this
->
get_form
(
\
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
,
\
qtype_stack_edit_form
::
DEFAULT_SPECIFIC_FEEDBACK
);
$qtype
=
new
\
qtype_stack
();
$this
->
assertEquals
(
array
(
'ans1'
=>
array
(
1
,
1
)),
$qtype
->
get_input_names_from_question_text
(
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
));
$qtype
->
get_input_names_from_question_text
(
\
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
));
}
public
function
test_get_prt_names_from_question_default
()
{
$form
=
$this
->
get_form
(
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
,
qtype_stack_edit_form
::
DEFAULT_SPECIFIC_FEEDBACK
);
$qtype
=
new
qtype_stack
();
$form
=
$this
->
get_form
(
\
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
,
\
qtype_stack_edit_form
::
DEFAULT_SPECIFIC_FEEDBACK
);
$qtype
=
new
\
qtype_stack
();
$this
->
assertEquals
(
array
(
'prt1'
=>
1
),
$qtype
->
get_prt_names_from_question
(
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
,
qtype_stack_edit_form
::
DEFAULT_SPECIFIC_FEEDBACK
));
$qtype
->
get_prt_names_from_question
(
\
qtype_stack_edit_form
::
DEFAULT_QUESTION_TEXT
,
\
qtype_stack_edit_form
::
DEFAULT_SPECIFIC_FEEDBACK
));
}
}
This diff is collapsed.
Click to expand it.
tests/restore_logic_test.php
+
5
−
3
View file @
db4e460e
...
...
@@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Stack. If not, see <http://www.gnu.org/licenses/>.
namespace
qtype_stack
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
global
$CFG
;
...
...
@@ -26,7 +28,7 @@ require_once($CFG->dirroot . '/question/type/stack/backup/moodle2/restore_qtype_
* @copyright 2017 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
restore_logic_test
extends
restore_qtype_stack_plugin
{
class
restore_logic_test
extends
\
restore_qtype_stack_plugin
{
private
$log
=
''
;
public
function
__construct
()
{
...
...
@@ -75,7 +77,7 @@ class restore_logic_test extends restore_qtype_stack_plugin {
* @group qtype_stack
* @covers \qtype_stack
*/
class
qtype_stack_restore_logic_testcase
extends
advanced_testcase
{
class
qtype_stack_restore_logic_testcase
extends
\
advanced_testcase
{
public
function
test_fix_prt_roots
()
{
global
$DB
;
...
...
@@ -93,7 +95,7 @@ class qtype_stack_restore_logic_testcase extends advanced_testcase {
$DB
->
set_field
(
'qtype_stack_prt_nodes'
,
'truenextnode'
,
7
,
array
(
'questionid'
=>
$question
->
id
,
'prtname'
=>
'oddeven'
,
'nodename'
=>
0
));
$restoreplugin
=
new
testable_restore_qtype_stack_plugin
();
$restoreplugin
=
new
\
testable_restore_qtype_stack_plugin
();
$restoreplugin
->
after_execute_question
();
$this
->
assertStringContainsString
(
'The PRT named "oddeven" is malformed'
,
$restoreplugin
->
get_log
());
...
...
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