Commit 9498654c authored by Sam Hemelryk's avatar Sam Hemelryk
Browse files

Merge branch 'MDL-17884_m20' of git://

parents fe1f367a 2d572444
// This file is part of Moodle -
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <>.
* Unit tests for /lib/componentlib.class.php.
* @package moodlecore
* @copyright 2011 Tomasz Muras
* @license GNU GPL v3 or later
if (!defined('MOODLE_INTERNAL')) {
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
class componentlib_test extends UnitTestCase {
public function test_component_installer() {
global $CFG;
$ci = new component_installer('', 'unittest', '');
$destpath = $CFG->dataroot.'/downloadtests';
//carefully remove component files to enforce fresh installation
$this->assertEqual(COMPONENT_NEEDUPDATE, $ci->need_upgrade());
$status = $ci->install();
$this->assertEqual(COMPONENT_INSTALLED, $status);
$this->assertEqual('9e94f74b3efb1ff6cf075dc6b2abf15c', $ci->get_component_md5());
//it's already installed, so Moodle should detect it's up to date
$this->assertEqual(COMPONENT_UPTODATE, $ci->need_upgrade());
$status = $ci->install();
$this->assertEqual(COMPONENT_UPTODATE, $status);
//check if correct files were downloaded
$this->assertEqual('2af180e813dc3f446a9bb7b6af87ce24', md5_file($destpath.'/'.'test.jpg'));
$this->assertEqual('47250a973d1b88d9445f94db4ef2c97a', md5_file($destpath.'/'.'test.html'));
......@@ -79,4 +79,10 @@ class filelib_test extends UnitTestCase {
$postdata = format_postdata_for_curlcall($postdatatoconvert);
$this->assertEqual($postdata, $expectedresult);
public function test_download_file_content() {
$testhtml = "";
$contents = download_file_content($testhtml);
$this->assertEqual('47250a973d1b88d9445f94db4ef2c97a', md5($contents));
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment