197 Commits

Author SHA1 Message Date
Ankit Agarwal
0d14fcbc60 MDL-9367 restore: Roll only configuration dates
It was decided to roll only configuration dates and any date related to user content
such as 'timecreated' , 'timemodified' etc should not be rolled forward.
2017-08-01 10:46:37 +05:30
David Monllao
2db6e9811b MDL-59212 analytics: Core indicators tests
Part of MDL-57791 epic.
2017-07-24 08:37:01 +02:00
Marina Glancy
63e9e38202 MDL-58911 calendar: use the same callbacks in unittests and prod
Remove unittest-specific callbacks for checking access and displaying
the calendar events on the dashboard.

This will allow plugin developers unittest the full behavior
of how their plugins add events to the dashboard.

Reset all static caches between unittests.
2017-06-20 16:13:35 +08:00
Dan Poltawski
f98ad251ae Merge branch 'MDL-55139' of git://github.com/stronk7/moodle 2017-03-28 18:33:19 +01:00
Rajesh Taneja
36cc9f8e37
MDL-54628 behat: Set behat dir for each run under behat_dataroot
Before this patch behat_dataroot for parallel runs
were created at same level as ->behat_dataroot
After this patch, it will be created 1 level under
->behat_dataroot with BEHAT_PARALLEL_SITE_NAME
prefix and run number as suffix. This will allow
common files as test enabled and parallel run info
to be saved in parent directory and access it easily.
2017-01-30 08:51:53 +08:00
Jake Dallimore
f6d9efefaa MDL-48498 core_files: curl_security_helper_base and implementation
Base class and core implementation providing a means to check URLs
against the curl security admin settings entries.
2016-11-08 15:11:15 +08:00
David Monllao
90abff01b3 Merge branch 'MDL-54751-master-v5' of https://github.com/snake/moodle 2016-11-07 08:55:44 +08:00
Jake Dallimore
3704ff8cde MDL-54751 phpunit: Support adhoc module and section deletion in phpunit
Created a new phpunit util function run_all_adhoc_tasks which runs any
pending tasks, for use in unit tests. Added new recyclebin and course
unit tests covering the new functionality.
2016-11-07 07:41:59 +08:00
Marina Glancy
fab11235d8 MDL-38158 core_media: Convert media players to new plugin type
AMOS BEGIN
  MOV [siteyoutube,core_media],[pluginname,media_youtube]
  MOV [siteyoutube_desc,core_media],[pluginname_help,media_youtube]
  MOV [sitevimeo,core_media],[pluginname,media_vimeo]
  MOV [sitevimeo_desc,core_media],[pluginname_help,media_vimeo]
  MOV [html5audio,core_media],[pluginname,media_html5audio]
  MOV [html5audio_desc,core_media],[pluginname_help,media_html5audio]
  MOV [html5video,core_media],[pluginname,media_html5video]
  MOV [html5video_desc,core_media],[pluginname_help,media_html5video]
  MOV [flashanimation,core_media],[pluginname,media_swf]
  MOV [flashanimation_desc,core_media],[pluginname_help,media_swf]
AMOS END
2016-11-04 17:30:40 +08:00
Russell Smith
ef15173794 MDL-56354 unittests: Put debug messages in the failure notice. 2016-10-26 08:39:10 +11:00
Eloy Lafuente (stronk7)
9123439e06 MDL-55139 unit tests: Make code-coverage for components way better
By specifying the filter on all those partial phpunit.xml files
we are restricting in a 99% the effort (time and memory) needed
by phpunit to process xdebug execution coverage, retricting it
to the target files within a component.
2016-10-07 00:41:22 +02:00
Rajesh Taneja
544de35bc3
MDL-55379 phpunit: Preserve config option if passed 2016-09-22 10:45:47 +08:00
Eloy Lafuente (stronk7)
0f4b338fbb Merge branch 'wip-mdl-55379' of https://github.com/rajeshtaneja/moodle 2016-09-20 02:06:32 +02:00
Russell Smith
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
Rajesh Taneja
1b319d3d3b
MDL-55379 phpunit: Fix dir separator for cli commands 2016-09-12 09:48:40 +08:00
Rajesh Taneja
a7f202de4e
MDL-55379 phpunit: Fixed hint_result for rerun 2016-09-12 09:48:39 +08:00
Tim Hunt
972a367b98 MDL-55741 phpunit: does not reset get_log_manager cache 2016-08-26 17:14:17 +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
Rajesh Taneja
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
Simey Lameze
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
David Monllao
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
sam marshall
6bd871d3dd MDL-52981 Unit tests: Reset global after test 2016-02-03 10:25:27 +00:00
David Monllao
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
Rajesh Taneja
faea241337 MDL-52656 unittest: Reset original session while setting user 2016-01-08 09:41:28 +10:00
Mark Nielsen
e61a9638f1 MDL-52060 phpunit: Improve get_message_processors reset 2015-12-22 13:40:39 +08:00
Marina Glancy
1766e6a17f MDL-52284 core: PHP7 engine errors have type Throwable 2015-12-10 10:49:37 +08:00
Tony Levi
d74b7e424f MDL-52284 core: compatibility with Exception/Throwable changes in PHP7 2015-12-10 10:49:36 +08:00
David Monllao
53f8e45279 Merge branch 'MDL-50687-master' of git://github.com/danpoltawski/moodle 2015-11-16 14:25:48 +08:00
Dan Poltawski
9680529069 MDL-50687 phpunit: error early if required locale not installed 2015-11-13 07:00:09 +00:00
Rajesh Taneja
81676e84e6 MDL-52077 unittest: Fixed string typo 2015-11-10 13:53:47 +08:00
David Mudrák
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
rajesh Taneja
5ecf8e8f21 MDL-51266 unittest: replaced low level phpunit_util calls 2015-09-23 15:42:48 +08:00
Andrew Nicols
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
Eloy Lafuente (stronk7)
839b8c3905 Merge branch 'MDL-47449-master' of git://github.com/andrewnicols/moodle 2015-08-19 18:30:33 +02:00
sam marshall
89a73b0815 MDL-51077 Availability: Date restriction unit test static not cleared 2015-08-14 10:51:29 +01:00
Andrew Nicols
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
David Monllao
ede96605ac Merge branch 'MDL-51053-master' of git://github.com/sammarshallou/moodle 2015-08-12 08:23:29 +08:00
sam marshall
27479b5cc9 MDL-51053 Restore: Static cache breaks unit tests 2015-08-11 14:07:38 +01:00
Rajesh Taneja
b9432e1a7d MDL-50926 phpunit: Advanced testcase should extend base_testcase 2015-08-11 02:37:28 +02:00
Tony Levi
b80b35d0fc MDL-50926 phpunit: Upgrade to phpunit 4.x 2015-08-11 02:35:11 +02:00
Petr Skoda
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
sam marshall
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
Andrew Nicols
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
Sam Hemelryk
d6abe6f744 Merge branch 'MDL-48194-master' of git://github.com/andrewnicols/moodle 2014-11-17 13:39:03 +13:00
Andrew Nicols
14ecbb2ee8 MDL-48196 phpunit: Set e-mail address for admin user at installation 2014-11-13 08:47:43 +08:00
Andrew Nicols
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
Petr Skoda
ddffa9d6d3 MDL-47538 phpunit: fix invalid PHPUNIT_SEQUENCE_START constant 2014-10-06 17:31:15 +13:00
Russell Smith
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
Russell Smith
529495f7ce MDL-46193 phpunit: Use random starting value on initialization. 2014-07-04 16:33:13 +10:00
Petr Skoda
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