Skip to content

Commit 3b0c92d

Browse files
[auto-generated] Update plugin files
Check out the commits that caused these changes: moodlehq/moodleapp@6a0823d...6c5984e
1 parent 1e098bb commit 3b0c92d

File tree

5 files changed

+27
-29
lines changed

5 files changed

+27
-29
lines changed

tests/behat/behat_app.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ public function login(string $username) {
283283

284284
// Wait until the main page appears.
285285
$this->spin(
286-
function($context, $args) {
286+
function($context) {
287287
$initialpage = $context->getSession()->getPage()->find('xpath', '//page-core-mainmenu') ??
288288
$context->getSession()->getPage()->find('xpath', '//page-core-login-change-password') ??
289289
$context->getSession()->getPage()->find('xpath', '//page-core-user-complete-profile');
@@ -780,7 +780,7 @@ public function the_app_should_have_opened_a_browser_tab(bool $not = false, ?str
780780
if (!is_null($urlpattern)) {
781781
$this->getSession()->switchToWindow($windowNames[1]);
782782
$windowurl = $this->getSession()->getCurrentUrl();
783-
$windowhaspattern = !!preg_match("/$urlpattern/", $windowurl);
783+
$windowhaspattern = (bool)preg_match("/$urlpattern/", $windowurl);
784784
$this->getSession()->switchToWindow($windowNames[0]);
785785

786786
if ($not === $windowhaspattern) {
@@ -885,6 +885,8 @@ public function i_switch_network_connection(string $mode) {
885885
case 'offline':
886886
$this->runtime_js("network.setForceConnectionMode('none');");
887887
break;
888+
default:
889+
break;
888890
}
889891
}
890892

tests/behat/behat_app_helper.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,9 @@ protected function replace_arguments(string $text): string {
412412
preg_match_all("/\\$\\{([^:}]+):([^}]+)\\}/", $text, $matches);
413413

414414
foreach ($matches[0] as $index => $match) {
415-
switch ($matches[2][$index]) {
416-
case 'cmid':
417-
$coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]);
418-
$text = str_replace($match, $coursemodule->id, $text);
419-
420-
break;
415+
if ($matches[2][$index] == 'cmid') {
416+
$coursemodule = $DB->get_record('course_modules', ['idnumber' => $matches[1][$index]]);
417+
$text = str_replace($match, $coursemodule->id, $text);
421418
}
422419
}
423420

@@ -550,7 +547,7 @@ protected function handle_url(string $customurl, string $successXPath = '') {
550547
if (!empty($successXPath)) {
551548
// Wait until the page appears.
552549
$this->spin(
553-
function($context, $args) use ($successXPath) {
550+
function($context) use ($successXPath) {
554551
$found = $context->getSession()->getPage()->find('xpath', $successXPath);
555552
if ($found) {
556553
return true;
@@ -597,7 +594,6 @@ protected function get_cm_by_activity_name_and_course(string $activity, string $
597594
$cmfrom = $cmtable->get_from_sql();
598595

599596
$acttable = new \core\dml\table($activity, 'a', 'a');
600-
$actselect = $acttable->get_field_select();
601597
$actfrom = $acttable->get_from_sql();
602598

603599
$sql = <<<EOF
@@ -662,7 +658,7 @@ protected function get_first_restricted_version_tag(): ?string {
662658
// Set up relevant tags for each version.
663659
$usedtags = array_keys($usedtags);
664660
foreach ($usedtags as $usedtag) {
665-
if (!preg_match('~^lms_(from|upto)([0-9]+(?:\.[0-9]+)*)$~', $usedtag, $matches)) {
661+
if (!preg_match('~^lms_(from|upto)(\d+(?:\.\d+)*)$~', $usedtag, $matches)) {
666662
// No match, ignore.
667663
continue;
668664
}

tests/behat/behat_performance.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,8 @@ public function parse_time(string $text): float {
7878
$spaceindex = strpos($text, ' ');
7979
$value = floatval(substr($text, 0, $spaceindex));
8080

81-
switch (substr($text, $spaceindex + 1)) {
82-
case 'seconds':
83-
$value *= 1000;
84-
break;
81+
if (substr($text, $spaceindex + 1) == 'seconds') {
82+
$value *= 1000;
8583
}
8684

8785
return $value;
@@ -108,6 +106,8 @@ public function parse_comparison(string $text): Closure {
108106
return function ($a, $b) {
109107
return $a === $b;
110108
};
109+
default:
110+
break;
111111
}
112112
}
113113

tests/behat/classes/performance_measure.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,13 @@ private function analyseDuration(): void {
247247
* Analyse long tasks.
248248
*/
249249
private function analyseLongTasks(): void {
250-
$blocking = 0;
250+
$blockingDuration = 0;
251251

252252
foreach ($this->longTasks as $longTask) {
253-
$blocking += $longTask['duration'] - 50;
253+
$blockingDuration += $longTask['duration'] - 50;
254254
}
255255

256-
$this->blocking = $blocking;
256+
$this->blocking = $blockingDuration;
257257
}
258258

259259
/**
@@ -269,43 +269,43 @@ private function analyseDatabaseUsage(): void {
269269
private function analysePerformanceLogs(): void {
270270
global $CFG;
271271

272-
$scripting = 0;
273-
$styling = 0;
274-
$networking = 0;
272+
$scriptingDuration = 0;
273+
$stylingDuration = 0;
274+
$networkingCount = 0;
275275
$logs = $this->getPerformanceLogs();
276276

277277
foreach ($logs as $log) {
278278
// TODO this should filter by end time as well, but it seems like the timestamps are not
279279
// working as expected.
280-
if (($log['timestamp'] < $this->start)) {
280+
if ($log['timestamp'] < $this->start) {
281281
continue;
282282
}
283283

284284
$message = json_decode($log['message'])->message;
285285
$messagename = $message->params->name ?? '';
286286

287287
if (in_array($messagename, ['FunctionCall', 'GCEvent', 'MajorGC', 'MinorGC', 'EvaluateScript'])) {
288-
$scripting += $message->params->dur;
288+
$scriptingDuration += $message->params->dur;
289289

290290
continue;
291291
}
292292

293293
if (in_array($messagename, ['UpdateLayoutTree', 'RecalculateStyles', 'ParseAuthorStyleSheet'])) {
294-
$styling += $message->params->dur;
294+
$stylingDuration += $message->params->dur;
295295

296296
continue;
297297
}
298298

299299
if (in_array($messagename, ['XHRLoad']) && !str_starts_with($message->params->args->data->url, $CFG->behat_ionic_wwwroot)) {
300-
$networking++;
300+
$networkingCount++;
301301

302302
continue;
303303
}
304304
}
305305

306-
$this->scripting = round($scripting / 1000);
307-
$this->styling = round($styling / 1000);
308-
$this->networking = $networking;
306+
$this->scripting = round($scriptingDuration / 1000);
307+
$this->styling = round($stylingDuration / 1000);
308+
$this->networking = $networkingCount;
309309
}
310310

311311
/**

version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

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

9-
$plugin->version = 2022080500;
9+
$plugin->version = 2022090200;
1010
$plugin->requires = 2016052300;
1111
$plugin->maturity = MATURITY_STABLE;
1212
$plugin->release = '4.1.0-dev';

0 commit comments

Comments
 (0)