Skip to content
Snippets Groups Projects
Commit 632c2ea3 authored by Tobias Zimmermann's avatar Tobias Zimmermann
Browse files

Issue #2183087 by tstoeckler, rjacobs: Update for removed core functions.

parent c2345a7e
No related branches found
No related tags found
No related merge requests found
Libraries 8.x-3.x, xxxx-xx-xx
-----------------------------
#2183087 by tstoeckler, rjacobs: Update for removed core functions.
by tstoeckler: Fix tests.
by tstoeckler: Provide required 'type' key in test library info file.
#2090351 by tstoeckler: Remove obsolete hook_flush_caches().
......
......@@ -7,12 +7,21 @@
namespace Drupal\libraries\Tests;
use \Drupal\simpletest\UnitTestBase;
use Drupal\simpletest\DrupalUnitTestBase;
/**
* Tests basic Libraries API functions.
*/
class LibrariesUnitTest extends UnitTestBase {
class LibrariesUnitTest extends DrupalUnitTestBase {
/**
* {@inheritdoc}
*/
public static $modules = array('libraries');
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'Libraries API unit tests',
......@@ -21,11 +30,6 @@ class LibrariesUnitTest extends UnitTestBase {
);
}
function setUp() {
drupal_load('module', 'libraries');
parent::setUp();
}
/**
* Tests libraries_get_path().
*/
......
......@@ -396,7 +396,7 @@ class LibrariesWebTest extends WebTestBase {
$this->assertLibraryFiles('example_4', 'Concurrent version and variant overloading');
// Test caching.
variable_set('libraries_test_cache', TRUE);
\Drupal::state()->set('libraries_test.cache', TRUE);
cache('libraries')->delete('example_callback');
// When the library information is not cached, all callback groups should be
// invoked.
......@@ -414,7 +414,7 @@ class LibrariesWebTest extends WebTestBase {
$this->assertNoRaw('The <em>post-detect</em> callback group was not invoked.', 'Post-detect callback not invoked for cached libraries.');
$this->assertRaw('The <em>pre-load</em> callback group was invoked.', 'Pre-load callback invoked for cached libraries.');
$this->assertRaw('The <em>post-load</em> callback group was invoked.', 'Post-load callback invoked for cached libraries.');
variable_set('libraries_test_cache', FALSE);
\Drupal::state()->set('libraries_test.cache', FALSE);
}
/**
......
......@@ -680,7 +680,8 @@ function libraries_load_files($library) {
if (!isset($options['group'])) {
$options['group'] = ($type == 'js') ? JS_DEFAULT : CSS_AGGREGATE_DEFAULT;
}
call_user_func('drupal_add_' . $type, $data, $options);
// @todo Avoid the usage of _drupal_add_js() and _drupal_add_css()
call_user_func('_drupal_add_' . $type, $data, $options);
$count++;
}
}
......
......@@ -458,7 +458,7 @@ function _libraries_test_callback(&$library, $version, $variant, $group) {
// The following is used to test caching of library information.
// Only set the message for the top-level library to prevent confusing,
// duplicate messages.
if (!isset($version) && !isset($variant) && variable_get('libraries_test_cache', FALSE)) {
if (!isset($version) && !isset($variant) && \Drupal::state()->get('libraries_test.cache', FALSE)) {
drupal_set_message("The <em>$group</em> callback group was invoked.");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment