mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods now are required to return void. This was warned with phpunit 7 and now is enforced. At the same time, fix a few wrong function names, provider data and param types, return statements...
This commit is contained in:
parent
c611109ed7
commit
d81a94807b
421 changed files with 531 additions and 531 deletions
|
@ -42,7 +42,7 @@ class qbehaviour_adaptive_type_test extends basic_testcase {
|
|||
/** @var qbehaviour_adaptive_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('adaptive');
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ class qbehaviour_adaptive_mark_display_test extends basic_testcase {
|
|||
/** @var question_display_options display options to use when rendering. */
|
||||
protected $options;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
global $PAGE;
|
||||
parent::setUp();
|
||||
$this->renderer = $PAGE->get_renderer('qbehaviour_adaptive');
|
||||
|
|
|
@ -43,7 +43,7 @@ class qbehaviour_deferredcbm_type_test extends qbehaviour_walkthrough_test_base
|
|||
/** @var qbehaviour_deferredcbm_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('deferredcbm');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_deferredfeedback_type_test extends qbehaviour_walkthrough_test_
|
|||
/** @var qbehaviour_deferredfeedback_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('deferredfeedback');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_immediatecbm_type_test extends qbehaviour_walkthrough_test_base
|
|||
/** @var qbehaviour_immediatecbm_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('immediatecbm');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_immediatefeedback_type_test extends basic_testcase {
|
|||
/** @var qbehaviour_immediatefeedback_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('immediatefeedback');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_informationitem_type_testcase extends basic_testcase {
|
|||
/** @var qbehaviour_informationitem_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('informationitem');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_interactive_type_test extends basic_testcase {
|
|||
/** @var qbehaviour_interactive_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('interactive');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_interactivecountback_type_test extends basic_testcase {
|
|||
/** @var qbehaviour_interactivecountback_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('interactivecountback');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_manualgraded_type_test extends basic_testcase {
|
|||
/** @var qbehaviour_manualgraded_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('manualgraded');
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ class qbehaviour_missing_type_test extends basic_testcase {
|
|||
/** @var qbehaviour_missing_type */
|
||||
protected $behaviourtype;
|
||||
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->behaviourtype = question_engine::get_behaviour_type('missing');
|
||||
}
|
||||
|
|
|
@ -796,7 +796,7 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase {
|
|||
*/
|
||||
protected $currentoutput = '';
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->resetAfterTest(true);
|
||||
|
||||
|
@ -805,7 +805,7 @@ abstract class qbehaviour_walkthrough_test_base extends question_testcase {
|
|||
context_system::instance());
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->displayoptions = null;
|
||||
$this->quba = null;
|
||||
parent::tearDown();
|
||||
|
|
|
@ -50,14 +50,14 @@ class question_attempt_testcase extends advanced_testcase {
|
|||
/** @var question_attempt a question attempt that can be used in the tests. */
|
||||
private $qa;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->question = test_question_maker::make_question('description');
|
||||
$this->question->defaultmark = 3;
|
||||
$this->usageid = 13;
|
||||
$this->qa = new question_attempt($this->question, $this->usageid);
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->question = null;
|
||||
$this->useageid = null;
|
||||
$this->qa = null;
|
||||
|
|
|
@ -44,7 +44,7 @@ class question_attempt_with_steps_test extends advanced_testcase {
|
|||
private $question;
|
||||
private $qa;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->question = test_question_maker::make_question('description');
|
||||
$this->qa = new testable_question_attempt($this->question, 0, null, 2);
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
|
@ -53,7 +53,7 @@ class question_attempt_with_steps_test extends advanced_testcase {
|
|||
}
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qa = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ class question_attempt_iterator_test extends advanced_testcase {
|
|||
private $qas = array();
|
||||
private $iterator;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
$this->quba->set_preferred_behaviour('deferredfeedback');
|
||||
|
@ -56,7 +56,7 @@ class question_attempt_iterator_test extends advanced_testcase {
|
|||
$this->iterator = $this->quba->get_attempt_iterator();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->quba = null;
|
||||
$this->iterator = null;
|
||||
}
|
||||
|
@ -122,4 +122,4 @@ class question_attempt_iterator_test extends advanced_testcase {
|
|||
public function test_cannot_unset() {
|
||||
unset($this->iterator[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ class question_attempt_step_iterator_test extends advanced_testcase {
|
|||
private $qa;
|
||||
private $iterator;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$question = test_question_maker::make_question('description');
|
||||
$this->qa = new testable_question_attempt($question, 0);
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
|
@ -51,7 +51,7 @@ class question_attempt_step_iterator_test extends advanced_testcase {
|
|||
$this->iterator = $this->qa->get_step_iterator();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qa = null;
|
||||
$this->iterator = null;
|
||||
}
|
||||
|
@ -141,4 +141,4 @@ class question_attempt_step_iterator_test extends advanced_testcase {
|
|||
public function test_cannot_unset() {
|
||||
unset($this->iterator[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -747,7 +747,7 @@ class question_usage_autosave_test extends qbehaviour_walkthrough_test_base {
|
|||
$this->delete_quba();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
// This test relies on the destructor for the second DB connection being called before running the next test.
|
||||
// Without this change - there will be unit test failures on "some" DBs (MySQL).
|
||||
gc_collect_cycles();
|
||||
|
|
|
@ -47,7 +47,7 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base {
|
|||
/** @var testable_question_engine_unit_of_work the unit of work we are testing. */
|
||||
protected $observer;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
// Create a usage in an initial state, with one shortanswer question added,
|
||||
// and attempted in interactive mode submitted responses 'toad' then 'frog'.
|
||||
// Then set it to use a new unit of work for any subsequent changes.
|
||||
|
@ -64,7 +64,7 @@ class question_engine_unit_of_work_test extends data_loading_method_test_base {
|
|||
$this->setup_initial_test_state($this->get_test_data());
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
public function tearDown(): void {
|
||||
question_bank::end_unit_test();
|
||||
}
|
||||
|
||||
|
|
|
@ -97,14 +97,14 @@ abstract class question_attempt_upgrader_test_base extends advanced_testcase {
|
|||
protected $updater;
|
||||
protected $loader;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$logger = new dummy_question_engine_assumption_logger();
|
||||
$this->loader = new test_question_engine_upgrade_question_loader($logger);
|
||||
$this->updater = new test_question_engine_attempt_upgrader($this->loader, $logger);
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->updater = null;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class core_question_category_class_testcase extends advanced_testcase {
|
|||
*/
|
||||
protected $topcat;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
self::setAdminUser();
|
||||
$this->resetAfterTest();
|
||||
|
|
|
@ -34,7 +34,7 @@ class core_question_events_testcase extends advanced_testcase {
|
|||
/**
|
||||
* Tests set up.
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
$this->resetAfterTest();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class core_question_external_testcase extends externallib_advanced_testcase {
|
|||
/**
|
||||
* Set up for every test
|
||||
*/
|
||||
public function setUp() {
|
||||
public function setUp(): void {
|
||||
global $DB;
|
||||
$this->resetAfterTest();
|
||||
$this->setAdminUser();
|
||||
|
|
|
@ -45,11 +45,11 @@ class qtype_calculated_test extends advanced_testcase {
|
|||
protected $tolerance = 0.00000001;
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_calculated();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -48,11 +48,11 @@ class qtype_calculatedsimple_test extends advanced_testcase {
|
|||
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_calculatedsimple();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ class qtype_ddimageortext_test extends basic_testcase {
|
|||
/** @var qtype_ddimageortext instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = question_bank::get_qtype('ddimageortext');;
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ class qtype_ddmarker_test extends advanced_testcase {
|
|||
/** @var qtype_ddmarker instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = question_bank::get_qtype('ddmarker');;
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ class qtype_ddwtos_test extends question_testcase {
|
|||
/** @var qtype_ddwtos instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = question_bank::get_qtype('ddwtos');;
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ require_once($CFG->dirroot . '/question/type/description/edit_description_form.p
|
|||
class qtype_description_test extends advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_description();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ require_once($CFG->dirroot . '/question/type/essay/questiontype.php');
|
|||
class qtype_essay_test extends advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_essay();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ class qtype_gapselect_test extends question_testcase {
|
|||
/** @var qtype_gapselect instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = question_bank::get_qtype('gapselect');
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,11 +42,11 @@ class qtype_match_test extends advanced_testcase {
|
|||
/** @var qtype_match instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_match();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -43,11 +43,11 @@ class qtype_multianswer_test extends advanced_testcase {
|
|||
/** @var qtype_multianswer instance of the question type class to test. */
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_multianswer();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ require_once($CFG->dirroot . '/question/type/multichoice/edit_multichoice_form.p
|
|||
class qtype_multichoice_test extends advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_multichoice();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,11 +47,11 @@ class qtype_numerical_test extends advanced_testcase {
|
|||
protected $tolerance = 0.00000001;
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_numerical();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,11 +40,11 @@ require_once($CFG->dirroot . '/question/type/random/questiontype.php');
|
|||
class qtype_random_test extends advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_random();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ class qtype_shortanswer_test extends advanced_testcase {
|
|||
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_shortanswer();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,10 +58,10 @@ class test_response_answer_comparer implements question_response_answer_comparer
|
|||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class question_first_matching_answer_grading_strategy_testcase extends advanced_testcase {
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
}
|
||||
|
||||
public function test_no_answers_gives_null() {
|
||||
|
|
|
@ -41,11 +41,11 @@ require_once($CFG->dirroot . '/question/type/truefalse/edit_truefalse_form.php')
|
|||
class qtype_truefalse_test extends advanced_testcase {
|
||||
protected $qtype;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp(): void {
|
||||
$this->qtype = new qtype_truefalse();
|
||||
}
|
||||
|
||||
protected function tearDown() {
|
||||
protected function tearDown(): void {
|
||||
$this->qtype = null;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue