forked from moodleou/moodle-report_customsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue moodleou#141-: fix phpunit test external\get_users not found
- Loading branch information
thomas.ludwig
committed
Jan 25, 2024
1 parent
658cc04
commit 749dece
Showing
2 changed files
with
36 additions
and
24 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 |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
|
||
require_once($CFG->dirroot . '/webservice/tests/helpers.php'); | ||
|
||
use core_external\external_api; | ||
|
||
/** | ||
* Tests for the get_users web service. | ||
|
@@ -31,6 +32,9 @@ | |
* @category external | ||
* @copyright 2020 The Open University | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
* | ||
* @runTestsInSeparateProcesses | ||
* | ||
*/ | ||
class external_get_users_test extends \externallib_advanced_testcase { | ||
|
||
|
@@ -52,7 +56,7 @@ protected function setup_users(): array { | |
|
||
// Create some users. | ||
$DB->update_record('user', (object) | ||
['id' => $USER->id, 'firstname' => 'Admin', 'lastname' => 'User']); | ||
['id' => (int) $USER->id, 'firstname' => 'Admin', 'lastname' => 'User']); | ||
$admin = $DB->get_record('user', ['id' => $USER->id]); | ||
$manager = $generator->create_user( | ||
['firstname' => 'The', 'lastname' => 'Manager', 'email' => '[email protected]']); | ||
|
@@ -68,10 +72,10 @@ protected function setup_users(): array { | |
|
||
public function test_get_users_site_config() { | ||
[$admin] = $this->setup_users(); | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/boost/core/1/u/f2'; | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f2'; | ||
|
||
$result = get_users::execute('', 'moodle/site:config'); | ||
$result = \external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
$result = external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
|
||
$this->assertEquals([ | ||
[ | ||
|
@@ -86,10 +90,11 @@ public function test_get_users_site_config() { | |
|
||
public function test_get_users_site_viewreports() { | ||
[$admin, $manager] = $this->setup_users(); | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/boost/core/1/u/f2'; | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f2'; | ||
|
||
$result = get_users::execute('', 'moodle/site:viewreports'); | ||
$result = \external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
$result = external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
|
||
|
||
$this->assertEquals([ | ||
[ | ||
|
@@ -111,10 +116,10 @@ public function test_get_users_site_viewreports() { | |
|
||
public function test_get_users_customsql_view() { | ||
[$admin, $manager, $coursecreateor] = $this->setup_users(); | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/boost/core/1/u/f2'; | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f2'; | ||
|
||
$result = get_users::execute('', 'report/customsql:view'); | ||
$result = \external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
$result = external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
|
||
$this->assertEquals([ | ||
[ | ||
|
@@ -143,10 +148,10 @@ public function test_get_users_customsql_view() { | |
|
||
public function test_get_users_serch_without_admins() { | ||
[, $manager] = $this->setup_users(); | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/boost/core/1/u/f2'; | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f2'; | ||
|
||
$result = get_users::execute('Man', 'report/customsql:view'); | ||
$result = \external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
$result = external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
|
||
$this->assertEquals([ | ||
[ | ||
|
@@ -161,10 +166,10 @@ public function test_get_users_serch_without_admins() { | |
|
||
public function test_get_users_serch_with_admin() { | ||
[$admin] = $this->setup_users(); | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/boost/core/1/u/f2'; | ||
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/boost/core/1/u/f2'; | ||
|
||
$result = get_users::execute('n U', 'report/customsql:view'); | ||
$result = \external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
$result = external_api::clean_returnvalue(get_users::execute_returns(), $result); | ||
|
||
$this->assertEquals([ | ||
[ | ||
|