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-73971 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: - Some fixtures, initially defined in the test files have been moved to new files in fixtures subdirectory, leaving the unit test files clearer: - moodle2_course_format_test.php - Rename wrong named test: - baseoptiogroup_test = baseoptigroup_test
- Loading branch information
Showing
143 changed files
with
1,891 additions
and
2,313 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,17 +14,7 @@ | |
// 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 data_registry class. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
use \tool_dataprivacy\data_registry; | ||
namespace tool_dataprivacy; | ||
|
||
/** | ||
* Unit tests for the data_registry class. | ||
|
@@ -33,15 +23,15 @@ | |
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_dataprivacy_dataregistry_testcase extends advanced_testcase { | ||
class data_registry_test extends \advanced_testcase { | ||
|
||
/** | ||
* Ensure that the get_effective_context_value only errors if provided an inappropriate element. | ||
* | ||
* This test is not great because we only test a limited set of values. This is a fault of the underlying API. | ||
*/ | ||
public function test_get_effective_context_value_invalid_element() { | ||
$this->expectException(coding_exception::class); | ||
$this->expectException(\coding_exception::class); | ||
data_registry::get_effective_context_value(\context_system::instance(), 'invalid'); | ||
} | ||
|
||
|
@@ -51,7 +41,7 @@ public function test_get_effective_context_value_invalid_element() { | |
* This test is not great because we only test a limited set of values. This is a fault of the underlying API. | ||
*/ | ||
public function test_get_effective_contextlevel_value_invalid_element() { | ||
$this->expectException(coding_exception::class); | ||
$this->expectException(\coding_exception::class); | ||
data_registry::get_effective_contextlevel_value(\context_system::instance(), 'invalid'); | ||
} | ||
} |
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,27 +14,21 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Tests for the data_request persistent. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace tool_dataprivacy; | ||
|
||
use data_privacy_testcase; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
require_once('data_privacy_testcase.php'); | ||
|
||
use tool_dataprivacy\api; | ||
|
||
/** | ||
* Tests for the data_request persistent. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_dataprivacy_data_request_testcase extends data_privacy_testcase { | ||
class data_request_test extends data_privacy_testcase { | ||
|
||
/** | ||
* Data provider for testing is_resettable, and is_active. | ||
|
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
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,13 +14,7 @@ | |
// 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 filtered_userlist. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace tool_dataprivacy; | ||
|
||
/** | ||
* Unit tests for the filtered_userlist. | ||
|
@@ -29,7 +23,7 @@ | |
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_dataprivacy_filtered_userlist_testcase extends advanced_testcase { | ||
class filtered_userlist_test extends \advanced_testcase { | ||
/** | ||
* Test the apply_expired_contexts_filters function with arange of options. | ||
* | ||
|
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,25 +14,21 @@ | |
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Tests for the manager observer. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
namespace tool_dataprivacy; | ||
|
||
use data_privacy_testcase; | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
require_once('data_privacy_testcase.php'); | ||
|
||
/** | ||
* API tests. | ||
* Tests for the manager observer. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Andrew Nicols <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_dataprivacy_manager_observer_testcase extends data_privacy_testcase { | ||
class manager_observer_test extends data_privacy_testcase { | ||
/** | ||
* Ensure that when users are configured as DPO, they are sent an message upon failure. | ||
*/ | ||
|
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,18 +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/>. | ||
|
||
/** | ||
* Tests for the event observer. | ||
* | ||
* @package tool_dataprivacy | ||
* @copyright 2018 Mihail Geshoski <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
namespace tool_dataprivacy; | ||
|
||
use \tool_dataprivacy\event\user_deleted_observer; | ||
use \tool_dataprivacy\api; | ||
use tool_dataprivacy\event\user_deleted_observer; | ||
|
||
/** | ||
* Event observer test. | ||
|
@@ -34,7 +25,7 @@ | |
* @copyright 2018 Mihail Geshoski <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class tool_dataprivacy_user_deleted_observer_testcase extends advanced_testcase { | ||
class user_deleted_observer_test extends \advanced_testcase { | ||
|
||
/** | ||
* Ensure that a delete data request is created upon user deletion. | ||
|
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
Oops, something went wrong.