| 7 file.test | FileURLRewritingTest::testShippedFileURL() |
| 8 file.test | FileURLRewritingTest::testShippedFileURL() |
Test the generating of rewritten shipped file URLs.
File
- modules/
simpletest/ tests/ file.test, line 2492 - This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.
Code
function testShippedFileURL() {
// Test generating an URL to a shipped file (i.e. a file that is part of
// Drupal core, a module or a theme, for example a JavaScript file).
// Test alteration of file URLs to use a CDN.
variable_set('file_test_hook_file_url_alter', 'cdn');
$filepath = 'misc/jquery.js';
$url = file_create_url($filepath);
$this->assertEqual(FILE_URL_TEST_CDN_1 . '/' . $filepath, $url, t('Correctly generated a CDN URL for a shipped file.'));
$filepath = 'misc/favicon.ico';
$url = file_create_url($filepath);
$this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $filepath, $url, t('Correctly generated a CDN URL for a shipped file.'));
// Test alteration of file URLs to use root-relative URLs.
variable_set('file_test_hook_file_url_alter', 'root-relative');
$filepath = 'misc/jquery.js';
$url = file_create_url($filepath);
$this->assertEqual(base_path() . '/' . $filepath, $url, t('Correctly generated a root-relative URL for a shipped file.'));
$filepath = 'misc/favicon.ico';
$url = file_create_url($filepath);
$this->assertEqual(base_path() . '/' . $filepath, $url, t('Correctly generated a root-relative URL for a shipped file.'));
// Test alteration of file URLs to use protocol-relative URLs.
variable_set('file_test_hook_file_url_alter', 'protocol-relative');
$filepath = 'misc/jquery.js';
$url = file_create_url($filepath);
$this->assertEqual('/' . base_path() . '/' . $filepath, $url, t('Correctly generated a protocol-relative URL for a shipped file.'));
$filepath = 'misc/favicon.ico';
$url = file_create_url($filepath);
$this->assertEqual('/' . base_path() . '/' . $filepath, $url, t('Correctly generated a protocol-relative URL for a shipped file.'));
}
Login or register to post comments