From b86e1d14232d531ce3ef22ffaab9583e240f0337 Mon Sep 17 00:00:00 2001 From: Mo Farouk <122031508+fmido88@users.noreply.github.com> Date: Sat, 17 Feb 2024 02:48:34 +0200 Subject: [PATCH] cs fix --- classes/category/options.php | 3 ++- classes/privacy/provider.php | 2 +- classes/util/balance.php | 2 +- classes/util/cm.php | 2 +- styles.css | 2 +- tests/coupons_test.php | 22 +++++++++++----------- tests/util/balance_op_test.php | 14 +++++++------- tests/util/instance_test.php | 2 +- 8 files changed, 25 insertions(+), 24 deletions(-) diff --git a/classes/category/options.php b/classes/category/options.php index e989eb0f..630e9ea2 100644 --- a/classes/category/options.php +++ b/classes/category/options.php @@ -108,12 +108,13 @@ public function get_parents_options() { * @return array[string] */ public static function get_all_categories_options() { - $catoptions = [0 => get_string('any')]; + $catoptions = []; $allcats = \core_course_category::get_all(); foreach ($allcats as $catid => $cat) { $catoptions[$catid] = $cat->get_nested_name(false); } asort($catoptions, SORT_STRING | SORT_FLAG_CASE); + $catoptions = [0 => get_string('any')] + $catoptions; return $catoptions; } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 030eaadc..8e169bea 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -46,7 +46,7 @@ class provider implements * @param collection $collection The initialized collection to add items to. * @return collection A listing of user data stored through this system. */ - public static function get_metadata(collection $collection) :collection { + public static function get_metadata(collection $collection): collection { $collection->add_database_table('enrol_wallet_items', [ 'userid' => "privacy:metadata:enrol_wallet_items:userid", 'cost' => "privacy:metadata:enrol_wallet_items:cost", diff --git a/classes/util/balance.php b/classes/util/balance.php index 7b093875..d80ffcc5 100644 --- a/classes/util/balance.php +++ b/classes/util/balance.php @@ -181,7 +181,7 @@ protected function set_main_balance() { * from the transaction table. * @return float */ - private function get_nonrefund_from_transactions():float { + private function get_nonrefund_from_transactions(): float { global $DB; $balance = $this->get_main_balance(); $record = $DB->get_records('enrol_wallet_transactions', ['userid' => $this->userid], 'id DESC', 'norefund', 0, 1); diff --git a/classes/util/cm.php b/classes/util/cm.php index 8715bf9c..4846fee1 100644 --- a/classes/util/cm.php +++ b/classes/util/cm.php @@ -98,7 +98,7 @@ public function __construct($cmid, $userid = 0) { * Set all available costs for this cm, considering multiple conditions may be applied. * @param \stdClass $conditions the availability tree. */ - private function set_costs ($conditions) { + private function set_costs($conditions) { foreach ($conditions->c as $child) { if (!empty($child->c) && !empty($child->op)) { $this->set_costs($child); diff --git a/styles.css b/styles.css index fda76d94..d3e38531 100644 --- a/styles.css +++ b/styles.css @@ -133,7 +133,7 @@ font-size: 0.8em; } } - + .enrol_wallet_topup .accordion .accordion__title { display: block; font-size: 1.1rem; diff --git a/tests/coupons_test.php b/tests/coupons_test.php index b1a2c6f1..cba96b17 100644 --- a/tests/coupons_test.php +++ b/tests/coupons_test.php @@ -78,7 +78,7 @@ class coupons_test extends \advanced_testcase { * Test if a certain type of coupons are enabled * @covers ::is_enabled_type */ - public function test_is_enabled_type():void { + public function test_is_enabled_type(): void { $this->setUser($this->u2); $coupons = new coupons('fixed1'); $this->assertFalse($coupons->is_enabled_type()); @@ -119,7 +119,7 @@ public function test_is_enabled_type():void { * Test if coupons are enabled in this site. * @covers ::is_enabled() */ - public function test_is_enabled():void { + public function test_is_enabled(): void { $this->assertFalse(coupons::is_enabled()); $this->set_config(coupons::DISCOUNT); $this->assertTrue(coupons::is_enabled()); @@ -138,7 +138,7 @@ public function test_is_enabled():void { * Test validation for fixed coupons * @covers ::validate_coupon() */ - public function test_validate_fixed_coupon():void { + public function test_validate_fixed_coupon(): void { $this->set_config(coupons::ALL); // Not logged in. $coupons = new coupons('fixed1'); @@ -212,7 +212,7 @@ public function test_validate_fixed_coupon():void { * Test validation for enrol coupons * @covers ::validate_coupon */ - public function test_validate_enrol_coupon():void { + public function test_validate_enrol_coupon(): void { $this->setUser($this->u1); $this->set_config([coupons::ENROL]); $coupons = new coupons('enrol1'); @@ -329,7 +329,7 @@ public function test_validate_enrol_coupon():void { * Validation for discount coupons. * @covers ::validate_coupon() */ - public function test_validate_discount_coupon():void { + public function test_validate_discount_coupon(): void { $this->set_config(coupons::DISCOUNT); $coupons = new coupons('percent1'); $this->assertNotTrue($coupons->validate_coupon(coupons::AREA_ENROL, $this->inst1->id)); @@ -437,7 +437,7 @@ public function test_validate_discount_coupon():void { * Validate category coupons * @covers ::validate_coupons() */ - public function test_validate_category_coupon():void { + public function test_validate_category_coupon(): void { $this->set_config(coupons::CATEGORY); // Not logged in. $coupons = new coupons('category1'); @@ -506,7 +506,7 @@ public function test_validate_category_coupon():void { * Test applying fixed coupon * @covers ::apply_coupon() */ - public function test_apply_fixed_coupon():void { + public function test_apply_fixed_coupon(): void { $this->set_config(coupons::FIXED); $coupons = new coupons('fixed1', $this->u1->id); $coupons->apply_coupon(); @@ -576,7 +576,7 @@ public function test_apply_fixed_coupon():void { * Test applying category coupon * @covers ::apply_coupon() */ - public function test_apply_category_coupon():void { + public function test_apply_category_coupon(): void { $this->set_config(coupons::CATEGORY); $this->setUser($this->u1); @@ -616,7 +616,7 @@ public function test_apply_category_coupon():void { * Test applying enrol coupons * @covers ::apply_coupon */ - public function test_apply_enrol_coupon():void { + public function test_apply_enrol_coupon(): void { $this->set_config(coupons::ENROL); $this->setUser($this->u1); $coupons = new coupons('enrol1'); @@ -647,7 +647,7 @@ public function test_apply_enrol_coupon():void { * Generate a number of coupons of different data, types and restrictions * to be tested. */ - protected function setUp() :void { + protected function setUp(): void { parent::setUp(); global $DB, $CFG; require_once($CFG->dirroot."/enrol/wallet/locallib.php"); @@ -945,7 +945,7 @@ protected function setUp() :void { * We will use this frequently, so we can shorten the arguments. * @param int|array $value */ - private function set_config($value) { + private function set_config($value): void { if (is_array($value)) { $value = implode(',', $value); } diff --git a/tests/util/balance_op_test.php b/tests/util/balance_op_test.php index 4a73dd92..c63beb13 100644 --- a/tests/util/balance_op_test.php +++ b/tests/util/balance_op_test.php @@ -188,7 +188,7 @@ public function test_conditional_discount_charging(): void { * @covers ::credit * @return void */ - public function test_credit():void { + public function test_credit(): void { global $DB; $this->resetAfterTest(); $gen = $this->getDataGenerator(); @@ -377,7 +377,7 @@ public function test_credit():void { * @covers ::credit * @return void */ - public function test_credit_nocat():void { + public function test_credit_nocat(): void { global $DB; $this->resetAfterTest(); $gen = $this->getDataGenerator(); @@ -506,7 +506,7 @@ public function test_credit_nocat():void { * @covers ::debit * @return void */ - public function test_debit():void { + public function test_debit(): void { global $DB; $this->resetAfterTest(); $gen = $this->getDataGenerator(); @@ -640,7 +640,7 @@ public function test_debit():void { * @covers ::debit * @return void */ - public function test_debit_nocat():void { + public function test_debit_nocat(): void { global $DB; $this->resetAfterTest(); set_config('catbalance', 0, 'enrol_wallet'); @@ -802,7 +802,7 @@ public function test_debit_nocat():void { * @covers ::get_total_free * @return void */ - public function test_free_balance():void { + public function test_free_balance(): void { global $DB; $this->resetAfterTest(); $gen = $this->getDataGenerator(); @@ -940,7 +940,7 @@ public function test_free_balance():void { * Test transferring balance to another user. * @covers ::transfer_to_other() */ - public function test_transfer_to_other():void { + public function test_transfer_to_other(): void { $this->resetAfterTest(); $gen = $this->getDataGenerator(); $user1 = $gen->create_user(); @@ -1029,7 +1029,7 @@ public function test_transfer_to_other():void { * Used to reset the balance of a user to zero. * @param int $userid */ - private function reset_balance($userid):void { + private function reset_balance($userid): void { $op = new balance_op($userid); $op->debit($op->get_valid_balance(), $op::OTHER); $details = $op->get_balance_details(); diff --git a/tests/util/instance_test.php b/tests/util/instance_test.php index 71e79e03..60ab06c2 100644 --- a/tests/util/instance_test.php +++ b/tests/util/instance_test.php @@ -142,7 +142,7 @@ public function test_get_cost_after_discount(): void { * Testing discounts after first and second repurchase * @covers ::get_cost_after_discount */ - public function test_repurchase_discount_and_function():void { + public function test_repurchase_discount_and_function(): void { global $DB; $this->resetAfterTest(); $wallet = new enrol_wallet_plugin;