Skip to content

Commit

Permalink
Fix codestyle and pin moodle-plugin-ci version
Browse files Browse the repository at this point in the history
  • Loading branch information
justusdieckmann committed Aug 26, 2024
1 parent 8c7aaab commit fda9c06
Show file tree
Hide file tree
Showing 17 changed files with 367 additions and 422 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci 4.5.4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
Expand Down Expand Up @@ -173,7 +173,7 @@ jobs:
- name: Initialise moodle-plugin-ci
run: |
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci ^4
composer create-project -n --no-dev --prefer-dist moodlehq/moodle-plugin-ci ci 4.5.4
echo $(cd ci/bin; pwd) >> $GITHUB_PATH
echo $(cd ci/vendor/bin; pwd) >> $GITHUB_PATH
sudo locale-gen en_AU.UTF-8
Expand Down
6 changes: 3 additions & 3 deletions classes/capabilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ public static function has(string $capability, context $context, $userid = null)

$key = "$userid:$context->id:$capability";

if (!isset($cache[$key])) {
$cache[$key] = has_capability($capability, $context, $userid);
if (!isset(self::$cache[$key])) {
self::$cache[$key] = has_capability($capability, $context, $userid);
}

return $cache[$key];
return self::$cache[$key];
}

}
4 changes: 2 additions & 2 deletions classes/output/moodleoverflow_email.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class moodleoverflow_email implements \renderable, \templatable {
/**
* Whether the user can reply to this post.
*
* @var boolean $canreply
* @var bool $canreply
*/
protected $canreply = false;

/**
* Whether to override forum display when displaying usernames.
* @var boolean $viewfullnames
* @var bool $viewfullnames
*/
protected $viewfullnames = false;

Expand Down
1 change: 1 addition & 0 deletions classes/privacy/data_export_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Privacy Subsystem implementation for mod_moodleoverflow.
*
Expand Down
4 changes: 2 additions & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class provider implements
*
* @return collection the updated collection of metadata items.
*/
public static function get_metadata(collection $collection) : collection {
public static function get_metadata(collection $collection): collection {
$collection->add_database_table('moodleoverflow_discussions',
[
'name' => 'privacy:metadata:moodleoverflow_discussions:name',
Expand Down Expand Up @@ -135,7 +135,7 @@ public static function get_metadata(collection $collection) : collection {
*
* @return contextlist $contextlist The list of contexts used in this plugin.
*/
public static function get_contexts_for_userid(int $userid) : contextlist {
public static function get_contexts_for_userid(int $userid): contextlist {
// Fetch all Moodleoverflow discussions, moodleoverflow posts, ratings, tracking settings and subscriptions.
$sql = "SELECT c.id
FROM {context} c
Expand Down
1 change: 1 addition & 0 deletions grade.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* @copyright 2017 Kennet Winter <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

require_once(__DIR__ . "/../../config.php");
require_login();
$id = required_param('id', PARAM_INT);
Expand Down
722 changes: 330 additions & 392 deletions lang/en/moodleoverflow.php

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions tests/behat/behat_mod_moodleoverflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ protected function find_moodleoverflow_discussion_card(string $discussiontitle):
$discussiontitle . '"]]');
}

// phpcs:disable moodle.Files.LineLength.TooLong
/**
* Checks that an element and selector type exists in another element and selector type on the current page.
*
Expand All @@ -171,6 +172,7 @@ protected function find_moodleoverflow_discussion_card(string $discussiontitle):
* @param string $discussiontitle The discussion title
*/
public function should_exist_in_the_moodleoverflow_discussion_card($element, $selectortype, $discussiontitle) {
// phpcs:enable
// Get the container node.
$containernode = $this->find_moodleoverflow_discussion_card($discussiontitle);

Expand All @@ -182,6 +184,7 @@ public function should_exist_in_the_moodleoverflow_discussion_card($element, $se
$this->find($selectortype, $element, $exception, $containernode);
}

// phpcs:disable moodle.Files.LineLength.TooLong
/**
* Click on the element of the specified type which is located inside the second element.
*
Expand All @@ -191,6 +194,7 @@ public function should_exist_in_the_moodleoverflow_discussion_card($element, $se
* @param string $discussiontitle The discussion title
*/
public function i_click_on_in_the_moodleoverflow_discussion_card($element, $selectortype, $discussiontitle) {
// phpcs:enable
// Get the container node.
$containernode = $this->find_moodleoverflow_discussion_card($discussiontitle);

Expand All @@ -204,6 +208,7 @@ public function i_click_on_in_the_moodleoverflow_discussion_card($element, $sele
$node->click();
}

// phpcs:disable moodle.Files.LineLength.TooLong
/**
* Checks that an element and selector type does not exist in another element and selector type on the current page.
*
Expand All @@ -216,6 +221,7 @@ public function i_click_on_in_the_moodleoverflow_discussion_card($element, $sele
* @param string $discussiontitle The discussion title
*/
public function should_not_exist_in_the_moodleoverflow_discussion_card($element, $selectortype, $discussiontitle) {
// phpcs:enable
// Get the container node.
$containernode = $this->find_moodleoverflow_discussion_card($discussiontitle);

Expand Down
8 changes: 2 additions & 6 deletions tests/dailymail_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@
* @package mod_moodleoverflow
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \mod_moodleoverflow\task\send_daily_mail::execute
*/
class dailymail_test extends \advanced_testcase {
final class dailymail_test extends \advanced_testcase {

/** @var \stdClass collection of messages */
private $sink;
Expand Down Expand Up @@ -138,7 +139,6 @@ private function helper_run_send_mails() {

/**
* Test if the task send_daily_mail sends a mail to the user.
* @covers \send_daily_mail::execute
*/
public function test_mail_delivery(): void {
// Create user with maildigest = on.
Expand All @@ -154,7 +154,6 @@ public function test_mail_delivery(): void {

/**
* Test if the task send_daily_mail does not sends email from posts that are not in the course of the user.
* @return void
*/
public function test_delivery_not_enrolled(): void {
// Create user with maildigest = on.
Expand Down Expand Up @@ -201,7 +200,6 @@ public function test_delivery_not_enrolled(): void {

/**
* Test if the content of the mail matches the supposed content.
* @covers \send_daily_mail::execute
*/
public function test_content_of_mail_delivery(): void {

Expand Down Expand Up @@ -236,7 +234,6 @@ public function test_content_of_mail_delivery(): void {

/**
* Test if the task does not send a mail when maildigest = 0
* @covers \send_daily_mail::execute
*/
public function test_mail_not_send(): void {
// Creat user with daily_mail = off.
Expand All @@ -252,7 +249,6 @@ public function test_mail_not_send(): void {

/**
* Test if database is updated after sending a mail
* @covers \send_daily_mail::execute
*/
public function test_records_removed(): void {
global $DB;
Expand Down
2 changes: 1 addition & 1 deletion tests/locallib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @copyright 2017 Kennet Winter <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class locallib_test extends advanced_testcase {
final class locallib_test extends advanced_testcase {

public function setUp(): void {
\mod_moodleoverflow\subscriptions::reset_moodleoverflow_cache();
Expand Down
2 changes: 1 addition & 1 deletion tests/post_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class post_test extends \advanced_testcase {
final class post_test extends \advanced_testcase {

/** @var \stdClass test course */
private $course;
Expand Down
9 changes: 5 additions & 4 deletions tests/privacy_provider_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
//
// 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 moodleoverflow implementation of the Privacy Provider API.
*
Expand Down Expand Up @@ -41,7 +42,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \provider
*/
class privacy_provider_test extends \core_privacy\tests\provider_testcase {
final class privacy_provider_test extends \core_privacy\tests\provider_testcase {
/**
* @var \mod_moodleoverflow_generator Plugin generator
*/
Expand Down Expand Up @@ -587,7 +588,7 @@ public function test_post_attachment_inclusion(): void {
/**
* Ensure that all user data is deleted from a context.
*/
public function test_all_users_deleted_from_context() {
public function test_all_users_deleted_from_context(): void {
global $DB;
$fs = get_file_storage();
$course = $this->getDataGenerator()->create_course();
Expand Down Expand Up @@ -724,7 +725,7 @@ public function test_all_users_deleted_from_context() {
/**
* Ensure that all user data is deleted for a specific context.
*/
public function test_delete_data_for_user() {
public function test_delete_data_for_user(): void {
global $DB;
$fs = get_file_storage();
$course = $this->getDataGenerator()->create_course();
Expand Down Expand Up @@ -937,7 +938,7 @@ protected function create_and_enrol_users($course, $count) {
/**
* Ensure that user data for specific users is deleted from a specified context.
*/
public function test_delete_data_for_users() {
public function test_delete_data_for_users(): void {
global $DB;

$fs = get_file_storage();
Expand Down
2 changes: 1 addition & 1 deletion tests/ratings_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* @copyright 2023 Tamaro Walter
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class ratings_test extends \advanced_testcase {
final class ratings_test extends \advanced_testcase {
/** @var \stdClass test course */
private $course;

Expand Down
2 changes: 1 addition & 1 deletion tests/readtracking_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \readtracking
*/
class readtracking_test extends advanced_testcase {
final class readtracking_test extends advanced_testcase {

/**
* Test the logic in the moodleoverflow_can_track_moodleoverflows() function.
Expand Down
4 changes: 3 additions & 1 deletion tests/review_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*
* @group mod_moodleoverflow
* @covers \mod_moodleoverflow_external::review_approve_post
* @covers \mod_moodleoverflow_external::review_reject_post
*/
class review_test extends \advanced_testcase {
final class review_test extends \advanced_testcase {

/** @var \mod_moodleoverflow_generator $generator */
private $generator;
Expand Down
10 changes: 5 additions & 5 deletions tests/subscriptions_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @covers \subscriptions
*/
class subscriptions_test extends advanced_testcase {
final class subscriptions_test extends advanced_testcase {

/**
* Test setUp.
Expand Down Expand Up @@ -1360,7 +1360,7 @@ public function test_moodleoverflow_subscribe_toggle_as_other_repeat_subscriptio
*
* @return array
*/
public function is_subscribable_moodleoverflows() {
public static function is_subscribable_moodleoverflows() {
return [
[
'forcesubscribe' => MOODLEOVERFLOW_DISALLOWSUBSCRIBE,
Expand All @@ -1382,9 +1382,9 @@ public function is_subscribable_moodleoverflows() {
*
* @return array
*/
public function is_subscribable_provider(): array {
public static function is_subscribable_provider(): array {
$data = [];
foreach ($this->is_subscribable_moodleoverflows() as $moodleoverflow) {
foreach (self::is_subscribable_moodleoverflows() as $moodleoverflow) {
$data[] = [$moodleoverflow];
}

Expand Down Expand Up @@ -1440,7 +1440,7 @@ public function test_is_subscribable_is_guest($options): void {
* Returns subscription obtions.
* @return array
*/
public function is_subscribable_loggedin_provider(): array {
public static function is_subscribable_loggedin_provider(): array {
return [
[
['forcesubscribe' => MOODLEOVERFLOW_DISALLOWSUBSCRIBE],
Expand Down
2 changes: 1 addition & 1 deletion tests/userstats_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
*
* @covers \userstats_table
*/
class userstats_test extends \advanced_testcase {
final class userstats_test extends \advanced_testcase {

/** @var \stdClass test course */
private $course;
Expand Down

0 comments on commit fda9c06

Please sign in to comment.