Skip to content

Commit

Permalink
Fix more coding style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
timhunt committed Dec 13, 2023
1 parent e98d62a commit 318a026
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 45 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ jobs:
run: moodle-plugin-ci phpcs --max-warnings 0

- name: Moodle PHPDoc Checker
continue-on-error: true # This step will show errors but will not fail.
if: ${{ always() }}
run: moodle-plugin-ci phpdoc

Expand Down
5 changes: 3 additions & 2 deletions category.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* This page shows the list of queries in a category, with edit icons, an add new button
* if you have the report/customsql:definequeries capability
* This page shows the list of queries in a category.
*
* With editing UI, if you have the report/customsql:definequeries capability.
*
* @package report_customsql
* @copyright 2021 The Open University
Expand Down
1 change: 1 addition & 0 deletions classes/local/query.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public function can_edit(\context $context): bool {
/**
* Check the capability to view the query.
*
* @param \context $context The context to check.
* @return bool Has capability to view or not?
*/
public function can_view(\context $context):bool {
Expand Down
2 changes: 2 additions & 0 deletions classes/output/category_query.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@ class category_query implements renderable, templatable {
/** @var query Category object. */
private $category;

/** @var context Context to check the capability. */
private $context;

/** @var moodle_url Return url. */
private $returnurl;

/**
* Create the category renderable object.
*
* @param query $query Query object.
* @param category $category
* @param context $context Context to check the capability.
Expand Down
2 changes: 1 addition & 1 deletion classes/output/renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class renderer extends plugin_renderer_base {
* Output the standard action icons (edit, delete and back to list) for a report.
*
* @param stdClass $report the report.
* @param context $context context to use for permission checks.
* @param stdClass $category Category object.
* @param context $context context to use for permission checks.
* @return string HTML for report actions.
*/
public function render_report_actions(stdClass $report, stdClass $category, context $context):string {
Expand Down
2 changes: 0 additions & 2 deletions classes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

class utils {


/**
* Return the current timestamp, or a fixed timestamp specified by an automated test.
*
Expand Down
4 changes: 2 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ function report_customsql_validate_users($userids, $capability) {
function report_customsql_get_message_no_data($report) {
// Construct subject.
$subject = report_customsql_email_subject(0, $report);
$url = new moodle_url('/report/customsql/view.php', params: ['id' => $report->id]);
$url = new moodle_url('/report/customsql/view.php', ['id' => $report->id]);
$link = get_string('emailink', 'report_customsql', html_writer::tag('a', $url, ['href' => $url]));
$fullmessage = html_writer::tag('p', get_string('nodatareturned', 'report_customsql') . ' ' . $link);
$fullmessagehtml = $fullmessage;
Expand Down Expand Up @@ -801,7 +801,7 @@ function report_customsql_get_ready_to_run_daily_reports($timenow) {
*
* @param object $recipient the message recipient.
* @param object $message the message object.
* @return mixed result of {@link message_send()}.
* @return mixed result of {@see message_send()}.
*/
function report_customsql_send_email_notification($recipient, $message) {

Expand Down
2 changes: 1 addition & 1 deletion templates/form-user-selector-suggestion.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}
}}
<span>
<img height="12" src="{{profileimageurlsmall}}" alt="" role="presentation">
<img height="12" src="{{profileimageurlsmall}}" alt="">
<span>{{fullname}}</span>
{{#hasidentity}}
<span><small>{{identity}}</small></span>
Expand Down
5 changes: 5 additions & 0 deletions tests/behat/behat_report_customsql.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,11 @@ public function the_custom_sql_report_x_exists(string $reportname, PyStringNode
$this->save_new_report($report);
}

/**
* Helper used by other methods to save a report.
*
* @param array $report the report to save.
*/
protected function save_new_report(array $report) {
global $CFG, $DB;

Expand Down
72 changes: 36 additions & 36 deletions tests/external/external_get_users_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

namespace report_customsql\external;

use core_external\external_api;

defined('MOODLE_INTERNAL') || die();

global $CFG;
Expand Down Expand Up @@ -74,16 +72,16 @@ public function test_get_users_site_config() {
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/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([
[
'id' => $admin->id,
'fullname' => fullname($admin),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
[
'id' => $admin->id,
'fullname' => fullname($admin),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
], $result);
}

Expand All @@ -92,23 +90,23 @@ public function test_get_users_site_viewreports() {
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/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([
[
'id' => $manager->id,
'fullname' => fullname($manager),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
[
'id' => $admin->id,
'fullname' => fullname($admin),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
[
'id' => $manager->id,
'fullname' => fullname($manager),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
[
'id' => $admin->id,
'fullname' => fullname($admin),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
], $result);
}

Expand All @@ -117,7 +115,7 @@ public function test_get_users_customsql_view() {
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/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([
[
Expand Down Expand Up @@ -145,11 +143,13 @@ public function test_get_users_customsql_view() {
}

public function test_get_users_serch_without_admins() {
global $OUTPUT;

[, $manager] = $this->setup_users();
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/boost/core/1/u/f2';
$defaultuserimage = $OUTPUT->image_url('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([
[
Expand All @@ -167,16 +167,16 @@ public function test_get_users_serch_with_admin() {
$defaultuserimage = 'https://www.example.com/moodle/theme/image.php/_s/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([
[
'id' => $admin->id,
'fullname' => fullname($admin),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
[
'id' => $admin->id,
'fullname' => fullname($admin),
'identity' => '[email protected]',
'hasidentity' => true,
'profileimageurlsmall' => $defaultuserimage,
],
], $result);
}
}
2 changes: 1 addition & 1 deletion tests/local/category_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
* @copyright 2021 The Open University
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class _category_test extends \advanced_testcase {
class category_test extends \advanced_testcase {
/**
* Test create category.
*/
Expand Down

0 comments on commit 318a026

Please sign in to comment.