Commit graph

412 commits

Author SHA1 Message Date
tjhunt
82701e2443 switch roles: MDL-18132 separate database table role_allow_switch instead of re-using role_allow_assign.
This is part 1 that does the back-end:

1. New table role_allow_switch.
2. Upgrade that copies all the allows from role_allow_assign, and then drops the old CFG->allowuserswitchrolestheycantassign.
3. Old function get_assignable_roles_for_switchrole renamed to get_switchable_roles and changed to use the new table. Fixes MDL-18604 in HEAD.
4. Switch callers to use the new function name.
5. Unit tests for this new function.
6. To make those unit tests work, new switch_global_user_id and revert_global_user_id methods in UnitTestCaseUsingDatabase for toggling $USER->id.

I still need to do the editing interface under Administration ► Users ► Permissions ► Define roles. That will be done as a second commit.
2009-03-23 08:15:21 +00:00
tjhunt
b695b4e16c Make accesslib unit tests work once again using the new UnitTestCaseUsingDatabase 2009-03-23 04:18:44 +00:00
tjhunt
f68cb08bbe unit tests: MDL-18607 new way to do unit tests involving the database.
This is not as ambitious as the abortive FakeDBUnitTests scheme, but this one works for simple cases.

There is a new test case class UnitTestCaseUsingDatabase to inherit from. I hope it is sufficiently well documented in its PHPdocs.
* It users $CFG->unittestprefix.
* You can access that database using $this->testdb.
* That database is empty by default, you have to call create_test_table to create the ones you want, and drop_test_table to clean them up in the end. The table definitions are read from the XMLDB file.
* When you are ready to call real Moodle code that users $DB, call switch_to_test_db and then revert_to_real_db when you are done.
* If you forget to call drop_test_table or switch_to_test_db, the class will attempt to clean up after you, but will also print rude developer debug messages telling you not to be stupid.
* There is also a load_test_data method for populating a table from an array.

The is an example of its use in lib/simpletest/testunittestusingdb.php.
2009-03-23 04:12:37 +00:00
tjhunt
4e42a90c53 weblib: Fix test_format_text_email and unit tests. 2009-03-23 03:41:34 +00:00
tjhunt
48f7eb9868 ajaxlib: fix unit tests. 2009-03-10 08:01:57 +00:00
tjhunt
af52eceef4 qtype admin: MDL-18425 also related to MDL-18355.
Allow question types  to be displayed in order that is better than random or alphabetical. Since we don't know all the qtypes there may be:
1. Store the order in the DB (config plugins).
2. Set up a good default order for the standard types. (Unknown types go at the end by default.)
3. Allow admins to edit the order on the qtype admin screen.
2009-03-03 07:47:32 +00:00
nicolasconnault
ec0123208d MDL-18188 Added a new function with matching unit tests, following Sam's comment in the tracker 2009-02-10 15:33:25 +00:00
skodak
760ab567d0 MDL-16483 - partial unbreaking of eventlsib test 2009-01-10 13:54:11 +00:00
skodak
58fa5d6f75 MDL-16483 - renamed MoodleUnitTestCase to FakeDBUnitTestCase; MDL-17841 removed bogus remove lib/simpletest/slowcodetest.php 2009-01-10 13:47:26 +00:00
skodak
cc4245a3cd MDL-16483 - stopped using MoodleUnitTestCase in tests where $DB not needed 2009-01-10 13:23:37 +00:00
skodak
e70da470a7 MDL-14123 Full IPv6 support - reimplemented address_in_subnet() + added more unittests 2009-01-09 21:16:26 +00:00
skodak
65de686486 MDL-14123 cleanremoteaddr improvements and added unit tests 2009-01-09 10:16:07 +00:00
skodak
542797b4e8 MDL-17767 loginas internals refactoring - code moved to sessionlib.php 2009-01-02 14:53:02 +00:00
skodak
d1aa1e4855 MDL-17758 fixed hardcoded /admin/ links 2009-01-01 14:25:29 +00:00
sam_marshall
82bd6a5ea9 MDL-15499: Conditional availability of activities 2008-12-17 16:37:35 +00:00
tjhunt
212235d3e2 accesslib: MDL-17647, MDL-17648 and MDL-17649 Bug fix, improvement and unit test.
MDL-17647 was referring to moodle/site:candoanything insstead of moodle/site:doanything

MDL-17648 Let get_users_by_capability take an array of capabilities, like has_any_capability

MDL-17649 get_users_by_capability must have unit tests (HEAD only).

The unit tests were briefly working (apart from the system context, which I had to set up by hand in the test contexts table). Then I made the mistake of trying to upgrade the test tables, and it all went horribly wrong (MDL-17644).
2008-12-15 06:22:18 +00:00
tjhunt
b1bc126319 unit tests: MDL-17646 Arrgh! edited the wrong file after making testsimpletestlib.php by copying testaccesslib.php! 2008-12-15 03:08:22 +00:00
tjhunt
821e4ecf16 unit tests: MDL-17646 Helper functions for loading and cleaning up test data. 2008-12-15 02:39:55 +00:00
tjhunt
9289e4c90e weblib: MDL-17606 Make the highlight function better, with unit tests. 2008-12-11 10:33:57 +00:00
sam_marshall
002f56ef79 MDL-17412: Completion system unit tests were broken 2008-11-26 13:59:24 +00:00
nicolasconnault
dbc0194458 MDL_13766 Refactoring of core repository code and added first unit tests 2008-11-26 07:03:10 +00:00
skodak
beaa43db85 MDL-17036 dml: dbpersist moved into dboptions 2008-10-27 22:21:34 +00:00
tjhunt
6ff2be37f5 moodlelib iprange checks: MDL-16986 If the user makes a mistake and types something like 172.16.1.143/148, with something greater than 32 after the slash, treat it as /32. 2008-10-24 02:53:51 +00:00
mjollnir_
51122d6c67 MDL-16587 & MDL-15666: portfolio unit test framework expanded to do 3d rather than 2d testing (caller + plugin + new: exportformat) 2008-10-13 10:20:05 +00:00
jamiesensei
8b92c1e3f6 MDL-16529 "Only include closed attempts in manual grade counts" 2008-09-23 09:52:55 +00:00
nicolasconnault
274e2947a2 MDL-16486 Only using one test $DB connection. Completed most of the implementation. Tests working well now. 2008-09-22 07:06:08 +00:00
nicolasconnault
c7d306e168 MDL-15666 MDL-16486 2008-09-17 14:31:30 +00:00
nicolasconnault
356e001031 MDL-16483 minor fixes 2008-09-16 16:40:15 +00:00
nicolasconnault
b9c639d6c2 MDL-16483 Refactored install/upgrade code into lib/adminlib. Created an intermediate MoodleUnitTestCase class that overrides simpletest's constructor, destructor and setup/teardown methods. All moodle unit tests must extend this class. 2008-09-16 12:19:43 +00:00
mjollnir_
932e78b53b MDL-15666 - fake writting files in test portfolio exporter so that we can test integration between callers and plugins 2008-09-15 16:10:55 +00:00
nicolasconnault
3cc60460e8 MDL-15666 Subclassing exporter class so that only local files are written 2008-09-15 13:45:14 +00:00
nicolasconnault
795ad63034 MDL-15666 Testing a matrix of portfolio caller/plugin. Starting the new cleanup method in unit tests (max id) 2008-09-15 13:18:44 +00:00
mjollnir_
27dda89ffe MDL-15666 - changes to the portfolio caller tests
now that i changed the api again (adding load_data), rather than add a call to it to
all the callers, i abstracted the caller setup into the parent class (portfoliolib_test)
2008-09-11 13:47:40 +00:00
nicolasconnault
ef6f0f603d MDL-15666 new unit test for new button class 2008-09-10 17:08:14 +00:00
nicolasconnault
2341547ccc MDL-15666 Fixed some fatal errors in database generation 2008-09-09 10:17:48 +00:00
nicolasconnault
6b98209524 MDL-15666 Unit tests can all be run from lib/simpletest/testportfoliolib.php. See requires at the end of the file. 2008-09-06 14:36:45 +00:00
nicolasconnault
6511446349 MDL-15666 Fixed error that caused blank page in unit test. Including generator library. Partly fixed generator. 2008-09-06 11:24:57 +00:00
nicolasconnault
7399a49d44 MDL-14081 fixed error in eventslib unit tests 2008-09-06 11:22:30 +00:00
nicolasconnault
77ac22a5b6 MDL-15666 sha1 tests for glossary callers. Entry caller test currently fails. 2008-09-04 11:44:48 +00:00
skodak
8aff848213 MDL-14589 minor database driver loading refactoring 2008-09-02 20:32:03 +00:00
tjhunt
1cc6b5162c MDL-15655 - address_in_subnet does not work on 64 bit architectures. Also, we found some other issues with this funtion while diagnosing the problem. 2008-09-01 04:17:11 +00:00
nicolasconnault
75d226d74d MDL-15666 Generating test data on-the-fly using the generator! 2008-08-29 14:46:55 +00:00
nicolasconnault
7e95408b01 MDL-15666 MDL-16177
Refactored the generator script into proper Object Oriented code. It can now be used as a CLI tool, as a web form or as an included library with a function call. Stub implementation is demonstrated in portfolio unit tests.
2008-08-29 08:01:55 +00:00
mjollnir_
cc8696b2ef MDL-15666 - fixed up the dup test and changed setup to mock the user 2008-08-19 16:14:17 +00:00
nicolasconnault
29de31324e MDL-15666 Tests for creating duplicate instance of plugin that doesn't allow duplicates 2008-08-19 15:34:05 +00:00
nicolasconnault
d50475e64f MDL-15666 Adding test file with stub methods. 2008-08-19 09:21:30 +00:00
nicolasconnault
ea549328d0 MDL-15666 Adding test file with stub methods. 2008-08-19 07:14:03 +00:00
skodak
bed7993115 MDL-15897 deprecated PARAM_CLEANFILE - we now support unicode everywhere 2008-07-31 23:03:50 +00:00
sam_marshall
49f6e5f476 MDL-15498: Fixes to problems Petr identified with completion system checkin 2008-07-28 15:58:50 +00:00
sam_marshall
4e781c7b50 MDL-15498: Completion system 2008-07-28 12:31:29 +00:00