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

by tstoeckler: Fix tests

parent 04e6d129
No related branches found
No related tags found
No related merge requests found
Libraries 8.x-3.x, xxxx-xx-xx
-----------------------------
#2390301 by rjacobs: Fix DrupalUnitTestBase no longer exists so tests can't load
by tstoeckler: Fix tests.
#2390301 by rjacobs: Fix DrupalUnitTestBase no longer exists so tests can't load.
#2332157 by tstoeckler: Add a composer.json.
#2287529 by drupalshrek, tstoeckler: Update installation link in README.txt.
by tstoeckler: Fix tests.
......
......@@ -680,6 +680,9 @@ function libraries_load_files($library) {
if (!isset($options['group'])) {
$options['group'] = ($type == 'js') ? JS_DEFAULT : CSS_AGGREGATE_DEFAULT;
}
if ($type === 'js') {
$options['version'] = -1;
}
// @todo Avoid the usage of _drupal_add_js() and _drupal_add_css()
call_user_func('_drupal_add_' . $type, $data, $options);
$count++;
......
......@@ -17,10 +17,42 @@ use Drupal\simpletest\WebTestBase;
*/
class LibrariesWebTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $profile = 'testing';
/**
* Modules to install.
*
* @var array
*/
static $modules = array('libraries', 'libraries_test');
/**
* The URL generator used in this test.
*
* @var \Drupal\Core\Utility\UnroutedUrlAssemblerInterface
*/
protected $urlAssembler;
/**
* The state service used in this test.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->urlAssembler = $this->container->get('unrouted_url_assembler');
$this->state = $this->container->get('state');
}
/**
* Tests libraries_detect_dependencies().
*/
......@@ -465,12 +497,17 @@ class LibrariesWebTest extends WebTestBase {
// JavaScript and CSS files appear as full URLs and with an appended
// query string.
if (in_array($extension, array('js', 'css'))) {
$filepath = url('', array('absolute' => TRUE)) . $filepath;
$filepath .= '?' . \Drupal::state()->get('system.css_js_query_string') ?: '0';
$filepath = $this->urlAssembler->assemble("base://$filepath", [
'query' => [
$this->state->get('system.css_js_query_string') ?: '0' => NULL,
],
'absolute' => TRUE,
]);
// If index.php is part of the generated URLs, we need to strip it.
$filepath = str_replace('index.php/', '', $filepath);
//$filepath = str_replace('index.php/', '', $filepath);
}
$raw = $html[$extension][0] . $filepath . $html[$extension][1];
list($prefix, $suffix) = $html[$extension];
$raw = $prefix . $filepath . $suffix;
if ($expected) {
$html_expected[] = String::checkPlain($raw);
$this->assertRaw($raw, "$label$name.$extension found.");
......
libraries_test_files:
path: '/libraries_test/files'
defaults:
_content: Drupal\libraries_test\Controller\ExampleController::files
_controller: Drupal\libraries_test\Controller\ExampleController::files
requirements:
_access: 'TRUE'
libraries_test_integration_files:
path: '/libraries_test/integration_files'
defaults:
_content: Drupal\libraries_test\Controller\ExampleController::integration
_controller: Drupal\libraries_test\Controller\ExampleController::integration
requirements:
_access: 'TRUE'
libraries_test_versions:
path: '/libraries_test/versions'
defaults:
_content: Drupal\libraries_test\Controller\ExampleController::versions
_controller: Drupal\libraries_test\Controller\ExampleController::versions
requirements:
_access: 'TRUE'
libraries_test_variant:
path: '/libraries_test/variant'
defaults:
_content: Drupal\libraries_test\Controller\ExampleController::variant
_controller: Drupal\libraries_test\Controller\ExampleController::variant
requirements:
_access: 'TRUE'
libraries_test_versions_and_variants:
path: '/libraries_test/versions_and_variants'
defaults:
_content: Drupal\libraries_test\Controller\ExampleController::versionsAndVariants
_controller: Drupal\libraries_test\Controller\ExampleController::versionsAndVariants
requirements:
_access: 'TRUE'
libraries_test_cache:
path: '/libraries_test/cache'
defaults:
_content: Drupal\libraries_test\Controller\ExampleController::cache
_controller: Drupal\libraries_test\Controller\ExampleController::cache
requirements:
_access: 'TRUE'
......@@ -68,7 +68,7 @@ class ExampleController implements ContainerInjectionInterface {
$output .= '</ul>';
$output .= '</div>';
return $output;
return ['#markup' => $output];
}
public function files() {
......
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