46 Commits

Author SHA1 Message Date
Sara Arjona
32576936ad MDL-72347 filter: Remove censor filter
Word censorship filter is not widely used these days so it has been
removed from Moodle core.
2021-10-04 09:28:59 +02:00
Eloy Lafuente (stronk7)
ba5b6089d5 MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
    - assertRegExp()     -> assertMatchesRegularExpression()
    - assertNotRegExp()  -> assertDoesNotMatchRegularExpression()

This is about to, simply, move all cases to the new alternatives.

Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md

Regexp to find all them:

    ag 'assertRegExp|assertNotRegExp' -li
2021-03-11 19:22:24 +01:00
Bas Brands
4394f9e358 MDL-67735 theme_boost: remove bs2 and bs4alpha compatibility css 2020-08-17 08:16:42 +00:00
Paul Holden
eb9f830604 MDL-66762 user: stricter email validation. 2019-11-07 09:00:19 +08:00
[Peter Burnett]
d82b6004bf MDL-66280 core: Added unit tests for print_password_policy 2019-08-02 11:34:23 +10:00
Arjen Lentz
4b71e99564 MDL-21475 weblib: Simplify validate_email() to use existing function. 2019-02-19 10:51:21 +10:00
Andrew Nicols
8af75f08e8 MDL-36754 tests: Move moodle_url tests to own file 2018-08-14 07:06:09 +08:00
Jun Pataleta
c353ad20c3 MDL-45170 core: Integration review fixes
* Pass $forcehttps parameter to call extract_draft_file_urls_from_text()
 call in \core_weblib_testcase::test_extract_draft_file_urls_from_text()
* Style fixes
2018-08-08 16:17:32 +08:00
Charles Fulton
7d7d3b1731 MDL-45170 files: check other draftfile areas when processing 2018-08-08 16:15:23 +08:00
Ryan Wyllie
748545858c MDL-60942 filters: include filter in format_string cache key 2017-12-01 06:49:24 +00:00
Matteo Scaramuccia
cdf8238b14 MDL-57379 Files: Improved file argument evaluation.
get_file_argument() is responsible to extract the relative path
of the file to be served by a specific Moodle component
like a theme or a module.
Some modules like scorm and imscp require slasharguments support
and they force it when creating the URLs to serve their files.
It should honor the slasharguments setting but this could break
those instances where existing hard-coded links still make usage of
the "old" format, the one when slasharguments is set to No i.e. '?file='.

Its logic has been improved by looking at when the URL is related to
serving a plug-in file in a "forced" slasharguments way of serving it
i.e. using '/pluginfile.php/' and not '/pluginfile.php?'.
2017-02-19 16:39:04 +01:00
David Mudrák
7620746f67 MDL-57531 mail: Make validate_email return actual boolean as expected
It was discovered by unit tests that the return value is not a real
boolean as was intuitively expected and documented. To avoid potential
issues with the truthyness in the future, we explicitly cast the return
value to boolean now.
2017-01-04 13:16:07 +01:00
David Mudrák
61367eb639 MDL-57531 mail: Validate the sender's email address
The patch adds validation for the noreplyaddress setting variable, for
the explicit $replyto parameter and for the sender's email. In case of
misconfigured noreplyaddress setting, it falls back to the default
noreply address value. In case of invalid email in the user's record,
the email is not sent.

The patch also adds unit test for the value returned by the function
generate_email_processing_address() so that it can be considered as a
valid email, too.

This is supposed to significantly minimise the risk of exploiting the
vulnerability in PHPMailer's Sender field.
2017-01-04 12:35:19 +01:00
sam marshall
b16b1f86b1 MDL-55650 Library: s() function - tweak parameters for performance
The s() function includes a comment saying that parameter options
should be modified to improve performance once PHP 5.4 is required.
Since Moodle has required PHP 5.4 for some time, we should probably
make the change and remove the comment.

According to my benchmarking, these changes make s() about 7% faster
and will save a staggering 2ms from a typical course view that calls
it 8,000 times.
2016-08-22 15:38:13 +01:00
Rajesh Taneja
52f3e060e4
MDL-55091 phpunit: Following has been deprecated.
1. getMock()
2. setExpectedException()
3. checkForUnintentionallyCoveredCode renamed to beStrictAboutCoversAnnotation
4. beStrictAboutTestSize renamed to enforceTimeLimit
5. UnitTestCase class is now fully removed.
2016-07-26 10:11:30 +08:00
Cameron Ball
6fb1a7177f
MDL-47371 weblib: Add option to disable escaping 2016-07-12 10:31:17 +08:00
David Monllao
505ce88467 MDL-54627 search: Ensure that all format_string strings are text.
All user input that is usually displayed through format_strings with
filters like mulitlang applied should be converted to text as well.
2016-05-19 13:16:01 +08:00
Cameron Ball
3e3f624549 MDL-53393 libraries: Upgrade Html2Text to 4.0.1 2016-03-21 12:05:33 +08:00
Brendan Heywood
462065e822 MDL-51718 weblib: Allow moodle_url scheme to be set 2015-11-05 09:08:00 +11:00
Andrew Nicols
44250050dc MDL-51524 tests: Fix broken tests
The upgraded version of HTML2Text highlighted some bugs in our unit tests.

In the IOS test, the HTML content includes a couple of patches of  
In the previous version of HTML2Text, these were being converted to
breaking spaces. In one of these cases, it was then removed due to a trim.
The expected texts have been converted to use the correct non-breaking spaces.
In the case of the trimmed one, it is no longer trimmed as non-breaking
spaces are not trimmed.
This gives a truer reflection of the actual text.

In the case of the Outlook test, this trailing whitespace is not present in
the source. It was likely caused by a bug in the previous version of
HTML2Text.

In the case of the weblib change, the test was just wrong. Both of the
actual characters are encodings for an HTML bullet (decimal and hex) and
should both be converted to the relevant UTF8 representation of this
bullet.
2015-10-12 09:35:59 +08:00
Jetha Chan
b42cb67935 MDL-50868 weblib: add unit test for ruby support 2015-07-24 14:09:48 +09:00
Sam Hemelryk
9915109268 MDL-48304 moodle_url: compare now considers anchor 2014-11-20 15:38:34 +13:00
Tim Hunt
1fa2823de8 MDL-46688 weblib: improve the highlight function.
Thanks to Joseph Baxter for suggesting some of the test cases.
2014-08-08 17:51:58 +01:00
Frederic Massart
0a8b3583ca MDL-42995 libraries: Global function to strip pluginfile content 2014-01-06 09:29:25 +01:00
Petr Škoda
a9d2f1b414 MDL-41707 allow custom location of external test files used from unit tests 2013-09-27 10:47:56 +02:00
Simon Coggins
d06ffbdf2d MDL-41806 Add assessors to moodle_url class
New assessors for scheme, host and port.
2013-09-16 16:14:29 +12:00
Petr Škoda
037d673ea9 MDL-39474 add set_debugging() tests 2013-08-21 15:41:35 +02:00
Petr Škoda
b33bf039f3 MDL-39915 cleanup core_weblib_testcase 2013-07-28 15:06:23 +02:00
Sam Hemelryk
61b223a632 MDL-40635 moodle_url: can now set anchor during construction 2013-07-15 10:17:49 +12:00
Petr Škoda
66056f994f MDL-39096 fix obfuscate_text() utf-8 compatibility 2013-06-07 22:38:48 +02:00
Eloy Lafuente (stronk7)
bee592add8 Merge branch 'wip-MDL-39216-m25' of git://github.com/samhemelryk/moodle 2013-05-01 02:29:36 +02:00
Sam Hemelryk
a697000b53 MDL-39216 url: included test for empty string param 2013-05-01 12:27:36 +12:00
Sam Hemelryk
45d9752205 MDL-39216 url: updated tests to show desired outcome 2013-04-30 11:09:47 +12:00
Sam Hemelryk
616396a6cf MDL-39216 url: new moodle_url tests for valueless params 2013-04-30 11:09:47 +12:00
Tim Hunt
328ac3069b MDL-39378 Improve s() performance.
These changes give about a 10% speed-up in this function. The significant changes are:
1. Simplify the if logic to remove unnecssary cases.
2. Dont pass default argument values to htmlspecialchars, just using the
   defaults is faster.
3. I can confirm that /i regex is faster than the equivalent regex without the i.

I also added more unit tests to test the edge cases.
2013-04-26 18:49:25 +01:00
Tim Hunt
0c6f9e759b MDL-39378 s(): fix bad hex regex 2013-04-26 18:38:29 +01:00
Dan Poltawski
be576cb0e8 Merge branch 'wip-mdl-36674' of git://github.com/rajeshtaneja/moodle 2013-01-21 10:15:16 +08:00
Rajesh Taneja
72b181ba59 MDL-36674 Administration: out_as_local_url will check for both http and https url's
out_as_local_url will first check if url passed in wwwroot, if it's not then it will check
if loginhttps is enabled and url is httpswwwroot
2013-01-14 15:59:06 +08:00
Petr Škoda
4fa7fdeada MDL-37286 improve coding style in unit tests 2013-01-12 15:28:57 +01:00
Petr Škoda
e7259ec998 MDL-37286 add new combined_progress_trace
This type of trace should be useful when multiple trace outputs requested.
2013-01-12 15:16:39 +01:00
Petr Škoda
837e304260 MDL-37286 add progres_trace buffer and unit tests 2013-01-12 15:16:38 +01:00
sam marshall
ffe4de973b MDL-29624 Media embedding system, part 0: Add get_path() to moodle_url
(It may not seem directly related, but this function is needed for the
media embedding system.
2012-05-09 18:22:12 +01:00
Petr Skoda
bd319d12c2 MDL-30686 fix typo
Thanks Dan Poltawski!
2012-04-27 13:39:18 +02:00
Petr Skoda
f0202ae9a2 MDL-30686 improve accuracy of qualified_me() by trying PAGE->url first
This should help SSL proxies and returning to current page after require_login().
2012-04-27 13:39:18 +02:00
Petr Skoda
4ca04fb58b MDL-32569 remove remaining references to simpletest and improve events test 2012-04-21 17:08:30 +02:00
Petr Skoda
a3d5830a0a MDL-32149 PHPUnit test support - part 2
Includes:
* constants refactoring
* reworked db table init
* support for $CFG->debug = -1
* functional DB tests
* fixed $DB->get_indexes() to not throw exceptions when table does not exist
* fix handling of user passwords in test db
* add debug info to exception messages
* removed unnecessary PHP debug errors from mathslib
* fixed @error suppression in get_string
* fixed PHPUnit error handler setup
* added timezone info to default install
2012-04-03 22:30:53 +02:00