forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-74413 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: - Moved to the level2 "privacy" namespace: - \mod_assign\privacy\feedback_legacy_polyfill_test - \mod_assign\privacy\submission_legacy_polyfill_test - Moved to the level2 "task" namespace: - \core_message\task\migrate_message_data_test - \ltiservice_gradebookservices\task\cleanup_test - \message_email\task\send_email_test - \mod_lti\task\clean_access_tokens_test - \mod_workshop\task\cron_task_test - Moved to the level2 "event" namespace: - \core_h5p\event\deleted_test - \core_h5p\event\viewed_test - Renamed to a better name: - backup_forum_activity_task_test.php (missing "task")
- Loading branch information
Showing
106 changed files
with
1,067 additions
and
1,493 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,14 +14,9 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Unit tests for Marking Guide grading method. | ||
* | ||
* @package gradingform_guide | ||
* @category test | ||
* @copyright 2015 Nikita Kalinin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace gradingform_guide; | ||
|
||
use gradingform_controller; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
|
@@ -37,7 +32,7 @@ | |
* @copyright 2015 Nikita Kalinin <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class gradingform_guide_testcase extends advanced_testcase { | ||
class guide_test extends \advanced_testcase { | ||
/** | ||
* Unit test to get draft instance and create new instance. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,42 +14,24 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Unit tests for the advanced grading subsystem | ||
* | ||
* @package core_grading | ||
* @category phpunit | ||
* @copyright 2011 David Mudrak <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace core_grading; | ||
|
||
use grading_manager; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
global $CFG; | ||
require_once($CFG->dirroot . '/grade/grading/lib.php'); // Include the code to test | ||
|
||
|
||
/** | ||
* Makes protected method accessible for testing purposes | ||
* | ||
* @package core_grading | ||
* @category phpunit | ||
* @copyright 2011 David Mudrak <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class testable_grading_manager extends grading_manager { | ||
} | ||
|
||
|
||
/** | ||
* Test cases for the grading manager API | ||
* | ||
* @package core_grading | ||
* @category phpunit | ||
* @category test | ||
* @copyright 2011 David Mudrak <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class core_grade_grading_manager_testcase extends advanced_testcase { | ||
class grading_manager_test extends \advanced_testcase { | ||
public function test_basic_instantiation() { | ||
$manager1 = get_grading_manager(); | ||
|
||
|
@@ -103,7 +85,7 @@ public function test_set_and_get_grading_area() { | |
$this->assertEquals('rubric', $gradingman->get_active_method()); | ||
|
||
// attempting to set an invalid method | ||
$this->expectException(moodle_exception::class); | ||
$this->expectException(\moodle_exception::class); | ||
$gradingman->set_active_method('no_one_should_ever_try_to_implement_a_method_with_this_silly_name'); | ||
} | ||
|
||
|
@@ -115,27 +97,27 @@ public function test_tokenize() { | |
$UTFfailuremessage = 'A test using UTF-8 characters has failed. Consider updating PHP and PHP\'s PCRE or INTL extensions (MDL-30494)'; | ||
|
||
$needle = " šašek, \n\n \r a král; \t"; | ||
$tokens = testable_grading_manager::tokenize($needle); | ||
$tokens = grading_manager::tokenize($needle); | ||
$this->assertEquals(2, count($tokens), $UTFfailuremessage); | ||
$this->assertTrue(in_array('šašek', $tokens), $UTFfailuremessage); | ||
$this->assertTrue(in_array('král', $tokens), $UTFfailuremessage); | ||
|
||
$needle = ' " šašek a král " '; | ||
$tokens = testable_grading_manager::tokenize($needle); | ||
$tokens = grading_manager::tokenize($needle); | ||
$this->assertEquals(1, count($tokens)); | ||
$this->assertTrue(in_array('šašek a král', $tokens)); | ||
|
||
$needle = '""'; | ||
$tokens = testable_grading_manager::tokenize($needle); | ||
$tokens = grading_manager::tokenize($needle); | ||
$this->assertTrue(empty($tokens)); | ||
|
||
$needle = '"0"'; | ||
$tokens = testable_grading_manager::tokenize($needle); | ||
$tokens = grading_manager::tokenize($needle); | ||
$this->assertEquals(1, count($tokens)); | ||
$this->assertTrue(in_array('0', $tokens)); | ||
|
||
$needle = '<span>Aha</span>, then who\'s a bad guy here he?'; | ||
$tokens = testable_grading_manager::tokenize($needle); | ||
$tokens = grading_manager::tokenize($needle); | ||
$this->assertEquals(8, count($tokens)); | ||
$this->assertTrue(in_array('span', $tokens)); // Extracted the tag name | ||
$this->assertTrue(in_array('Aha', $tokens)); | ||
|
@@ -144,7 +126,7 @@ public function test_tokenize() { | |
$this->assertTrue(in_array('he', $tokens)); // Removed the trailing ? | ||
$needle = 'grammar, "english language"'; | ||
$tokens = testable_grading_manager::tokenize($needle); | ||
$tokens = grading_manager::tokenize($needle); | ||
$this->assertTrue(in_array('grammar', $tokens)); | ||
$this->assertTrue(in_array('english', $tokens)); | ||
$this->assertTrue(in_array('language', $tokens)); | ||
|
Oops, something went wrong.