mirror of
https://github.com/moodle/moodle.git
synced 2025-04-25 10:26:17 +02:00
MDL-74866 bennu: Fix parameter parsing
Some parameter values are wrapped by DQUOTE character. We need to go through and get the actual value inside the quoted string.
This commit is contained in:
parent
a7514f231d
commit
fd475bf7e8
@ -137,16 +137,39 @@ class behat_calendar extends behat_base {
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to a specific date in the calendar.
|
||||
* Navigate to a specific month in the calendar.
|
||||
*
|
||||
* @Given /^I view the calendar for "(?P<month>\d+)" "(?P<year>\d+)"$/
|
||||
* @param int $month the month selected as a number
|
||||
* @param int $year the four digit year
|
||||
*/
|
||||
public function i_view_the_calendar_for($month, $year) {
|
||||
$time = make_timestamp($year, $month, 1);
|
||||
$this->execute('behat_general::i_visit', ['/calendar/view.php?view=month&course=1&time='.$time]);
|
||||
$this->view_the_calendar('month', 1, $month, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* Navigate to a specific date in the calendar.
|
||||
*
|
||||
* @Given /^I view the calendar for "(?P<day>\d+)" "(?P<month>\d+)" "(?P<year>\d+)"$/
|
||||
* @param int $day the day selected as a number
|
||||
* @param int $month the month selected as a number
|
||||
* @param int $year the four digit year
|
||||
*/
|
||||
public function i_view_the_calendar_day_view(int $day, int $month, int $year) {
|
||||
$this->view_the_calendar('day', $day, $month, $year);
|
||||
}
|
||||
|
||||
/**
|
||||
* View the correct calendar view with specific day
|
||||
*
|
||||
* @param string $type type of calendar view: month or day
|
||||
* @param int $day the day selected as a number
|
||||
* @param int $month the month selected as a number
|
||||
* @param int $year the four digit year
|
||||
*/
|
||||
private function view_the_calendar(string $type, int $day, int $month, int $year) {
|
||||
$time = make_timestamp($year, $month, $day);
|
||||
$this->execute('behat_general::i_visit', ['/calendar/view.php?view=' . $type . '&course=1&time=' . $time]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,3 +85,20 @@ Feature: Import and edit calendar events
|
||||
And I upload "calendar/tests/fixtures/import.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Import calendar"
|
||||
And I should see "Site events"
|
||||
|
||||
Scenario: Import iCalendar file with parameter.
|
||||
Given I log in as "admin"
|
||||
And I view the calendar for "7" "2022"
|
||||
And I click on "Import or export calendars" "link"
|
||||
And I press "Import calendar"
|
||||
And I set the following fields to these values:
|
||||
| Calendar name | Test Import |
|
||||
| Import from | Calendar file (.ics) |
|
||||
| Type of event | User |
|
||||
And I upload "calendar/tests/fixtures/import_with_parameters.ics" file to "Calendar file (.ics)" filemanager
|
||||
And I press "Import calendar"
|
||||
When I view the calendar for "1" "7" "2022"
|
||||
Then I should see "First event"
|
||||
And I should see "Description of the first event"
|
||||
And I should see "Second event"
|
||||
And I should see "Description of the second event"
|
||||
|
27
calendar/tests/fixtures/import_with_parameters.ics
vendored
Normal file
27
calendar/tests/fixtures/import_with_parameters.ics
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
BEGIN:VCALENDAR
|
||||
METHOD:PUBLISH
|
||||
PRODID:-//Huong Nguyen/NONSGML Moodle//EN
|
||||
VERSION:2.0
|
||||
BEGIN:VEVENT
|
||||
UID:special_import_moodle_1
|
||||
SUMMARY:First event
|
||||
DESCRIPTION:Description of the first event\n
|
||||
CLASS:PUBLIC
|
||||
LAST-MODIFIED:20220728T034015Z
|
||||
LOCATION:Vietnam
|
||||
DTSTAMP:20220728T034031Z
|
||||
DTSTART:20220701T070000Z
|
||||
DTEND:20220701T070000Z
|
||||
END:VEVENT
|
||||
BEGIN:VEVENT
|
||||
UID:special_import_moodle_2
|
||||
SUMMARY:Second event
|
||||
DESCRIPTION;ALTREP="http://moodle.com/":Description of the second event\n
|
||||
CLASS:PUBLIC
|
||||
LAST-MODIFIED:20220728T034021Z
|
||||
LOCATION:Vietnam
|
||||
DTSTAMP:20220728T034031Z
|
||||
DTSTART:20220701T080000Z
|
||||
DTEND:20220701T080000Z
|
||||
END:VEVENT
|
||||
END:VCALENDAR
|
@ -303,6 +303,18 @@ class iCalendar_component {
|
||||
$component = $this; // use the iCalendar
|
||||
}
|
||||
|
||||
$cleanedparams = [];
|
||||
// Some parameter values are wrapped by DQUOTE character.
|
||||
// We need to go through and get the actual value inside the quoted string.
|
||||
foreach ($params as $param => $value) {
|
||||
if (preg_match('#"(?P<actualvalue>[^"]*?)"#', $value, $matches)) {
|
||||
$cleanedparams[$param] = $matches['actualvalue'];
|
||||
} else {
|
||||
$cleanedparams[$param] = $value;
|
||||
}
|
||||
}
|
||||
$params = $cleanedparams;
|
||||
|
||||
if ($component->add_property($label, $data, $params) === false) {
|
||||
$this->parser_error("Failed to add property '$label' on line $key");
|
||||
}
|
||||
|
@ -28,3 +28,4 @@ Changelog
|
||||
9/ MDL-60391: replace create_function() with lambda function for PHP 7.2 compatibility (13 Oct 2017)
|
||||
10/ MDL-62914: added handling for TZURL property (13 July 2018)
|
||||
11/ MDL-67029: replace curly by square brackets for string offsets. PHP 7.4 compatibility (25 Oct 2019)
|
||||
12/ MDL-74866: fixed parameter parsing if the value is wrapped by DQUOTE character (28 Jul 2022)
|
||||
|
Loading…
x
Reference in New Issue
Block a user