Commit graph

10 commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
8a14a7bd22 MDL-71036 phpunit: assertContains() now performs strict comparison
The methods assertContains() and assertNotContains() now perform
strict (type and value) comparison, pretty much like assertSame()
does.

A couple of new assertContainsEquals() and assertNotContainsEquals()
methods have been created to provide old (non-strict) behavior, pretty
much like assertEquals() do.

Apart from replacing the calls needing a relaxed comparison to those
new methods, there are also a couple of alternative, about how to
fix this, depending of every case:

- If the test is making any array_values() conversion, then it's better
  to remove that conversion and use assertArrayHasKey(), that is not
  strict.
- Sometimes if may be also possible to, simply, cast the expectation
  to the exact type coming in the array. I've not applied this technique
  to any of the cases in core.

Link: https://github.com/sebastianbergmann/phpunit/issues/3426
2021-03-11 23:04:31 +01:00
Andrew Nicols
fe0944987e MDL-66011 test: remove magic @covers lines 2019-10-04 09:40:34 +08:00
Andrew Nicols
bc01342057 MDL-65130 privacy: Add @covers annotation to tests 2019-03-21 10:29:07 +08:00
Eloy Lafuente (stronk7)
c9840c0144 MDL-62619 privacy: Prevent action when boolean queries are involved
Before the patch, queries like:

SELECT 1 FROM dual UNION SELECT 2 FROM dual

were failing badly, with everything but the first numeric element
being ignored by the optimization.

So, being conservative, now we reduce the query being analysed,
ignoring any subquery, inline view (anything within parenthesis
in general) and, in the remaining query, if a boolean query (UNION,
MINUS, INTERSECT...) is found, we don't apply any optimization.
2018-08-09 16:05:55 +02:00
David Mudrák
cea03cbd43 MDL-62619 privacy: Fix some bits of performance improvements
* We need to use is_numeric() in this case as is_int() would never
  return true.
* Extend the supported cases, add support for SQL consisting just of
  numerical value or selectinga numerical constant.
* Do not rely on any particulat letter case in provided SQL.
* Add unit tests for the new method. Even when it is a protected one, it
  is an essential unit to be tested on its own.
2018-07-27 10:14:43 +02:00
Andrew Nicols
7d05f5813d Merge branch 'MDL-62140_master' of git://github.com/markn86/moodle 2018-04-24 11:16:07 +08:00
Mark Nelson
6d82a42353 MDL-62140 core_privacy: only reset tests when necessary 2018-04-24 10:54:21 +08:00
Andrew Nicols
3bdcd4d8c3 MDL-62140 core_privacy: Improve unit test 2018-04-24 10:18:31 +08:00
Mark Nelson
aa725516d3 MDL-62140 core_privacy: add helper functions to add system/user context 2018-04-23 20:06:02 +08:00
Andrew Nicols
81f1e31a51 MDL-61307 core_privacy: Define and test providers 2018-03-09 10:01:18 +08:00