Skip to content

Instantly share code, notes, and snippets.

@stronk7
Created March 27, 2019 09:53
Show Gist options
  • Save stronk7/c19466f7f43faf532d719670a94b7dfb to your computer and use it in GitHub Desktop.
Save stronk7/c19466f7f43faf532d719670a94b7dfb to your computer and use it in GitHub Desktop.
With phpunit 7.x assertEquals(string, string) comparisons now being strict (===), we need to keep them lazy (coz DB returns strings)
Reference: https://github.com/sebastianbergmann/phpunit/issues/3185
stronk7@~/git_moodle/moodle (phpunit70 *$%)$ git diff mod/quiz
diff --git a/mod/quiz/tests/attempt_walkthrough_from_csv_test.php b/mod/quiz/tests/attempt_walkthrough_from_csv_test.php
index 3556793f612..029dbd2ffb1 100644
--- a/mod/quiz/tests/attempt_walkthrough_from_csv_test.php
+++ b/mod/quiz/tests/attempt_walkthrough_from_csv_test.php
@@ -338,7 +338,7 @@ class mod_quiz_attempt_walkthrough_from_csv_testcase extends advanced_testcase {
$this->assertEquals((bool)$value, $attemptobj->is_finished());
break;
case 'summarks' :
- $this->assertEquals($value, $attemptobj->get_sum_marks(), "Sum of marks of attempt {$result['quizattempt']}.");
+ $this->assertEquals((float)$value, $attemptobj->get_sum_marks(), "Sum of marks of attempt {$result['quizattempt']}.");
break;
case 'quizgrade' :
// Check quiz grades.
stronk7@~/git_moodle/moodle (phpunit70 *$%)$ git diff question
diff --git a/question/type/multichoice/tests/helper.php b/question/type/multichoice/tests/helper.php
index 27297541b5e..b665052ccb6 100644
--- a/question/type/multichoice/tests/helper.php
+++ b/question/type/multichoice/tests/helper.php
@@ -80,7 +80,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 13,
'answer' => 'One',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0.5',
+ 'fraction' => 0.5,
'feedback' => 'One is odd.',
'feedbackformat' => FORMAT_HTML,
),
@@ -88,7 +88,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 14,
'answer' => 'Two',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0.0',
+ 'fraction' => 0.0,
'feedback' => 'Two is even.',
'feedbackformat' => FORMAT_HTML,
),
@@ -96,7 +96,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 15,
'answer' => 'Three',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0.5',
+ 'fraction' => 0.5,
'feedback' => 'Three is odd.',
'feedbackformat' => FORMAT_HTML,
),
@@ -104,7 +104,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 16,
'answer' => 'Four',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0.0',
+ 'fraction' => 0.0,
'feedback' => 'Four is even.',
'feedbackformat' => FORMAT_HTML,
),
@@ -261,7 +261,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 13,
'answer' => 'One',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '1',
+ 'fraction' => 1,
'feedback' => 'One is the oddest.',
'feedbackformat' => FORMAT_HTML,
),
@@ -269,7 +269,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 14,
'answer' => 'Two',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0.0',
+ 'fraction' => 0.0,
'feedback' => 'Two is even.',
'feedbackformat' => FORMAT_HTML,
),
@@ -277,7 +277,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 15,
'answer' => 'Three',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0',
+ 'fraction' => 0,
'feedback' => 'Three is odd.',
'feedbackformat' => FORMAT_HTML,
),
@@ -285,7 +285,7 @@ class qtype_multichoice_test_helper extends question_test_helper {
'id' => 16,
'answer' => 'Four',
'answerformat' => FORMAT_PLAIN,
- 'fraction' => '0.0',
+ 'fraction' => 0.0,
'feedback' => 'Four is even.',
'feedbackformat' => FORMAT_HTML,
),
diff --git a/question/type/multichoice/tests/upgradelibnewqe_test.php b/question/type/multichoice/tests/upgradelibnewqe_test.php
index f6859b72c41..cd94e1a4cd4 100644
--- a/question/type/multichoice/tests/upgradelibnewqe_test.php
+++ b/question/type/multichoice/tests/upgradelibnewqe_test.php
@@ -266,7 +266,7 @@ class qtype_multichoice_attempt_upgrader_test extends question_attempt_upgrader_
'fraction' => 0.9,
'timecreated' => 1278604597,
'userid' => null,
- 'data' => array('-comment' => 'Well done!', '-mark' => '0.9', '-maxmark' => '1'),
+ 'data' => array('-comment' => 'Well done!', '-mark' => '0.9', '-maxmark' => 1),
),
),
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment