mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-65204 phpunit: more isEqual() strict string fixes
This is a followup of 85f47ba, where we were relaxing the (new since phpunit 7.x) strict (===) isEqual() comparison for strings. Copying the explanations for easier understanding. Link: https://github.com/sebastianbergmann/phpunit/issues/3185 Solution here is one of: a) Return to the previous situation, making the comparison softer. That can achieved by forcing different types, so float == string works. b) Changing APIs (both forms and database return strings) to perform some conversion to floats. That would make float comparison (with floats or strings) to work too. The patch here follows the a) approach. Changing all the internals for proper float handling sounds excesive when it has been working perfectly since ever. So we went the easier route, just getting rid of the new === comparisons when needed by changing expectation types to float.
This commit is contained in:
parent
f3971a2d88
commit
87f196af93
@ -2321,7 +2321,7 @@ class core_dml_testcase extends database_driver_testcase {
|
||||
$record->id = '1';
|
||||
$record->course = '1';
|
||||
$record->oneint = null;
|
||||
$record->onenum = '1.00';
|
||||
$record->onenum = 1.0;
|
||||
$record->onechar = 'a';
|
||||
$record->onetext = 'aaa';
|
||||
|
||||
|
@ -146,7 +146,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[0]][$this->allslots[0]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->sa->id,
|
||||
'maxmark' => '5.0000000',
|
||||
'maxmark' => 5.0,
|
||||
'sequencenumber' => 2,
|
||||
'state' => (string) question_state::$gradedright,
|
||||
), $state);
|
||||
@ -154,7 +154,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[0]][$this->allslots[1]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->essay->id,
|
||||
'maxmark' => '10.0000000',
|
||||
'maxmark' => 10.0,
|
||||
'sequencenumber' => 2,
|
||||
'state' => (string) question_state::$needsgrading,
|
||||
), $state);
|
||||
@ -162,7 +162,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[1]][$this->allslots[0]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->sa->id,
|
||||
'maxmark' => '5.0000000',
|
||||
'maxmark' => 5.0,
|
||||
'sequencenumber' => 2,
|
||||
'state' => (string) question_state::$gradedwrong,
|
||||
), $state);
|
||||
@ -170,7 +170,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[1]][$this->allslots[1]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->essay->id,
|
||||
'maxmark' => '10.0000000',
|
||||
'maxmark' => 10.0,
|
||||
'sequencenumber' => 1,
|
||||
'state' => (string) question_state::$gaveup,
|
||||
), $state);
|
||||
@ -295,7 +295,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[0]][$this->allslots[0]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->sa->id,
|
||||
'maxmark' => '5.0000000',
|
||||
'maxmark' => 5.0,
|
||||
'sequencenumber' => 2,
|
||||
'state' => (string) question_state::$gradedright,
|
||||
), $state);
|
||||
@ -303,7 +303,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[0]][$this->allslots[1]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->essay->id,
|
||||
'maxmark' => '10.0000000',
|
||||
'maxmark' => 10.0,
|
||||
'sequencenumber' => 2,
|
||||
'state' => (string) question_state::$needsgrading,
|
||||
), $state);
|
||||
@ -311,7 +311,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[1]][$this->allslots[0]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->sa->id,
|
||||
'maxmark' => '5.0000000',
|
||||
'maxmark' => 5.0,
|
||||
'sequencenumber' => 2,
|
||||
'state' => (string) question_state::$gradedwrong,
|
||||
), $state);
|
||||
@ -319,7 +319,7 @@ class question_engine_data_mapper_reporting_testcase extends qbehaviour_walkthro
|
||||
$state = $states[$this->usageids[1]][$this->allslots[1]];
|
||||
$this->assertEquals((object) array(
|
||||
'questionid' => $this->essay->id,
|
||||
'maxmark' => '10.0000000',
|
||||
'maxmark' => 10.0,
|
||||
'sequencenumber' => 1,
|
||||
'state' => (string) question_state::$gaveup,
|
||||
), $state);
|
||||
|
@ -240,7 +240,7 @@ class qtype_calculatedsimple_test_helper extends question_test_helper {
|
||||
$q->options->answers[0]->question = '3379';
|
||||
$q->options->answers[0]->answer = '{a} + {b}';
|
||||
$q->options->answers[0]->answerformat = '0';
|
||||
$q->options->answers[0]->fraction = '1.0000000';
|
||||
$q->options->answers[0]->fraction = 1.0;
|
||||
$q->options->answers[0]->feedback = '';
|
||||
$q->options->answers[0]->feedbackformat = '1';
|
||||
$q->options->answers[0]->tolerance = '0.01';
|
||||
@ -251,7 +251,7 @@ class qtype_calculatedsimple_test_helper extends question_test_helper {
|
||||
$q->options->units = array();
|
||||
|
||||
$q->options->unitgradingtype = '0';
|
||||
$q->options->unitpenalty = '0.1000000';
|
||||
$q->options->unitpenalty = 0.1;
|
||||
$q->options->showunits = '3';
|
||||
$q->options->unitsleft = '0';
|
||||
|
||||
|
@ -199,21 +199,21 @@ class qtype_numerical_test_helper extends question_test_helper {
|
||||
$q->options->answers = array();
|
||||
$q->options->answers[0] = new stdClass();
|
||||
$q->options->answers[0]->answer = '3.14';
|
||||
$q->options->answers[0]->fraction = '1.0000000';
|
||||
$q->options->answers[0]->fraction = 1.0;
|
||||
$q->options->answers[0]->feedback = 'Very good.';
|
||||
$q->options->answers[0]->feedbackformat = FORMAT_HTML;
|
||||
$q->options->answers[0]->tolerance = '0';
|
||||
|
||||
$q->options->answers[1] = new stdClass();
|
||||
$q->options->answers[1]->answer = '3.142';
|
||||
$q->options->answers[1]->fraction = '0.0000000';
|
||||
$q->options->answers[1]->fraction = 0.0;
|
||||
$q->options->answers[1]->feedback = 'Too accurate.';
|
||||
$q->options->answers[1]->feedbackformat = FORMAT_HTML;
|
||||
$q->options->answers[1]->tolerance = '0';
|
||||
|
||||
$q->options->answers[2] = new stdClass();
|
||||
$q->options->answers[2]->answer = '3.1';
|
||||
$q->options->answers[2]->fraction = '0.0000000';
|
||||
$q->options->answers[2]->fraction = 0.0;
|
||||
$q->options->answers[2]->feedback = 'Not accurate enough.';
|
||||
$q->options->answers[2]->feedbackformat = FORMAT_HTML;
|
||||
$q->options->answers[2]->tolerance = '0';
|
||||
@ -221,7 +221,7 @@ class qtype_numerical_test_helper extends question_test_helper {
|
||||
$q->options->answers[3] = new stdClass();
|
||||
$q->options->answers[3]->answer = '3';
|
||||
$q->options->answers[3]->answerformat = '0';
|
||||
$q->options->answers[3]->fraction = '0.0000000';
|
||||
$q->options->answers[3]->fraction = 0.0;
|
||||
$q->options->answers[3]->feedback = 'Not accurate enough.';
|
||||
$q->options->answers[3]->feedbackformat = FORMAT_HTML;
|
||||
$q->options->answers[3]->tolerance = '0';
|
||||
@ -229,7 +229,7 @@ class qtype_numerical_test_helper extends question_test_helper {
|
||||
$q->options->answers[4] = new stdClass();
|
||||
$q->options->answers[4]->answer = '*';
|
||||
$q->options->answers[4]->answerformat = '0';
|
||||
$q->options->answers[4]->fraction = '0.0000000';
|
||||
$q->options->answers[4]->fraction = 0.0;
|
||||
$q->options->answers[4]->feedback = 'Completely wrong.';
|
||||
$q->options->answers[4]->feedbackformat = FORMAT_HTML;
|
||||
$q->options->answers[4]->tolerance = '0';
|
||||
@ -237,7 +237,7 @@ class qtype_numerical_test_helper extends question_test_helper {
|
||||
$q->options->units = array();
|
||||
|
||||
$q->options->unitgradingtype = '0';
|
||||
$q->options->unitpenalty = '0.1000000';
|
||||
$q->options->unitpenalty = 0.1;
|
||||
$q->options->showunits = '3';
|
||||
$q->options->unitsleft = '0';
|
||||
|
||||
|
@ -111,13 +111,13 @@ class qtype_truefalse_test_helper extends question_test_helper {
|
||||
$q->options->answers = array();
|
||||
$q->options->answers[0] = new stdClass();
|
||||
$q->options->answers[0]->answer = 'True';
|
||||
$q->options->answers[0]->fraction = '1.0000000';
|
||||
$q->options->answers[0]->fraction = 1.0;
|
||||
$q->options->answers[0]->feedback = 'This is the right answer.';
|
||||
$q->options->answers[0]->feedbackformat = FORMAT_HTML;
|
||||
|
||||
$q->options->answers[1] = new stdClass();
|
||||
$q->options->answers[1]->answer = 'False';
|
||||
$q->options->answers[1]->fraction = '0.0000000';
|
||||
$q->options->answers[1]->fraction = 0.0;
|
||||
$q->options->answers[1]->feedback = 'This is the wrong answer.';
|
||||
$q->options->answers[1]->feedbackformat = FORMAT_HTML;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user