156 Commits

Author SHA1 Message Date
Eloy Lafuente (stronk7)
29a541724f
MDL-65292 style: Fix all the function declaration ordering
This has been generated running the following Sniff,
part of the Moodle's CodeSniffer standard:
- PSR2.Methods.MethodDeclaration

It just ensures all the function declarations have
the correct order for:
- abstract and final.
- visibility (public, protected, private).
- static.

So, all the lines modified by this commit are function declarations
and the only changes are in the positions of those keywords.
2024-02-28 23:47:47 +01:00
Ilya Tregubov
94a13aeeff
MDL-79364 backup: Fix conversion for 1.9 backups.
1.9 backups used current plugin version as oldversion.
But quiz uses some hardcoded version numbers when processing
restore which is lower then current plugin number, so some quiz
logic was ignored.

See define_structure(), process_quiz_question_instance() within
restore_quiz_stepslib.php
2023-10-02 15:26:50 +08:00
Eloy Lafuente (stronk7)
9f53b0e965 MDL-73971 phpunit: Move more tests to use correct names and namespaces
Applied the following changes to various testcase classes:

- Namespaced with component[\level2-API]
- Moved to level2-API subdirectory when required.
- Fixed incorrect use statements with leading backslash.
- Remove file phpdoc block
- Remove MOODLE_INTERNAL if not needed.
- Changed code to point to global scope when needed.
- Fix some relative paths and comments here and there.
- All them passing individually.
- Complete runs passing too.

Special mention to:

- Some fixtures, initially defined in the test files have been
  moved to new files in fixtures subdirectory, leaving the unit
  test files clearer:
  - moodle2_course_format_test.php
- Rename wrong named test:
  - baseoptiogroup_test = baseoptigroup_test
2022-05-06 18:29:11 +02:00
Sara Arjona
3f2f2e85bb MDL-72115 course: Rename Miscellaneous category
The "Miscellaneous" course category has been renamed to Category 1.
Besides, the description field has been set from FORMAT_MOODLE to
FORMAT_HTML.
2021-09-13 08:36:17 +02:00
Eloy Lafuente (stronk7)
d95c378771 MDL-67673 phpunit: Remove expectedException annotations
While this is not strictly required, because removal will
happen in PHPUnit 9.0, we are already getting rid of all
uses in core.

From release notes:https://phpunit.de/announcements/phpunit-8.html

The annotations `@expectedException`, `@expectedExceptionCode`,
`@expectedExceptionMessage`, and `@expectedExceptionMessageRegExp`
are now deprecated.
Using these annotations will trigger a deprecation warning
in PHPUnit 8 and in PHPUnit 9 these annotations will be removed.

Also, all uses of expectExceptionMessageRegExp() has been moved
to expectExceptionMessageMatches(). See https://github.com/sebastianbergmann/phpunit/issues/3957

TODO: Various weirdness found while doing the changes with these tests:
- vendor/bin/phpunit lib/tests/exporter_test.php (created MDL-69700)
- vendor/bin/phpunit competency/tests/external_test.php (same issue than prev one)
- vendor/bin/phpunit question/engine/tests/questionengine_test.php (created MDL-69624)
- vendor/bin/phpunit lib/tests/event_test.php (created MDL-69688)
2020-10-21 12:46:00 +02:00
Eloy Lafuente (stronk7)
f6711bb394 MDL-67673 phpunit: Fix the return type of template methods
All the setup/teardown/pre/post/conditions template methods
now are required to return void. This was warned with phpunit 7
and now is enforced.

At the same time, fix a few wrong function names,
provider data and param types, return statements...
2020-10-21 12:45:59 +02:00
Michael Spall
f1a22c4a1b MDL-64290 backup imscc: Use correct tempdir for imscc restore
Use configured temp directory $CFG->tempdir instead of hard coded
$CFG->dataroot . '/temp/backup/'
Remove unused variable, $CFG
2018-12-05 10:44:14 -07:00
Shamim Rezaie
f181a24a0b MDL-62251 backup: Fix replace_tempdir() bug under Windows
rename() fails under Windows if the destination file/directory exists.
I modified the code to only call $this->get_workdir_path() once as that function
creates the directory if doesn't exist. And we don't want that considering the
behaviour of rename on Windows.
2018-05-10 18:16:09 +10:00
Matteo Scaramuccia
ef844148a9 MDL-60923 backup: Added $CFG->backuptempdir
The new setting will allow to host the temporary backup files
into a specific target directory. Defaults to '$CFG->tempdir/backup'.

Calling make_backup_temp_directory() checks that the required sub-directory
will be properly created under the new target directory.
2018-04-16 23:50:28 +02:00
Andrew Nicols
e6a4780452 MDL-58297 core: Update to use new hashing functions 2017-04-07 10:40:23 +08: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
Russell Smith
1fcf0ca8a5 MDL-35628 performance: Remove dirname() where possible.
dirname() is a slow function compared with __DIR__ and using
'/../'.  Moodle has a large number of legacy files that are included
each time a page loads and is not able to use an autoloader as it is
functional code.  This allows those required includes to perform as
best as possible in this situation.
2016-06-10 08:06:49 +10:00
Rajesh Taneja
0fe86bbdbb MDL-49799 behat: replaced asd.com with example.com
asd.com is a valid domain, we should use reserved domain names for testing
2015-04-20 11:21:20 +08:00
Mark Nielsen
292f663581 MDL-47569 backup: Do not close questions tag if never opened
This can happen when restoring quizzes that
do not have any questions.
2014-10-07 11:48:35 -07:00
Marina Glancy
b76ae3b0ce Merge branch 'MDL-44630_CC_Changes' of git://github.com/moodlerooms/moodle 2014-05-08 12:05:20 +08:00
Mark Nielsen
e686494fbc MDL-44630: Fixing PHP foreach warnings 2014-05-07 12:39:47 -07:00
sam marshall
38674ef91a MDL-44070 Conditional availability enhancements (4): backup
Implements backup and restore for the new conditional availability
data. This includes:

* Backup and restore of new field.
* Restore updates IDs in conditions, as required.
* Restore converts availability data from legacy (Moodle 2.6) backups.
* Unit tests for all this.
2014-04-07 20:11:41 +01:00
Mark Nielsen
cb4b7e55a0 MDL-44630: Review changes
* Fixing coding style violations.
* Fixing DOMDocument warning.
2014-04-03 10:10:10 -07:00
Mark Nielsen
c3d245cff3 MDL-44630: Several additions to Common Cartridge Import/Export
Changes provided by Darko Miletic and Sam Chaffee.

* Fix problem with CC import not detecting a CC package. (Sam)
* Fixed Common Cartridge not importing FIB answers. (Sam)
* Fix to CC export so that short answer pattern matching question
  in a quiz does not prevent the entire quiz from exporting. (Sam)
* Fix notice about missing index when there is no answer-specific
  feedback in short answer question during CC export. (Sam)
* Fixed Japanese characters being incorrectly encoded (garbled)
  on Common Cartridge import. (Sam)
* Changed import of CC discussions to create 'Standard General'
  forums in Moodle. (Sam)
* Fix problem with question name being replaced with question
  text on CC import of exported Moodle questions. (Sam)
* Fix CC 1.1 multiple choice question import having no correct
  answers. (Sam)
* Fixed problem with multiple choice, multiple answers allowed
  questions not exporting correct answers to CC. (Sam)
* Removed duplicate method. (Darko)
* Implemented fix that skips quiz export if it contains
  non-exportable question. (Darko)
* Fixed: Common cartridge export is extremely slow when dealing
  with lot of more than 200 files. (Darko)
* Added support for basic roles support in common cartridge. (Darko)
* Implemented folder resource export. (Darko)
* Minor fixes to adjust to the standard. (Darko)
* Added support for exporting simple fill in the blank
  (shortanswer without wildcards in Moodle). (Darko)
* Added support for exporting essay question. (Darko)
* Added support for true/false export. (Darko)
* Added support for exporting multiple response questions,
  added also category information into question metadata
  during export (Darko)
* Added support for correctly importing multiple response
  questions. (Darko)
2014-03-13 15:42:13 -07:00
Tim Hunt
dc4a3ea1ee MDL-43670 quiz_question_instances to match coding guidelines.
Some columns needed to be renamed:
* quiz     -> quizid
* question -> questionid
* grade    -> maxmark

Then all the places that refer to those needed to be fixed.
2014-01-17 10:56:07 +00:00
Eloy Lafuente (stronk7)
25e02ab6ee Merge branch 'MDL-41660-imscc-tempdir' of https://github.com/mpetrowi/moodle 2013-09-25 02:14:57 +02:00
Petr Škoda
bde002b81a MDL-41437 rework plugin_manager caching and version info in blocks and modules
This patch includes:

* version column removed from modules table, now using standard config, this allows decimal version for modules
* version column removed from block table, now using standard config, this allows decimal version for blocks
* module version.php can safely use $plugins instead of module
* new plugin_manager bulk caching, this should help with MUC performance when logged in as admin
* all missing plugins are now in plugin overview (previously only blocks and modules)
* simplified code and improved coding style
* reworked plugin_manager unit tests - now using real plugins instead of mocks
* unit tests now fail if any plugin does not contain proper version.php file
* allow uninstall of deleted filters
2013-09-22 21:25:26 +02:00
Matt Petro
d871a0df65 MDL-41660 backup ims-cc: Use correct temp directory 2013-09-08 17:28:33 -04:00
Petr Škoda
2f1e464a88 MDL-40438 migrate all collatorlib:: and textlib:: uses 2013-08-06 21:04:35 +02:00
Petr Škoda
8252b7c291 MDL-40901 standardise core test case class and file names
This finally allows us to type only the class name when executing individual core test cases.
2013-08-04 22:10:31 +02:00
Petr Škoda
eb459f7192 MDL-40642 set more restrictive umask and use proper permission for new dirs and files 2013-07-19 09:18:44 +02:00
Petr Škoda
bd3b3bba9f MDL-40220 use new core_component::get_plugin_list() 2013-07-16 22:36:11 +02:00
Jean-Michel Vedrine
3f28674535 MDL-33424 Images missing when restoring a 1.9 backup 2013-03-09 13:51:34 +01:00
David Mudrák
d0530ed444 MDL-37774 Make moodle1_file_manager::migrate_directory() support trailing slash in rootpath
As the $rootpath is concatenated with the $relpath, we would end with a
path like course_files//file.txt. Such a path is detected as not-valid
later and an error would be thrown.

So the patch makes sure that the trailing slash is cut off and a
debugging for the developer is displayed.
2013-02-08 11:45:24 +01:00
David Mudrák
86083f9752 MDL-37774 Add unit test to illustrate the problem with the trailing slash
The patch introduces two new tests for moodle1_file_manager::migrate_directory().
The second test with the trailing slash reveals the trouble here.
The expected behaviour is that the method would deal with the trailing
slash. Debugging message for the developer should be displayed though.
2013-02-08 11:41:38 +01:00
Petr Škoda
a629ad3dff MDL-37780 fix 1.9 restore on windows 2013-01-30 20:28:06 +01:00
David Mudrák
0ab681d3e7 MDL-36977 Be more picky when it comes to migrating files in moodle1 backups 2013-01-08 08:53:38 +08:00
David Mudrák
7b66137f7b MDL-36977 Add more unit tests for moodle1 backup conversion 2013-01-08 08:53:37 +08:00
Eloy Lafuente (stronk7)
12e13ce047 Merge branch 'MDL-32880_master_3' of git://github.com/pauln/moodle 2012-12-11 22:48:06 +01:00
David Mudrák
2c9689ed21 MDL-36204 Improve moodle1 conversion of embedded files
URL of files referenced in HTML fields via $@FILEPHP$@ are usually
encoded if they were linked using the HTML editor. So if they contain
spaces or plus signs in the name, their URL is encoded to use %20 and
%2B respectively.

Sometimes, for example when the HTML was edited manually in 1.9 without
the editor, non-encoded file names may be put into the HTML text. Such a
link used to work in 1.9 so we add an explicit support for it, too.

However, we do not support partially encoded URLs (e.g. only spaces are
encoded while plus signs are not). Such links are unmodified and will
rely on Legacy files support.
2012-11-23 03:39:17 +01:00
Paul Nicholls
a374ba237c MDL-32880: moodle1 backup converter: add generic block handler
This handler will automatically be used for any block which does not provide its own handler, and should be subclassed by any block which needs to do anything extra (or different).

This commit incorporates contributions from Mike Churchward and API design suggestions from David Mudrak.
2012-11-23 09:28:50 +13:00
Paul Nicholls
36ab8f6cb6 MDL-36204: moodle1 backup converter: add unit test to cover this issue 2012-11-15 10:50:16 +13:00
Paul Nicholls
bdc468f9a6 MDL-36204: moodle1 backup converter: urldecode filenames from links
If filenames are not run through urldecode(), those that contain spaces (or other url-encoded characters) will not be handled, as they can't be found in the backup file.
2012-11-15 09:26:55 +13:00
Ankit Agarwal
556e9404cc MDL-34471 backup: Update the php doc block 2012-08-08 17:11:02 +08:00
Adrian Greeve
a689cd1def MDL-34469 - lib - replacement of the deprecated get_context_instance and get_context_by_id functions (group 15) 2012-07-30 14:59:57 +08:00
Aaron Barnes
1d09e12936 MDL-32016 unit tests: Remove hard coded file hash and calculate dynamically 2012-05-16 11:55:39 +12: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
bb7898c6ab MDL-32569 convert remaining backup tests and drop old simpletests 2012-04-21 16:24:33 +02:00
Petr Skoda
4b02743182 MDL-32149 improve testcase naming and list in config file 2012-04-03 22:30:57 +02:00
Petr Skoda
1cbf2a20ca MDL-32149 setUp() and tearDown() are supposed to be 'protected', add missing blog testcase 2012-04-03 22:30:56 +02:00
Petr Skoda
dbf5a44798 MDL-32149 add backup tests and dropping of extra tables 2012-04-03 22:30:54 +02:00
Eloy Lafuente (stronk7)
c9d1f4338b MDL-32251 Two more E_STRICT detected on tests execution 2012-04-03 21:59:25 +02:00
Petr Skoda
caee6e6c26 MDL-32251 E_STRICT fixes part 3 2012-03-29 15:24:30 +02:00
Eloy Lafuente (stronk7)
2ed7cc2730 Merge branch 'w10_MDL-31301_m23_textlibcleanup' of git://github.com/skodak/moodle 2012-03-06 16:06:53 +01:00
Petr Skoda
f8311defeb MDL-31301 use static textlib methods 2012-03-03 11:46:13 +01:00