Commit 19276d32 authored by webchick's avatar webchick

Issue #1843486 by ACF: Added Change file_test() variables to state system.

parent 9a9a89d1
......@@ -153,14 +153,14 @@ function file_test_reset() {
'move' => array(),
'delete' => array(),
);
variable_set('file_test_results', $results);
state()->set('file_test.results', $results);
// These hooks will return these values, see file_test_set_return().
$return = array(
'validate' => array(),
'download' => NULL,
);
variable_set('file_test_return', $return);
state()->set('file_test.return', $return);
}
/**
......@@ -178,7 +178,7 @@ function file_test_reset() {
* @see file_test_reset()
*/
function file_test_get_calls($op) {
$results = variable_get('file_test_results', array());
$results = state()->get('file_test.results') ?: array();
return $results[$op];
}
......@@ -191,7 +191,7 @@ function file_test_get_calls($op) {
* passed to each call.
*/
function file_test_get_all_calls() {
return variable_get('file_test_results', array());
return state()->get('file_test.results') ?: array();
}
/**
......@@ -207,9 +207,9 @@ function file_test_get_all_calls() {
* @see file_test_reset()
*/
function _file_test_log_call($op, $args) {
$results = variable_get('file_test_results', array());
$results = state()->get('file_test.results') ?: array();
$results[$op][] = $args;
variable_set('file_test_results', $results);
state()->set('file_test.results', $results);
}
/**
......@@ -225,7 +225,7 @@ function _file_test_log_call($op, $args) {
* @see file_test_reset()
*/
function _file_test_get_return($op) {
$return = variable_get('file_test_return', array($op => NULL));
$return = state()->get('file_test.return') ?: array($op => NULL);
return $return[$op];
}
......@@ -241,9 +241,9 @@ function _file_test_get_return($op) {
* @see file_test_reset()
*/
function file_test_set_return($op, $value) {
$return = variable_get('file_test_return', array());
$return = state()->get('file_test.return') ?: array();
$return[$op] = $value;
variable_set('file_test_return', $return);
state()->set('file_test.return', $return);
}
/**
......@@ -315,7 +315,7 @@ function file_test_file_predelete(File $file) {
function file_test_file_url_alter(&$uri) {
// Only run this hook when this variable is set. Otherwise, we'd have to add
// another hidden test module just for this hook.
$alter_mode = variable_get('file_test_hook_file_url_alter', FALSE);
$alter_mode = state()->get('file_test.hook_file_url_alter');
if (!$alter_mode) {
return;
}
......
......@@ -35,7 +35,7 @@ function testShippedFileURL() {
// 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');
state()->set('file_test.hook_file_url_alter', 'cdn');
$filepath = 'core/misc/jquery.js';
$url = file_create_url($filepath);
$this->assertEqual(FILE_URL_TEST_CDN_1 . '/' . $filepath, $url, 'Correctly generated a CDN URL for a shipped file.');
......@@ -44,7 +44,7 @@ function testShippedFileURL() {
$this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $filepath, $url, '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');
state()->set('file_test.hook_file_url_alter', 'root-relative');
$filepath = 'core/misc/jquery.js';
$url = file_create_url($filepath);
$this->assertEqual(base_path() . '/' . $filepath, $url, 'Correctly generated a root-relative URL for a shipped file.');
......@@ -53,7 +53,7 @@ function testShippedFileURL() {
$this->assertEqual(base_path() . '/' . $filepath, $url, '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');
state()->set('file_test.hook_file_url_alter', 'protocol-relative');
$filepath = 'core/misc/jquery.js';
$url = file_create_url($filepath);
$this->assertEqual('/' . base_path() . '/' . $filepath, $url, 'Correctly generated a protocol-relative URL for a shipped file.');
......@@ -69,20 +69,20 @@ function testPublicCreatedFileURL() {
// Test generating an URL to a created file.
// Test alteration of file URLs to use a CDN.
variable_set('file_test_hook_file_url_alter', 'cdn');
state()->set('file_test.hook_file_url_alter', 'cdn');
$uri = $this->createUri();
$url = file_create_url($uri);
$public_directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
$this->assertEqual(FILE_URL_TEST_CDN_2 . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a CDN URL for a created file.');
// Test alteration of file URLs to use root-relative URLs.
variable_set('file_test_hook_file_url_alter', 'root-relative');
state()->set('file_test.hook_file_url_alter', 'root-relative');
$uri = $this->createUri();
$url = file_create_url($uri);
$this->assertEqual(base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a root-relative URL for a created file.');
// Test alteration of file URLs to use a protocol-relative URLs.
variable_set('file_test_hook_file_url_alter', 'protocol-relative');
state()->set('file_test.hook_file_url_alter', 'protocol-relative');
$uri = $this->createUri();
$url = file_create_url($uri);
$this->assertEqual('/' . base_path() . '/' . $public_directory_path . '/' . drupal_basename($uri), $url, 'Correctly generated a protocol-relative URL for a created file.');
......
Markdown is supported
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