MDL-73785 phpunit: Move more tests to use correct names and namespaces

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:

- When belonging to other components and being valid api:
  - analytics related tests have been moved to tests/analytics subdir.
  - backup & restore related tests have been moved to tests/backup subdir.
  - events related tests have been moved to tests/event subdir.
  - privacy related tests have been moved to tests/privacy.
  - task related tests have been moved to tests/task subdir.
- Some simple renames, not including the component part anymore (not
  needed now that they are namespaced):
  - some xxxlib_test.php have been renamed lib_test.php
    (when they where testing the corresponding lib.php).
  - cache stores tests have been all renamed store_test, originally
    each one had its own name (file_test, apcu_test, redis_test...)
  - assign feedback tests have been all renamed feedback_test, originally
    each one had its own name (file_test, editpdf_test...)
This commit is contained in:
Eloy Lafuente (stronk7)
2022-03-03 12:19:38 +01:00
parent 646c691107
commit eb0c520ad6
86 changed files with 1304 additions and 1707 deletions
+13 -24
View File
@@ -14,21 +14,10 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Framework processor tests.
*
* @package tool_lpmigrate
* @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
global $CFG;
namespace tool_lpmigrate;
use core_competency\course_competency;
use core_competency\course_module_competency;
use tool_lpmigrate\framework_mapper;
use tool_lpmigrate\framework_processor;
/**
* Framework processor testcase.
@@ -37,7 +26,7 @@ use tool_lpmigrate\framework_processor;
* @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
class processor_test extends \advanced_testcase {
/**
* This sets up a few things, and assign class variables.
@@ -402,13 +391,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
$dg = $this->getDataGenerator();
$u = $dg->create_user();
$role = $dg->create_role();
$sysctx = context_system::instance();
$sysctx = \context_system::instance();
$dg->enrol_user($u->id, $this->c1->id, 'editingteacher');
$dg->enrol_user($u->id, $this->c2->id, 'editingteacher');
assign_capability('moodle/competency:coursecompetencymanage', CAP_PROHIBIT, $role, $sysctx->id);
role_assign($role, $u->id, context_course::instance($this->c1->id)->id);
role_assign($role, $u->id, context_module::instance($this->cms[$this->c2->id]['F1']->cmid)->id);
role_assign($role, $u->id, \context_course::instance($this->c1->id)->id);
role_assign($role, $u->id, \context_module::instance($this->cms[$this->c2->id]['F1']->cmid)->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setUser($u);
@@ -484,7 +473,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course competency exists.
*
* @param stdClass $course The course.
* @param \stdClass $course The course.
* @param competency $competency The competency.
*/
protected function assertCourseCompetencyExists($course, $competency) {
@@ -495,7 +484,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course competency does not exist.
*
* @param stdClass $course The course.
* @param \stdClass $course The course.
* @param competency $competency The competency.
*/
protected function assertCourseCompetencyNotExists($course, $competency) {
@@ -506,7 +495,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course competency was migrated.
*
* @param stdClass $course The course.
* @param \stdClass $course The course.
* @param competency $compfrom The competency from.
* @param competency $compto The competency to.
*/
@@ -531,7 +520,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course competency was not migrated.
*
* @param stdClass $course The course.
* @param \stdClass $course The course.
* @param competency $compfrom The competency from.
* @param competency $compto The competency to.
*/
@@ -553,7 +542,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course module competency exists.
*
* @param stdClass $cm The CM.
* @param \stdClass $cm The CM.
* @param competency $competency The competency.
*/
protected function assertModuleCompetencyExists($cm, $competency) {
@@ -564,7 +553,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course module competency does not exist.
*
* @param stdClass $cm The CM.
* @param \stdClass $cm The CM.
* @param competency $competency The competency.
*/
protected function assertModuleCompetencyNotExists($cm, $competency) {
@@ -575,7 +564,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course module competency was migrated.
*
* @param stdClass $cm The CM.
* @param \stdClass $cm The CM.
* @param competency $compfrom The competency from.
* @param competency $compto The competency to.
*/
@@ -600,7 +589,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
/**
* Assert that the course module competency was not migrated.
*
* @param stdClass $cm The CM.
* @param \stdClass $cm The CM.
* @param competency $compfrom The competency from.
* @param competency $compto The competency to.
*/