NOTE: In order to do this test you will need to 'disable zlib' or 'disable zlib for admin settings'. There are two ways to do this:
a. Actually disable the zlib extension in your PHP settings.
b. Fake it by hacking code.
As the zlib extension is often compiled into code and can't be disabled, you may find the second approach easier. Here is how to fake it:
Fake 'disable zlib': edit lib/filestorage/tgz_packer.php, find the line that says 'extension_loaded('zlib')' and change the word 'zlib' to 'zlibfrog'.
Fake 'disable zlib for admin settings': edit admin/settings/development.php, change 'zlib' to 'zlibfrog' only in one instance in the last parameter of the call to admin_settings_php_extension_enabled constructor, currently on line 32.
1. With zlib enabled, run the two unit tests affected by this change:
vendor/bin/phpunit lib/filestorage/tests/tgz_packer_test.php
|
vendor/bin/phpunit lib/filestorage/tests/mbz_packer_test.php
|
EXPECTED: These unit tests pass in both cases with no skipped tests.
2. Disable zlib and rerun the two unit tests as above.
EXPECTED: The unit tests pass but all but one test in the first, and all test(s) in the second, are marked as skipped.
3. Enable zlib.
4. Look at admin settings Development / Experimental / Experimental settings.
EXPECTED: The 'enabletgzbackups' option is present (as before). There is no 'zlib enabled' option.
5. Disable zlib for admin settings, and reload the page.
EXPECTED: Below the enabletgzbackups option is a new 'zlib enabled' informational display with text telling you that the new backup format will be disabled if you don't install zlib.
6. Enable zlib for admin settings. Reload the page, then turn on the enabletgzbackups option and save changes.
7. Go to any small course page. Choose the backup option and proceed through the process using default settings. The backup file should be created.
8. Disable zlib.
9. Repeat the backup process.
EXPECTED: There should be no error and the backup file should be created. However you will probably notice that the file is a slightly different size, because it's now using the default zip compression as zlib is not available.
10. With zlib still disabled, restore the second backup file (the zip format one) to a new course using all default settings.
EXPECTED: This should complete successfully.
11. Return to the original course and this time, try to restore the first backup file (the gz format one).
EXPECTED: You don't even get to the first screen of backup but get an error 'The selected file is in the new backup format and cannot be restored because the zlib PHP extension is not available on this system.'
12. Enable zlib.
13. Repeat the attempt to restore the gz format backup (to a new course using default settings).
EXPECTED: This should complete successfully.