MDL-75716 phpunit: Move tests to use correct names and ns (take#5)

Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- In lib/tests/blocklib_test.php 2 helper classes have been
  moved to tests/fixtures, because they needed to be namespace-free.
This commit is contained in:
Eloy Lafuente (stronk7) 2022-09-11 19:34:26 +02:00
parent c6211a68b4
commit 81f05b3239
39 changed files with 1007 additions and 1119 deletions

View file

@ -22,19 +22,22 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace mod_quiz;
use quiz;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/mod/quiz/locallib.php');
require_once($CFG->dirroot . '/mod/quiz/classes/repaginate.php');
/**
* Testable subclass, giving access to the protected methods of {@link \mod_quiz\repaginate}
* @copyright 2014 The Open Univsersity
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_repaginate_testable extends \mod_quiz\repaginate {
class mod_quiz_repaginate_testable extends repaginate {
public function __construct($quizid = 0, $slots = null) {
return parent::__construct($quizid, $slots);
@ -61,7 +64,7 @@ class mod_quiz_repaginate_testable extends \mod_quiz\repaginate {
* @copyright 2014 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_quiz_repaginate_test extends advanced_testcase {
class repaginate_test extends \advanced_testcase {
/** @var array stores the slots. */
private $quizslots;
@ -111,7 +114,7 @@ class mod_quiz_repaginate_test extends advanced_testcase {
// Return the quiz object.
$quizobj = new quiz($quiz, $cm, $SITE);
return \mod_quiz\structure::create_for_quiz($quizobj);
return structure::create_for_quiz($quizobj);
}
/**
@ -261,7 +264,7 @@ class mod_quiz_repaginate_test extends advanced_testcase {
public function test_repaginate_the_rest() {
$this->set_quiz_slots();
$slotfrom = 1;
$type = \mod_quiz\repaginate::LINK;
$type = repaginate::LINK;
$expected = array();
foreach ($this->quizslots as $slot) {
if ($slot->slot > $slotfrom) {
@ -281,7 +284,7 @@ class mod_quiz_repaginate_test extends advanced_testcase {
$newslots[$s->id] = $s;
}
$type = \mod_quiz\repaginate::UNLINK;
$type = repaginate::UNLINK;
$expected = array();
foreach ($this->quizslots as $slot) {
if ($slot->slot > ($slotfrom - 1)) {