Before this change we were setting the month day to 1 unconditionally
and that was working ok for enabled by default elements.
But in a number or cases we were doing that against disabled elements
so the day reset was not happening. Now we wait for the element to
be enabled and only then proceed with the day reset.
Backed with tests using disabled form elements, so we have now
both enabled and disabled fields covered.
It has been detected, thanks to php80 specially, that there are
various places in core where support for localised floats is
missing. Before php80, some locale-dependent conversions were
performed by PHP, allowing things to work. But with php80 all
those comparisons are now locale-independent. See:
https://wiki.php.net/rfc/locale_independent_float_to_string
That implies that we now need to, always, unformat floats to
be internally the correct (decimal point as separator) in
order to compare it.
While this was visited in the php80 epic (MDL-70745), nothing
was found, all automated tests were passing ok. Problem is that
we run behat tests with en-AU laguage that has the decimal point
separator.
So, in this issue we are fixing all the problems detected by
running those Behat tests using localised (comma) decimal
separator.
Note that there may be other places still causing problems, but
it's really hard to find them programmatically, so we'll have to
wait for real use reports / issues and go fixing them while they
happen.
Back to this commit, this is the list of changes performed (note that
in the next commit, we'll be adding scenarios explicitly using
a localised decimal separator to ensure that they work ok).
A. Changes to various grade forms to ensure that, on their validation
floats are unformatted properly. Also, changed the corresponding
form element from current text/PARAM_RAW to proper float ones that
take care of the conversion in a number of places (but when disabled,
that's the reason we still have to unformat in validation.
This includes the following forms:
- edit_category_form
- edit_item_form
(this is the original problem reported that cause all the research
to be performed against full behat runs)
B. Changes to edit_letter_form, so it uses a proper PARAM_LOCALISEDFLOAT
(note this is the type of change that surely should be used for all
the rest of /grade/edit/tree form, including those in the previous
point).
C. Changes to the grade_item behat generator, so it's able to work with
localised floats, un-formatting them when needed.
At lib/behat/classes/behat_core_generator.php
D. Fix problem passing localised floats to scales, not displaying
properly. At grade/report/singleview/classes/local/ui/finalgrade.php
E. Change the behat text matcher in order to allow comparison of
localised floats when they are the current ones. Before this change
the matches was using soft/lazy comparison, so '50' and '50.0000'
match. Now, when the comma (for example) is used (and only then),
'50' and '50,000' will also match. This comparison is in use in a
bunch of tests and makes sense to make it localisation-aware.
At grade/report/singleview/classes/local/ui/finalgrade.php
F. Fix a couple of number_format() uses in lesson, because they are
not localised-aware. Switched to format_float(). At mod/lesson/locallib.php
G. Change the quiz_contains_the_following_questions() step to accept
localised maxmark expectations. At mod/quiz/tests/behat/behat_mod_quiz.php
H. Change the quiz generator so it accepts localised gradepass.
At mod/quiz/tests/generator/lib.php
I. Change the edit question form to show proper localised penalties,
previously it was always showing point-decimal ones. Of course,
leaving the values of the select element unmodified (internal floats).
Related, also change a couple of tests to, instead of try to match the
value (always internal floats), match the description (now localised),
so we can test them with different separators. At:
- question/type/ddimageortext/tests/behat/backup_and_restore.feature
- question/type/ddmarker/tests/behat/backup_and_restore.feature
- question/type/edit_question_form.php
This commit removes the moodle-behat-extension from the list of
third-party libraries.
In order to do this properly, all pending coding-style issues are fixed.
In addition the following niceties have also been included:
* convert long form array() syntax to short form
* alphabetically sort class imports (use)
* remove unused class imports
* correct documentation
* Normalise whitespace in concat operators
* Remove unnecessary file docblocks
Because of the way in which we check for exceptions, we always show the
following string during behat pretty output:
behat_hooks::i_look_for_exceptions()
We can easily modify this to only show this value when the
i_look_for_exceptions() test itself fails, but otherwise to show the
actual step that is run.
In some situations it is useful to modify the requested screensize by a
modifier. This allows for failing tests to be rerun at a different
screensize, where the original screensize triggered a failure for some
size-related reason.
When using a try/catch for a find if the first match is not met then we
have an implicit 6 second delay waiting for the search to time out.
We can avoid this by combining the searches in a comma-separated
selection.
I have also taken the opportunity to convert the use of ->click() to the
i_click_on function which has the benefit of supporting wait for
pendingJS.
The standard NodeElement functions for getAttribute, getTagName,
getParent, and friends go back to WebDriver and parse the DOM for each
request. This is insanely slow per request, and in the case of forms we
do a lot of checking to determine the field type.
This change modifies the form field detection to copy the entire node
content into a DOMDocument and parse the document locally.
This is significantly faster - in some cases where there are large
documents minutes faster.
I believe that this should be a safe change as the document fetched from
the browser is normalised to match the doctype specified.
This commit makes the following improvements to core page resolverss:
* allows for mixed case naming (course, Course, etc.)
* allows fields other than the idnumber to be specified:
** course: idnumber, shortname, fullname
** course category: idnumber, name
Whilst some of these fields are not unique, they will typically be
unique in most test scenarios. Where they are not then the idnumber
should be used in preference.
The activity generator currently requires an idnumber when creating
activities, but this is not a requirement when creating the same
activity through the UI. The requirement comes because we want to
provide a way to refer to activities in subsequent steps.
This commit modifies the behaviour such that the generator uses the name
of the activity as the default idnumber.
This has two main benefits:
1. it simplfies generation of activities; and
2. it makes the language used when writing behat tests much more natural.
With this change, steps will refer to the activity by its idnumber/title
in all cases, rather than sometimes by an idnumber which bears no
relevance to the title.
Try to correct broken ul/ol/li tags, as they have an outsized impact
on course layout. Uses basic regex and loops to track open and closed
tags.
Also adds a deep clean option to the HTML cleaner, that runs less
frequent, more intensive cleanings. This is because normally _cleanHTML
gets called after each keystroke, which could cause problems with
large content on weak systems.
Behat changes are a fix for setting multiline strings in Atto, and
creating a multiline match step.
This includes 2 change to the order date(time) elements are filled,
each one addressing one type of problem, where current order is
problematic and can lead to unexpected dates.
1) Changing date, when current month only has X days and target
month has more than X days. Example, being 1 April, change
the date to 31 May.
This is solved by changing the order of introduction
from current D => M => Y to Y => M => D.
2) Changing date, when target month only has X days and current
month has more that X days. Example, being 31 March, change
the date to 28 Feb.
This is solved by always setting the D to 1, before the
Y => M => D sequence commented @ 1) begins.