Skip to content

Commit

Permalink
[auto-generated] Update plugin files
Browse files Browse the repository at this point in the history
Check out the commits that caused these changes: moodlehq/moodleapp@3dd5acc...ee2e785
  • Loading branch information
github-actions[bot] committed Oct 9, 2023
1 parent 5fadd6e commit bae3c18
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
37 changes: 35 additions & 2 deletions tests/behat/behat_app_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ public function parse_element_locator(string $text): string {
);

$locator = [
'text' => str_replace('\\"', '"', $matches[1]),
'text' => $this->transform_time_to_string(str_replace('\\"', '"', $matches[1])),
'selector' => $matches[2] ?? null,
];

if (!empty($matches[3])) {
$locator[$matches[3]] = (object) [
'text' => str_replace('\\"', '"', $matches[4]),
'text' => $this->transform_time_to_string(str_replace('\\"', '"', $matches[4])),
'selector' => $matches[5] ?? null,
];
}
Expand Down Expand Up @@ -608,4 +608,37 @@ protected function resize_app_window(int $width = 500, int $height = 720) {

$this->getSession()->getDriver()->resizeWindow($width + $offset['x'], $height + $offset['y']);
}

/**
* Given a string, search if it contains a time with the ## format and convert it to a timestamp or readable time.
* Only allows 1 occurence, if the text contains more than one time sub-string it won't work as expected.
* This function is similar to the arg_time_to_string transformation, but it allows the time to be a sub-text of the string.
*
* @param string $text
* @return string Transformed text.
*/
protected function transform_time_to_string(string $text): string {
if (!preg_match('/##(.*)##/', $text, $matches)) {
// No time found, return the original text.
return $text;
}

$timepassed = explode('##', $matches[1]);

// If not a valid time string, then just return what was passed.
if ((($timestamp = strtotime($timepassed[0])) === false)) {
return $text;
}

$count = count($timepassed);
if ($count === 2) {
// If timestamp with specified strftime format, then return formatted date string.
return str_replace($matches[0], userdate($timestamp, $timepassed[1]), $text);
} else if ($count === 1) {
return str_replace($matches[0], $timestamp, $text);
} else {
// If not a valid time string, then just return what was passed.
return $text;
}
}
}
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

defined('MOODLE_INTERNAL') || die;

$plugin->version = 2023092100;
$plugin->version = 2023100900;
$plugin->requires = 2016052300;
$plugin->maturity = MATURITY_STABLE;
$plugin->release = '4.3.0';
Expand Down

0 comments on commit bae3c18

Please sign in to comment.