Skip to content
Snippets Groups Projects
Commit ffeb4a7d authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2560521 by dawehner, plach, larowlan, lauriii, Xano, Wim Leers, catch,...

Issue #2560521 by dawehner, plach, larowlan, lauriii, Xano, Wim Leers, catch, jhedstrom: Javascript does not work on beta 12 => HEAD update.php
parent f6163c3a
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,35 @@
*/
class UpdateKernel extends DrupalKernel {
/**
* {@inheritdoc}
*/
public function discoverServiceProviders() {
parent::discoverServiceProviders();
$this->serviceProviderClasses['app']['update_kernel'] = 'Drupal\Core\Update\UpdateServiceProvider';
}
/**
* {@inheritdoc}
*/
protected function initializeContainer() {
// Always force a container rebuild, in order to be able to override some
// services, see \Drupal\Core\Update\UpdateServiceProvider.
$this->containerNeedsRebuild = TRUE;
$container = parent::initializeContainer();
return $container;
}
/**
* {@inheritdoc}
*/
protected function cacheDrupalContainer(array $container_definition) {
// Don't save this particular container to cache, so it does not leak into
// the main site at all.
return FALSE;
}
/**
* {@inheritdoc}
*/
......
<?php
/**
* @file
* Contains \Drupal\Core\Update\UpdateServiceProvider.
*/
namespace Drupal\Core\Update;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
use Drupal\Core\DependencyInjection\ServiceProviderInterface;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* Ensures for some services that they don't cache.
*/
class UpdateServiceProvider implements ServiceProviderInterface, ServiceModifierInterface {
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) {
$definition = new Definition('Drupal\Core\Cache\NullBackend', ['null']);
$container->setDefinition('cache.null', $definition);
}
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
$definition = $container->getDefinition('asset.resolver');
$argument = new Reference('cache.null');
$definition->replaceArgument(5, $argument);
$definition = $container->getDefinition('library.discovery.collector');
$argument = new Reference('cache.null');
$definition->replaceArgument(0, $argument);
}
}
......@@ -238,6 +238,7 @@ protected function runUpdates() {
$this->drupalGet($this->updateUrl);
$this->clickLink(t('Continue'));
$this->doSelectionTest();
// Run the update hooks.
$this->clickLink(t('Apply pending updates'));
......@@ -273,4 +274,13 @@ protected function replaceUser1() {
$account->save();
}
/**
* Tests the selection page.
*/
protected function doSelectionTest() {
// No-op. Tests wishing to do test the selection page or the general
// update.php environment before running update.php can override this method
// and implement their required tests.
}
}
<?php
/**
* @file
* Contains \Drupal\system\Tests\Update\UpdatePathTestJavaScriptTest.php
*/
namespace Drupal\system\Tests\Update;
/**
* Tests the presence of JavaScript at update.php.
*
* @group Update
*/
class UpdatePathTestJavaScriptTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../tests/fixtures/update/drupal-8.bare.standard.php.gz',
];
}
/**
* Test JavaScript loading at update.php.
*
* @see ::doPreUpdateTests
*/
public function testJavaScriptLoading() {
$this->runUpdates();
}
/**
* {@inheritdoc}
*/
protected function doSelectionTest() {
// Ensure that at least one JS script has drupalSettings in there.
$scripts = $this->xpath('//script');
$found = FALSE;
foreach ($scripts as $script) {
if (!isset($script['src'])) {
continue;
}
$src = (string) $script['src'];
$file_content = file_get_contents($src);
if (strpos($file_content, 'window.drupalSettings =') !== FALSE) {
$found = TRUE;
break;
}
}
$this->assertTrue($found, 'Ensure that the drupalSettingsLoader.js was included in the JS 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