. /** * Unit tests for setuplib.php * * @package core_phpunit * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * Unit tests for setuplib.php * * @copyright 2012 The Open University * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class core_setuplib_testcase extends basic_testcase { /** * Test get_docs_url_standard in the normal case when we should link to Moodle docs. */ public function test_get_docs_url_standard() { global $CFG; if (empty($CFG->docroot)) { $docroot = 'http://docs.moodle.org/'; } else { $docroot = $CFG->docroot; } $this->assertRegExp('~^' . preg_quote($docroot, '') . '/2\d/' . current_language() . '/course/editing$~', get_docs_url('course/editing')); } /** * Test get_docs_url_standard in the special case of an absolute HTTP URL. */ public function test_get_docs_url_http() { $url = 'http://moodle.org/'; $this->assertEquals($url, get_docs_url($url)); } /** * Test get_docs_url_standard in the special case of an absolute HTTPS URL. */ public function test_get_docs_url_https() { $url = 'https://moodle.org/'; $this->assertEquals($url, get_docs_url($url)); } /** * Test get_docs_url_standard in the special case of a link relative to wwwroot. */ public function test_get_docs_url_wwwroot() { global $CFG; $this->assertEquals($CFG->wwwroot . '/lib/tests/setuplib_test.php', get_docs_url('%%WWWROOT%%/lib/tests/setuplib_test.php')); } }