Commit Graph

136 Commits

Author SHA1 Message Date
544de35bc3 MDL-55379 phpunit: Preserve config option if passed 2016-09-22 10:45:47 +08:00
0f4b338fbb Merge branch 'wip-mdl-55379' of https://github.com/rajeshtaneja/moodle 2016-09-20 02:06:32 +02:00
74ee9d29d2 MDL-55944 testing: Reduce sleep usage.
Remove sleep() and replace with waiting for a second to roll over,
this results in a simpler call the guarantee time() has moved forward
2016-09-14 09:49:30 +10:00
1b319d3d3b MDL-55379 phpunit: Fix dir separator for cli commands 2016-09-12 09:48:40 +08:00
a7f202de4e MDL-55379 phpunit: Fixed hint_result for rerun 2016-09-12 09:48:39 +08:00
972a367b98 MDL-55741 phpunit: does not reset get_log_manager cache 2016-08-26 17:14:17 +01:00
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
165b70a16a MDL-55091 phpunit: Add support for findNodes, as they are now deprecated
https://github.com/sebastianbergmann/phpunit/issues/1292
2016-07-21 07:08:47 +08:00
dccf9ca308 MDL-50705 core_user: introduce new fill_properties_cache()
Also the get_property_definition() was created to get the property without retrieve the whole definition cache and
    unit tests were created to tests those new methods.
2016-03-10 13:17:08 +01:00
db48207e1a MDL-31989 search: Search API and search engine API
Introducing both APIs in moodle along with:
- search_box widget to add a tiny search box
- admin settings with setup steps helper
- cache for search results
- template for a search result
- php unit stuff

Many thanks to Tomasz Muras, Prateek Sachan and Daniel Neis for their contributions, for starting this development
and for pushing for it to be completed. Also thanks to other contributors: Jonathan Harker and eugeneventer.
2016-02-23 10:47:58 +00:00
6bd871d3dd MDL-52981 Unit tests: Reset global after test 2016-02-03 10:25:27 +00:00
20ff2fba25 MDL-48621 events: Adapting unit tests to debugging messages
- A new assertDebuggingCalledCount has been introduced, as multiple debugging messages
  may be called in some cases, for example when calling events_cron with queued events
  that need to be dispatched.
- events_update_definition has been moved out of setUp as debugging messages are only
  caught by our phpunit custom stuff when they are called inside tests.
2016-01-19 15:19:10 +08:00
faea241337 MDL-52656 unittest: Reset original session while setting user 2016-01-08 09:41:28 +10:00
e61a9638f1 MDL-52060 phpunit: Improve get_message_processors reset 2015-12-22 13:40:39 +08:00
1766e6a17f MDL-52284 core: PHP7 engine errors have type Throwable 2015-12-10 10:49:37 +08:00
d74b7e424f MDL-52284 core: compatibility with Exception/Throwable changes in PHP7 2015-12-10 10:49:36 +08:00
53f8e45279 Merge branch 'MDL-50687-master' of git://github.com/danpoltawski/moodle 2015-11-16 14:25:48 +08:00
9680529069 MDL-50687 phpunit: error early if required locale not installed 2015-11-13 07:00:09 +00:00
81676e84e6 MDL-52077 unittest: Fixed string typo 2015-11-10 13:53:47 +08:00
3bca7dbfa6 MDL-49329 admin: Get rid of mdeploy and \core\update\deployer class
The mdeploy.php standalone script (used to download and unzip plugins
into the dirroot) and the \core\update\deployer class (as a
communication bridge between the core and the mdeploy.php) was
originally designed and implemented with the assumption that it would be
eventually used for updating the Moodle core itself, too. Therefore it
was written as standalone utility without dependency on the Moodle core
libraries.

However, it never happened and there is no real demand for that. So now
there is no need to have and maintain a completely parallel solution for
common things like fetching and unzipping plugin ZIPs.

Additional reasoning for mdeploy.php was that the core is not very
reliable during the core upgrade and we could run into various troubles.
This does not seem to be that bad. We rely on a lot of core
functionality (such as output rendering, DB access etc) and plugins
deployment seems to work well (and better) with common core libraries.

So long mdeploy, and thanks for all the hard work you did for us.
2015-10-08 23:32:04 +02:00
5ecf8e8f21 MDL-51266 unittest: replaced low level phpunit_util calls 2015-09-23 15:42:48 +08:00
4463f996c4 MDL-51236 phpunit: Prevent testsuite name conflicts
The testsuite name is fed straight into a class_exists() in
PHPUnit_Framework_TestSuite. In some cases, e.g. cachestore_static, the
class does exist, it's then fed into a ReflectionClass, and the test fails.

The testsuite needs to not conflict with any classes which could be
autoloaded in Moodle core.
2015-08-28 14:22:07 +08:00
839b8c3905 Merge branch 'MDL-47449-master' of git://github.com/andrewnicols/moodle 2015-08-19 18:30:33 +02:00
89a73b0815 MDL-51077 Availability: Date restriction unit test static not cleared 2015-08-14 10:51:29 +01:00
504c97925c MDL-47449 phpunit: Add comparitor for isEqual with exceptions
We often do isEqual tests but where a field, may have a single exception.
Ordinarily we can handle this easily by breaking the test down, but when
dealing with mocked objects we can only pass an instance of a
PHPUnit_Framework_Constraint, or a single value (which is cast to an
instance of PHPUnit_Framework_Constraint_IsEqual).

To deal with instances of time-based exception, we need to be able to
compare simple objects and classes where one or two values may be
different.
2015-08-14 10:53:19 +08:00
ede96605ac Merge branch 'MDL-51053-master' of git://github.com/sammarshallou/moodle 2015-08-12 08:23:29 +08:00
27479b5cc9 MDL-51053 Restore: Static cache breaks unit tests 2015-08-11 14:07:38 +01:00
b9432e1a7d MDL-50926 phpunit: Advanced testcase should extend base_testcase 2015-08-11 02:37:28 +02:00
b80b35d0fc MDL-50926 phpunit: Upgrade to phpunit 4.x 2015-08-11 02:35:11 +02:00
d6e7a63d9a MDL-49684 timezones: rewrite timezone support
This patch replaces all homegrown timezone
stuff with standard PHP date/time code.

The main change is the introduction of core_date
class that returns normalised user and server
timezones. From now on nobody should be using
$CFG->timezone or $user->timezone directly!

Other new features and fixes:
* admins are prompted for timezone during install
* editing of other users is finally fixed
* timezones are displayed in user profile
* new $this->setTimezone() in phpunit
* time locale is now automatically reset in phpunit
* timezone is now automatically reset in phpunit
* phpunit has Australia/Perth as default timezone
2015-04-06 13:53:51 +12:00
91fed57a4e MDL-42616 filelib: Use config value for custom MIME types (1/2)
Uses a new optional config variable to define custom MIME types
in JSON format. Includes new API for accessing and modifying
this data.
2014-12-19 14:48:59 +00:00
556e3a9e8a MDL-48197 testing: Always set up a mail sink for mail redirection
Rather than setting noemailever in the bootstrap, this sets up a default
phpmailer message sink which will catch all messages.

Tests which require the phpmailer sink will continue to work as before
without change, though the noemailever config setting no longer needs to
be altered.

For tests wanting to test with noemailever set with the previous behaviour,
they will need to load the message sink and then close it.
2014-11-19 09:09:49 +08:00
d6abe6f744 Merge branch 'MDL-48194-master' of git://github.com/andrewnicols/moodle 2014-11-17 13:39:03 +13:00
14ecbb2ee8 MDL-48196 phpunit: Set e-mail address for admin user at installation 2014-11-13 08:47:43 +08:00
a9edd8a671 MDL-48194 testing: Adjust naming of testsuites in phpunit.xml
This will make it easier to run phpunit for a specific component by making
all testsuite names consistent, guessable, and in-line with the naming of
the parameter (testsuite vs. test suite).
2014-11-12 11:46:03 +08:00
ddffa9d6d3 MDL-47538 phpunit: fix invalid PHPUNIT_SEQUENCE_START constant 2014-10-06 17:31:15 +13:00
9462323b13 MDL-46193 phpunit: Replace value in component config.
There are two phpunit.xml build locations, one for overall
and another for individual components.  To reduce id changes
when running different components, we use the same initial ID
in all component files when building.
2014-07-10 09:53:23 +02:00
529495f7ce MDL-46193 phpunit: Use random starting value on initialization. 2014-07-04 16:33:13 +10:00
2e00d01db4 MDL-46099 session: fix use of references for session globals
This reverses the references used for global $USER and $SESSION,
the reason is that PHP does not allow references to references.
$USER is a reference to $GLOBALS['USER'] which means we cannot
put any references to it. Solution is to store the current user and session
objects in $GLOBALS['USER'] and $GLOBALS['SESSIOn'] are reference
them in $_SESSION.

This patch makes the session code behave the same way in CLI,
phpunit and normal web requests - this allows use to finally
unit test most aspects of the session code in Moodle.
2014-07-01 08:38:00 +12:00
6b8e46ad04 MDL-45565 core_message: Reset internal users in phpunit 2014-05-26 15:42:12 +08:00
84f08cfa9d MDL-45606 Unit test fix for MySQL and added a comment about the removed code. 2014-05-20 18:01:32 +08:00
726b011050 MDL-45605 Phpunit: Do not call gc_collect_cycles as part of reset.
This takes 25% of the time in running tests and there is no benefit. The
behaviour of destructors is the same before/after the patch.
2014-05-19 10:37:16 +08:00
a9236a2c3f MDL-45287 fix behat database reset between scenarios
We cannot find out if DB received any writes because behat
web access runs in different request.

This was affecting only scenarios without generators.
2014-04-28 17:02:58 +08:00
08ec831ff8 MDL-44510 fix class guessing in phpunit 4 2014-03-26 11:32:33 +08:00
c386f35bca MDL-44339 treat unexpected debugging() calls in phpunit tests as errors 2014-03-14 11:43:46 +08:00
630bb85d9e MDL-43266 testing: avoid assoc arrays for json
Last commit switched from raw arrays to associative
arrays. That leads to json_encode() to generate an
object instead of an array, ultimately leading to
problems with the rest of code expecting an array.

By using array_values() we are moving back to the
non-associative array.

Also, fix some file permissions.
2014-03-13 22:11:03 +01:00
1700bec3c6 Merge branch 'MDL-43266_master-last-fixes' of git://github.com/dmonllao/moodle
Conflicts:
	lib/phpunit/classes/util.php
2014-03-13 19:12:25 +01:00
770eac9805 MDL-41269 disable all logging during phpunit testing 2014-02-28 14:52:26 +08:00
c78f19d153 MDL-43266 Testing sites are cleaning all test dataroot contents 2014-02-25 14:47:25 +08:00
623a32e50d MDL-43736 Events: Updated unit test to test context not used in event 2014-01-29 11:39:50 +08:00