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 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. #2332157 by tstoeckler: Add a composer.json.
#2287529 by drupalshrek, tstoeckler: Update installation link in README.txt. #2287529 by drupalshrek, tstoeckler: Update installation link in README.txt.
by tstoeckler: Fix tests. by tstoeckler: Fix tests.
......
...@@ -680,6 +680,9 @@ function libraries_load_files($library) { ...@@ -680,6 +680,9 @@ function libraries_load_files($library) {
if (!isset($options['group'])) { if (!isset($options['group'])) {
$options['group'] = ($type == 'js') ? JS_DEFAULT : CSS_AGGREGATE_DEFAULT; $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() // @todo Avoid the usage of _drupal_add_js() and _drupal_add_css()
call_user_func('_drupal_add_' . $type, $data, $options); call_user_func('_drupal_add_' . $type, $data, $options);
$count++; $count++;
......
...@@ -17,10 +17,42 @@ use Drupal\simpletest\WebTestBase; ...@@ -17,10 +17,42 @@ use Drupal\simpletest\WebTestBase;
*/ */
class LibrariesWebTest extends WebTestBase { class LibrariesWebTest extends WebTestBase {
/**
* {@inheritdoc}
*/
protected $profile = 'testing'; protected $profile = 'testing';
/**
* Modules to install.
*
* @var array
*/
static $modules = array('libraries', 'libraries_test'); 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(). * Tests libraries_detect_dependencies().
*/ */
...@@ -465,12 +497,17 @@ class LibrariesWebTest extends WebTestBase { ...@@ -465,12 +497,17 @@ class LibrariesWebTest extends WebTestBase {
// JavaScript and CSS files appear as full URLs and with an appended // JavaScript and CSS files appear as full URLs and with an appended
// query string. // query string.
if (in_array($extension, array('js', 'css'))) { if (in_array($extension, array('js', 'css'))) {
$filepath = url('', array('absolute' => TRUE)) . $filepath; $filepath = $this->urlAssembler->assemble("base://$filepath", [
$filepath .= '?' . \Drupal::state()->get('system.css_js_query_string') ?: '0'; '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. // 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) { if ($expected) {
$html_expected[] = String::checkPlain($raw); $html_expected[] = String::checkPlain($raw);
$this->assertRaw($raw, "$label$name.$extension found."); $this->assertRaw($raw, "$label$name.$extension found.");
......
libraries_test_files: libraries_test_files:
path: '/libraries_test/files' path: '/libraries_test/files'
defaults: defaults:
_content: Drupal\libraries_test\Controller\ExampleController::files _controller: Drupal\libraries_test\Controller\ExampleController::files
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
libraries_test_integration_files: libraries_test_integration_files:
path: '/libraries_test/integration_files' path: '/libraries_test/integration_files'
defaults: defaults:
_content: Drupal\libraries_test\Controller\ExampleController::integration _controller: Drupal\libraries_test\Controller\ExampleController::integration
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
libraries_test_versions: libraries_test_versions:
path: '/libraries_test/versions' path: '/libraries_test/versions'
defaults: defaults:
_content: Drupal\libraries_test\Controller\ExampleController::versions _controller: Drupal\libraries_test\Controller\ExampleController::versions
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
libraries_test_variant: libraries_test_variant:
path: '/libraries_test/variant' path: '/libraries_test/variant'
defaults: defaults:
_content: Drupal\libraries_test\Controller\ExampleController::variant _controller: Drupal\libraries_test\Controller\ExampleController::variant
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
libraries_test_versions_and_variants: libraries_test_versions_and_variants:
path: '/libraries_test/versions_and_variants' path: '/libraries_test/versions_and_variants'
defaults: defaults:
_content: Drupal\libraries_test\Controller\ExampleController::versionsAndVariants _controller: Drupal\libraries_test\Controller\ExampleController::versionsAndVariants
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
libraries_test_cache: libraries_test_cache:
path: '/libraries_test/cache' path: '/libraries_test/cache'
defaults: defaults:
_content: Drupal\libraries_test\Controller\ExampleController::cache _controller: Drupal\libraries_test\Controller\ExampleController::cache
requirements: requirements:
_access: 'TRUE' _access: 'TRUE'
...@@ -68,7 +68,7 @@ class ExampleController implements ContainerInjectionInterface { ...@@ -68,7 +68,7 @@ class ExampleController implements ContainerInjectionInterface {
$output .= '</ul>'; $output .= '</ul>';
$output .= '</div>'; $output .= '</div>';
return $output; return ['#markup' => $output];
} }
public function files() { 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