Update to Drupal 8.0-dev-2015-11-17. Commits through da81cd220, Tue Nov 17 15:53:49 2015 +0000, Issue #2617224 by Wim Leers: Move around/fix some documentation.
This commit is contained in:
parent
4afb23bbd3
commit
7784f4c23d
929 changed files with 19798 additions and 5304 deletions
|
@ -29,27 +29,17 @@ class ThemeController extends ControllerBase {
|
|||
*/
|
||||
protected $themeHandler;
|
||||
|
||||
/**
|
||||
* The route builder service.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteBuilderInterface
|
||||
*/
|
||||
protected $routeBuilder;
|
||||
|
||||
/**
|
||||
* Constructs a new ThemeController.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
|
||||
* The theme handler.
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
|
||||
* The route builder.
|
||||
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
|
||||
* The config factory.
|
||||
*/
|
||||
public function __construct(ThemeHandlerInterface $theme_handler, RouteBuilderInterface $route_builder, ConfigFactoryInterface $config_factory) {
|
||||
public function __construct(ThemeHandlerInterface $theme_handler,ConfigFactoryInterface $config_factory) {
|
||||
$this->themeHandler = $theme_handler;
|
||||
$this->configFactory = $config_factory;
|
||||
$this->routeBuilder = $route_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -58,7 +48,6 @@ class ThemeController extends ControllerBase {
|
|||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('theme_handler'),
|
||||
$container->get('router.builder'),
|
||||
$container->get('config.factory')
|
||||
);
|
||||
}
|
||||
|
@ -183,8 +172,6 @@ class ThemeController extends ControllerBase {
|
|||
// Set the default theme.
|
||||
$config->set('default', $theme)->save();
|
||||
|
||||
$this->routeBuilder->setRebuildNeeded();
|
||||
|
||||
// The status message depends on whether an admin theme is currently in
|
||||
// use: a value of 0 means the admin theme is set to be the default
|
||||
// theme.
|
||||
|
|
|
@ -108,13 +108,11 @@ class ThemeSettingsForm extends ConfigFormBase {
|
|||
|
||||
$themes = $this->themeHandler->listInfo();
|
||||
|
||||
// Deny access if the theme is not installed or not found.
|
||||
if (!empty($theme) && (empty($themes[$theme]) || !$themes[$theme]->status)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
// Default settings are defined in theme_get_setting() in includes/theme.inc
|
||||
if ($theme) {
|
||||
if (!$this->themeHandler->hasUi($theme)) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$var = 'theme_' . $theme . '_settings';
|
||||
$config_key = $theme . '.settings';
|
||||
$themes = $this->themeHandler->listInfo();
|
||||
|
|
|
@ -48,7 +48,7 @@ class ThemeLocalTask extends DeriverBase implements ContainerDeriverInterface {
|
|||
*/
|
||||
public function getDerivativeDefinitions($base_plugin_definition) {
|
||||
foreach ($this->themeHandler->listInfo() as $theme_name => $theme) {
|
||||
if ($theme->status) {
|
||||
if ($this->themeHandler->hasUi($theme_name)) {
|
||||
$this->derivatives[$theme_name] = $base_plugin_definition;
|
||||
$this->derivatives[$theme_name]['title'] = $theme->info['name'];
|
||||
$this->derivatives[$theme_name]['route_parameters'] = array('theme' => $theme_name);
|
||||
|
|
|
@ -7,8 +7,10 @@
|
|||
|
||||
namespace Drupal\system;
|
||||
|
||||
use Drupal\Core\Config\ConfigCrudEvent;
|
||||
use Drupal\Core\Config\ConfigEvents;
|
||||
use Drupal\Core\Config\ConfigImporterEvent;
|
||||
use Drupal\Core\Routing\RouteBuilderInterface;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
|
||||
|
@ -18,6 +20,35 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|||
class SystemConfigSubscriber implements EventSubscriberInterface {
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The router builder.
|
||||
*
|
||||
* @var \Drupal\Core\Routing\RouteBuilderInterface
|
||||
*/
|
||||
protected $routerBuilder;
|
||||
|
||||
/**
|
||||
* Constructs the SystemConfigSubscriber.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
|
||||
* The router builder service.
|
||||
*/
|
||||
public function __construct(RouteBuilderInterface $router_builder) {
|
||||
$this->routerBuilder = $router_builder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the router when the default or admin theme is changed.
|
||||
*
|
||||
* @param \Drupal\Core\Config\ConfigCrudEvent $event
|
||||
*/
|
||||
public function onConfigSave(ConfigCrudEvent $event) {
|
||||
$saved_config = $event->getConfig();
|
||||
if ($saved_config->getName() == 'system.theme' && ($event->isChanged('admin') || $event->isChanged('default'))) {
|
||||
$this->routerBuilder->setRebuildNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that the configuration synchronization is valid.
|
||||
*
|
||||
|
@ -55,6 +86,7 @@ class SystemConfigSubscriber implements EventSubscriberInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
$events[ConfigEvents::SAVE][] = array('onConfigSave', 0);
|
||||
// The empty check has a high priority so that is can stop propagation if
|
||||
// there is no configuration to import.
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateNotEmpty', 512);
|
||||
|
|
|
@ -137,6 +137,7 @@ class EntityAutocompleteElementFormTest extends EntityUnitTestBase implements Fo
|
|||
$form['single_autocreate_no_validate'] = array(
|
||||
'#type' => 'entity_autocomplete',
|
||||
'#target_type' => 'entity_test',
|
||||
'#validate_reference' => FALSE,
|
||||
'#autocreate' => array(
|
||||
'bundle' => 'entity_test',
|
||||
),
|
||||
|
|
|
@ -691,8 +691,8 @@ class EntityFieldTest extends EntityUnitTestBase {
|
|||
->setSetting('target_type', 'node')
|
||||
->setSetting('handler_settings', ['target_bundles' => ['article' => 'article']]);
|
||||
$reference_field = \Drupal::TypedDataManager()->create($definition);
|
||||
$reference = $reference_field->appendItem(array('entity' => $node));
|
||||
$violations = $reference->validate();
|
||||
$reference_field->appendItem(array('entity' => $node));
|
||||
$violations = $reference_field->validate();
|
||||
$this->assertEqual($violations->count(), 1);
|
||||
|
||||
$node = entity_create('node', array(
|
||||
|
@ -701,8 +701,8 @@ class EntityFieldTest extends EntityUnitTestBase {
|
|||
'title' => $this->randomString(),
|
||||
));
|
||||
$node->save();
|
||||
$reference->setValue($node);
|
||||
$violations = $reference->validate();
|
||||
$reference_field->entity = $node;
|
||||
$violations = $reference_field->validate();
|
||||
$this->assertEqual($violations->count(), 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ class EntityReferenceFieldTest extends EntityUnitTestBase {
|
|||
$entity->{$this->fieldName}->target_id = $referenced_entity->id();
|
||||
$violations = $entity->{$this->fieldName}->validate();
|
||||
$this->assertEqual($violations->count(), 1, 'Validation throws a violation.');
|
||||
$this->assertEqual($violations[0]->getMessage(), t('The entity must be of bundle %bundle.', array('%bundle' => $this->bundle)));
|
||||
$this->assertEqual($violations[0]->getMessage(), t('This entity (%type: %id) cannot be referenced.', array('%type' => $this->referencedEntityType, '%id' => $referenced_entity->id())));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,8 +40,7 @@ class HtaccessUnitTest extends KernelTestBase {
|
|||
$this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006") !== FALSE);
|
||||
$this->assertFalse(strpos($content, "Require all denied") !== FALSE);
|
||||
$this->assertFalse(strpos($content, "Deny from all") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Options None") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Options +FollowSymLinks") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Options -Indexes -ExecCGI -Includes -MultiViews") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003") !== FALSE);
|
||||
$this->assertFilePermissions($public . '/.htaccess', 0444);
|
||||
|
||||
|
@ -54,8 +53,7 @@ class HtaccessUnitTest extends KernelTestBase {
|
|||
$this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Require all denied") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Deny from all") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Options None") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Options +FollowSymLinks") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Options -Indexes -ExecCGI -Includes -MultiViews") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003") !== FALSE);
|
||||
$this->assertFilePermissions($private . '/.htaccess', 0444);
|
||||
|
||||
|
@ -68,8 +66,7 @@ class HtaccessUnitTest extends KernelTestBase {
|
|||
$this->assertTrue(strpos($content,"SetHandler Drupal_Security_Do_Not_Remove_See_SA_2006_006") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "Require all denied") !== FALSE);
|
||||
$this->assertTrue(strpos($content,"Deny from all") !== FALSE);
|
||||
$this->assertTrue(strpos($content,"Options None") !== FALSE);
|
||||
$this->assertTrue(strpos($content,"Options +FollowSymLinks") !== FALSE);
|
||||
$this->assertTrue(strpos($content,"Options -Indexes -ExecCGI -Includes -MultiViews") !== FALSE);
|
||||
$this->assertTrue(strpos($content, "SetHandler Drupal_Security_Do_Not_Remove_See_SA_2013_003") !== FALSE);
|
||||
$this->assertFilePermissions($stream . '/.htaccess', 0444);
|
||||
|
||||
|
|
|
@ -40,6 +40,19 @@ class StandardInstallerTest extends ConfigAfterInstallerTestBase {
|
|||
parent::setUpSite();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function curlExec($curl_options, $redirect = FALSE) {
|
||||
// Ensure that we see the classy progress CSS on the batch page.
|
||||
// Batch processing happens as part of HTTP redirects, so we can access the
|
||||
// HTML of the batch page.
|
||||
if (strpos($curl_options[CURLOPT_URL], '&id=1&op=do_nojs') !== FALSE) {
|
||||
$this->assertRaw('themes/classy/css/components/progress.css');
|
||||
}
|
||||
return parent::curlExec($curl_options, $redirect);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the exported standard configuration is up to date.
|
||||
*/
|
||||
|
|
|
@ -204,6 +204,7 @@ class MenuRouterTest extends WebTestBase {
|
|||
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
|
||||
$this->drupalGet($path);
|
||||
$this->assertRaw('This is the menuTestCallback content.');
|
||||
$this->assertNoText(t('The website encountered an unexpected error. Please try again later.'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -115,7 +115,7 @@ class RouteProviderTest extends KernelTestBase {
|
|||
public function testCandidateOutlines() {
|
||||
|
||||
$connection = Database::getConnection();
|
||||
$provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
|
||||
$provider = new TestRouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
|
||||
|
||||
$parts = array('node', '5', 'edit');
|
||||
|
||||
|
@ -532,7 +532,7 @@ class RouteProviderTest extends KernelTestBase {
|
|||
*/
|
||||
public function testGetRoutesByPatternWithLongPatterns() {
|
||||
$connection = Database::getConnection();
|
||||
$provider = new RouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
|
||||
$provider = new TestRouteProvider($connection, $this->state, $this->currentPath, $this->cache, $this->pathProcessor, $this->cacheTagsInvalidator, 'test_routes');
|
||||
|
||||
$this->fixtures->createTables($connection);
|
||||
// This pattern has only 3 parts, so we will get candidates, but no routes,
|
||||
|
@ -613,3 +613,11 @@ class RouteProviderTest extends KernelTestBase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class TestRouteProvider extends RouteProvider {
|
||||
|
||||
public function getCandidateOutlines(array $parts) {
|
||||
return parent::getCandidateOutlines($parts);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,11 +44,6 @@ class DefaultMobileMetaTagsTest extends WebTestBase {
|
|||
* Verifies that the default mobile meta tags can be removed.
|
||||
*/
|
||||
public function testRemovingDefaultMetaTags() {
|
||||
// @todo remove once PHP7 on Drupal CI has the fix.
|
||||
if (version_compare(phpversion(), '7.0.0-dev') >= 0) {
|
||||
// @see https://bugs.php.net/bug.php?id=70808
|
||||
return;
|
||||
}
|
||||
\Drupal::service('module_installer')->install(array('system_module_test'));
|
||||
$this->drupalGet('');
|
||||
foreach ($this->defaultMetaTags as $name => $metatag) {
|
||||
|
|
|
@ -100,6 +100,7 @@ class ErrorHandlerTest extends WebTestBase {
|
|||
$this->assertErrorMessage($error_warning);
|
||||
$this->assertErrorMessage($error_user_notice);
|
||||
$this->assertNoRaw('<pre class="backtrace">', 'Did not find pre element with backtrace class.');
|
||||
$this->assertErrorLogged($fatal_error['@message']);
|
||||
|
||||
// Set error reporting to not collect notices.
|
||||
$config->set('error_level', ERROR_REPORTING_DISPLAY_SOME)->save();
|
||||
|
|
|
@ -52,6 +52,9 @@ class ThemeTest extends WebTestBase {
|
|||
$this->assertResponse(404, 'The theme settings form URL for a uninstalled theme could not be found.');
|
||||
$this->drupalGet('admin/appearance/settings/' . $this->randomMachineName());
|
||||
$this->assertResponse(404, 'The theme settings form URL for a non-existent theme could not be found.');
|
||||
$this->assertTrue(\Drupal::service('theme_installer')->install(['stable']));
|
||||
$this->drupalGet('admin/appearance/settings/stable');
|
||||
$this->assertResponse(404, 'The theme settings form URL for a hidden theme is unavailable.');
|
||||
|
||||
// Specify a filesystem path to be used for the logo.
|
||||
$file = current($this->drupalGetTestFiles('image'));
|
||||
|
@ -190,6 +193,23 @@ class ThemeTest extends WebTestBase {
|
|||
// The logo field should only be present on the global theme settings form.
|
||||
$this->assertNoFieldByName('logo_path');
|
||||
$this->drupalPostForm(NULL, [], t('Save configuration'));
|
||||
|
||||
// Ensure only valid themes are listed in the local tasks.
|
||||
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header']);
|
||||
$this->drupalGet('admin/appearance/settings');
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
$this->assertLink($theme_handler->getName('classy'));
|
||||
$this->assertLink($theme_handler->getName('bartik'));
|
||||
$this->assertNoLink($theme_handler->getName('stable'));
|
||||
|
||||
// If a hidden theme is an admin theme it should be viewable.
|
||||
\Drupal::configFactory()->getEditable('system.theme')->set('admin', 'stable')->save();
|
||||
\Drupal::service('router.builder')->rebuildIfNeeded();
|
||||
$this->drupalPlaceBlock('local_tasks_block', ['region' => 'header', 'theme' => 'stable']);
|
||||
$this->drupalGet('admin/appearance/settings');
|
||||
$this->assertLink($theme_handler->getName('stable'));
|
||||
$this->drupalGet('admin/appearance/settings/stable');
|
||||
$this->assertResponse(200, 'The theme settings form URL for a hidden theme that is the admin theme is available.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -255,8 +275,14 @@ class ThemeTest extends WebTestBase {
|
|||
* Test switching the default theme.
|
||||
*/
|
||||
function testSwitchDefaultTheme() {
|
||||
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
// First, install Stark and set it as the default theme programmatically.
|
||||
$theme_handler->install(array('stark'));
|
||||
$theme_handler->setDefault('stark');
|
||||
|
||||
// Install Bartik and set it as the default theme.
|
||||
\Drupal::service('theme_handler')->install(array('bartik'));
|
||||
$theme_handler->install(array('bartik'));
|
||||
$this->drupalGet('admin/appearance');
|
||||
$this->clickLink(t('Set as default'));
|
||||
$this->assertEqual($this->config('system.theme')->get('default'), 'bartik');
|
||||
|
@ -266,10 +292,10 @@ class ThemeTest extends WebTestBase {
|
|||
$this->assertText('Bartik(' . t('active tab') . ')', 'Default local task on blocks admin page is the default theme.');
|
||||
// Switch back to Stark and test again to test that the menu cache is cleared.
|
||||
$this->drupalGet('admin/appearance');
|
||||
// Classy is the first 'Set as default' link.
|
||||
$this->clickLink(t('Set as default'), 0);
|
||||
// Stark is the first 'Set as default' link.
|
||||
$this->clickLink(t('Set as default'));
|
||||
$this->drupalGet('admin/structure/block');
|
||||
$this->assertText('Classy(' . t('active tab') . ')', 'Default local task on blocks admin page has changed.');
|
||||
$this->assertText('Stark(' . t('active tab') . ')', 'Default local task on blocks admin page has changed.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -328,8 +354,8 @@ class ThemeTest extends WebTestBase {
|
|||
// base theme of bartik.
|
||||
$this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
|
||||
|
||||
// Change the default theme to stark, stark is third in the list.
|
||||
$this->clickLink(t('Set as default'), 2);
|
||||
// Change the default theme to stark, stark is second in the list.
|
||||
$this->clickLink(t('Set as default'), 1);
|
||||
|
||||
// Check that bartik can be uninstalled now.
|
||||
$this->assertRaw('Uninstall Bartik theme', 'A link to uninstall the Bartik theme does appear on the theme settings page.');
|
||||
|
@ -344,9 +370,9 @@ class ThemeTest extends WebTestBase {
|
|||
// Seven is the second in the list.
|
||||
$this->clickLink(t('Uninstall'));
|
||||
$this->assertRaw('The <em class="placeholder">Seven</em> theme has been uninstalled');
|
||||
// Now uninstall classy.
|
||||
$this->clickLink(t('Uninstall'));
|
||||
$this->assertRaw('The <em class="placeholder">Classy</em> theme has been uninstalled');
|
||||
|
||||
// Check that the classy theme still can't be uninstalled as it is hidden.
|
||||
$this->assertNoRaw('Uninstall Classy theme', 'A link to uninstall the Classy theme does not appear on the theme settings page.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,6 +87,7 @@ class UncaughtExceptionTest extends WebTestBase {
|
|||
$this->assertResponse(500);
|
||||
$this->assertText('The website encountered an unexpected error. Please try again later.');
|
||||
$this->assertText($this->expectedExceptionMessage);
|
||||
$this->assertErrorLogged($this->expectedExceptionMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -122,6 +123,7 @@ class UncaughtExceptionTest extends WebTestBase {
|
|||
|
||||
$this->assertRaw('The website encountered an unexpected error.');
|
||||
$this->assertRaw($this->expectedExceptionMessage);
|
||||
$this->assertErrorLogged($this->expectedExceptionMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,6 +180,7 @@ class UncaughtExceptionTest extends WebTestBase {
|
|||
$this->assertResponse(500);
|
||||
|
||||
$this->assertRaw($this->expectedExceptionMessage);
|
||||
$this->assertErrorLogged($this->expectedExceptionMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -199,6 +202,7 @@ class UncaughtExceptionTest extends WebTestBase {
|
|||
|
||||
$this->assertRaw('The website encountered an unexpected error');
|
||||
$this->assertRaw($this->expectedExceptionMessage);
|
||||
$this->assertErrorLogged($this->expectedExceptionMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -233,6 +237,7 @@ class UncaughtExceptionTest extends WebTestBase {
|
|||
$this->drupalGet('');
|
||||
$this->assertResponse(500);
|
||||
$this->assertRaw('PDOException');
|
||||
$this->assertErrorLogged($this->expectedExceptionMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,7 +257,8 @@ class UncaughtExceptionTest extends WebTestBase {
|
|||
|
||||
// Find fatal error logged to the simpletest error.log
|
||||
$errors = file(\Drupal::root() . '/' . $this->siteDirectory . '/error.log');
|
||||
$this->assertIdentical(count($errors), 1, 'Exactly one line logged to the PHP error log');
|
||||
$this->assertIdentical(count($errors), 2, 'The error + the error that the logging service is broken has been written to the error log.');
|
||||
$this->assertTrue(strpos($errors[0], 'Failed to log error') !== FALSE, 'The error handling logs when an error could not be logged to the logger.');
|
||||
|
||||
$expected_path = \Drupal::root() . '/core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php';
|
||||
$expected_line = 63;
|
||||
|
|
|
@ -0,0 +1,185 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\system\Tests\Theme\StableLibraryOverrideTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Theme;
|
||||
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests Stable's library overrides.
|
||||
*
|
||||
* @group Theme
|
||||
*/
|
||||
class StableLibraryOverrideTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* The theme manager.
|
||||
*
|
||||
* @var \Drupal\Core\Theme\ThemeManagerInterface
|
||||
*/
|
||||
protected $themeManager;
|
||||
|
||||
/**
|
||||
* The theme initialization.
|
||||
*
|
||||
* @var \Drupal\Core\Theme\ThemeInitializationInterface
|
||||
*/
|
||||
protected $themeInitialization;
|
||||
|
||||
/**
|
||||
* The library discovery service.
|
||||
*
|
||||
* @var \Drupal\Core\Asset\LibraryDiscoveryInterface
|
||||
*/
|
||||
protected $libraryDiscovery;
|
||||
|
||||
/**
|
||||
* A list of all core modules.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $allModules;
|
||||
|
||||
/**
|
||||
* A list of libraries to skip checking, in the format extension/library_name.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $librariesToSkip = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->themeManager = $this->container->get('theme.manager');
|
||||
$this->themeInitialization = $this->container->get('theme.initialization');
|
||||
$this->libraryDiscovery = $this->container->get('library.discovery');
|
||||
|
||||
$this->container->get('theme_installer')->install(['stable']);
|
||||
|
||||
// Enable all core modules.
|
||||
$all_modules = system_rebuild_module_data();
|
||||
$all_modules = array_filter($all_modules, function ($module) {
|
||||
// Filter contrib, hidden, already enabled modules and modules in the
|
||||
// Testing package.
|
||||
if ($module->origin !== 'core' || !empty($module->info['hidden']) || $module->status == TRUE || $module->info['package'] == 'Testing') {
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
});
|
||||
$this->allModules = array_keys($all_modules);
|
||||
sort($this->allModules);
|
||||
$this->enableModules($this->allModules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that Stable overrides all relevant core library assets.
|
||||
*/
|
||||
public function testStableLibraryOverrides() {
|
||||
// First get the clean library definitions with no active theme.
|
||||
$libraries_before = $this->getAllLibraries();
|
||||
$libraries_before = $this->removeVendorAssets($libraries_before);
|
||||
|
||||
$this->themeManager->setActiveTheme($this->themeInitialization->getActiveThemeByName('stable'));
|
||||
$this->libraryDiscovery->clearCachedDefinitions();
|
||||
|
||||
// Now get the library definitions with Stable as the active theme.
|
||||
$libraries_after = $this->getAllLibraries();
|
||||
$libraries_after = $this->removeVendorAssets($libraries_after);
|
||||
|
||||
$root = \Drupal::root();
|
||||
foreach ($libraries_before as $extension => $libraries) {
|
||||
foreach ($libraries as $library_name => $library) {
|
||||
// Allow skipping libraries.
|
||||
if (in_array("$extension/$library_name", $this->librariesToSkip)) {
|
||||
continue;
|
||||
}
|
||||
$library_after = $libraries_after[$extension][$library_name];
|
||||
|
||||
// Check that all the CSS assets are overridden.
|
||||
foreach ($library['css'] as $index => $asset) {
|
||||
$clean_path = $asset['data'];
|
||||
$stable_path = $library_after['css'][$index]['data'];
|
||||
// Make core/misc assets look like they are coming from a "core"
|
||||
// module.
|
||||
$replacements = [
|
||||
'core/misc/' => "core/modules/core/css/",
|
||||
];
|
||||
$expected_path = strtr($clean_path, $replacements);
|
||||
|
||||
// Adjust the module asset paths to correspond with the Stable folder
|
||||
// structure.
|
||||
$expected_path = str_replace("core/modules/$extension/css/", "core/themes/stable/css/$extension/", $expected_path);
|
||||
$assert_path = str_replace("core/modules/$extension/", '', $clean_path);
|
||||
|
||||
$this->assertEqual($expected_path, $stable_path, "$assert_path from the $extension/$library_name library is overridden in Stable.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all vendor libraries and assets from the library definitions.
|
||||
*
|
||||
* @param array[] $all_libraries
|
||||
* An associative array of libraries keyed by extension, then by library
|
||||
* name, and so on.
|
||||
*
|
||||
* @return array[]
|
||||
* The reduced array of libraries.
|
||||
*/
|
||||
protected function removeVendorAssets($all_libraries) {
|
||||
foreach ($all_libraries as $extension => $libraries) {
|
||||
foreach ($libraries as $library_name => $library) {
|
||||
if (isset($library['remote'])) {
|
||||
unset($all_libraries[$extension][$library_name]);
|
||||
}
|
||||
foreach (['css', 'js'] as $asset_type) {
|
||||
foreach ($library[$asset_type] as $index => $asset) {
|
||||
if (strpos($asset['data'], 'core/assets/vendor') !== FALSE) {
|
||||
unset($all_libraries[$extension][$library_name][$asset_type][$index]);
|
||||
// Re-key the array of assets. This is needed because
|
||||
// libraries-override doesn't always preserve the order.
|
||||
if (!empty($all_libraries[$extension][$library_name][$asset_type])) {
|
||||
$all_libraries[$extension][$library_name][$asset_type] = array_values($all_libraries[$extension][$library_name][$asset_type]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $all_libraries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all libraries for core and all installed modules.
|
||||
*
|
||||
* @return array[]
|
||||
* An associative array of libraries keyed by extension, then by library
|
||||
* name, and so on.
|
||||
*/
|
||||
protected function getAllLibraries() {
|
||||
$modules = \Drupal::moduleHandler()->getModuleList();
|
||||
$module_list = array_keys($modules);
|
||||
sort($module_list);
|
||||
$this->assertEqual($this->allModules, $module_list, 'All core modules are installed.');
|
||||
|
||||
$libraries['core'] = $this->libraryDiscovery->getLibrariesByExtension('core');
|
||||
|
||||
$root = \Drupal::root();
|
||||
foreach ($modules as $module_name => $module) {
|
||||
$library_file = $module->getPath() . '/' . $module_name . '.libraries.yml';
|
||||
if (is_file($root . '/' . $library_file)) {
|
||||
$libraries[$module_name] = $this->libraryDiscovery->getLibrariesByExtension($module_name);
|
||||
}
|
||||
}
|
||||
return $libraries;
|
||||
}
|
||||
|
||||
}
|
|
@ -30,8 +30,7 @@ class UpdatePathRC1TestBaseFilledTest extends UpdatePathRC1TestBaseTest {
|
|||
* Tests that the content and configuration were properly updated.
|
||||
*/
|
||||
public function testUpdatedSite() {
|
||||
// @todo there are no updates to run.
|
||||
//$this->runUpdates();
|
||||
$this->runUpdates();
|
||||
|
||||
$spanish = \Drupal::languageManager()->getLanguage('es');
|
||||
|
||||
|
|
|
@ -34,6 +34,8 @@ class UpdatePathRC1TestBaseTest extends UpdatePathTestBase {
|
|||
* Tests that the database was properly loaded.
|
||||
*/
|
||||
public function testDatabaseLoaded() {
|
||||
$extensions = \Drupal::service('config.storage')->read('core.extension');
|
||||
$this->assertFalse(isset($extensions['theme']['stable']), 'Stable is not installed before updating.');
|
||||
$hook_updates = [
|
||||
'user' => '8000',
|
||||
'node' => '8003',
|
||||
|
@ -57,11 +59,14 @@ class UpdatePathRC1TestBaseTest extends UpdatePathTestBase {
|
|||
$this->assertEqual($existing_updates[$expected_update], 1, new FormattableMarkup("@expected_update exists in 'existing_updates' key and only appears once.", ['@expected_update' => $expected_update]));
|
||||
}
|
||||
|
||||
// @todo there are no updates to run.
|
||||
// $this->runUpdates();
|
||||
$this->runUpdates();
|
||||
$this->assertEqual(\Drupal::config('system.site')->get('name'), 'Site-Install');
|
||||
$this->drupalGet('<front>');
|
||||
$this->assertText('Site-Install');
|
||||
$extensions = \Drupal::service('config.storage')->read('core.extension');
|
||||
$this->assertTrue(isset($extensions['theme']['stable']), 'Stable is installed after updating.');
|
||||
$blocks = \Drupal::entityManager()->getStorage('block')->loadByProperties(['theme' => 'stable']);
|
||||
$this->assertTrue(empty($blocks), 'No blocks have been placed for Stable.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1464,6 +1464,7 @@ function system_update_8005() {
|
|||
break;
|
||||
|
||||
case 'classy':
|
||||
case 'stable':
|
||||
// Don't place any blocks or trigger custom themes installed warning.
|
||||
break;
|
||||
|
||||
|
@ -1541,6 +1542,7 @@ function system_update_8006() {
|
|||
|
||||
case 'seven':
|
||||
case 'classy':
|
||||
case 'stable':
|
||||
// Don't place any blocks or trigger custom themes installed warning.
|
||||
break;
|
||||
default:
|
||||
|
@ -1805,23 +1807,6 @@ function system_update_8011() {
|
|||
_system_update_create_block($name, $theme_name, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Install the Stable base theme if needed.
|
||||
*/
|
||||
function system_update_8012() {
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
// Ensure we have fresh info.
|
||||
$theme_handler->rebuildThemeData();
|
||||
foreach ($theme_handler->listInfo() as $theme) {
|
||||
// We first check that a base theme is set because if it's set to false then
|
||||
// it's unset in \Drupal\Core\Extension\ThemeHandler::rebuildThemeData().
|
||||
if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') {
|
||||
$theme_handler->install(['stable']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable automated cron module and move the config into it.
|
||||
*/
|
||||
|
@ -1847,3 +1832,31 @@ function system_update_8013() {
|
|||
/**
|
||||
* @} End of "addtogroup updates-8.0.0-beta".
|
||||
*/
|
||||
|
||||
/**
|
||||
* @addtogroup updates-8.0.0-rc
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Install the Stable base theme if needed.
|
||||
*/
|
||||
function system_update_8014() {
|
||||
$theme_handler = \Drupal::service('theme_handler');
|
||||
if ($theme_handler->themeExists('stable')) {
|
||||
return;
|
||||
}
|
||||
$theme_handler->refreshInfo();
|
||||
foreach ($theme_handler->listInfo() as $theme) {
|
||||
// We first check that a base theme is set because if it's set to false then
|
||||
// it's unset in \Drupal\Core\Extension\ThemeHandler::rebuildThemeData().
|
||||
if (isset($theme->info['base theme']) && $theme->info['base theme'] == 'stable') {
|
||||
$theme_handler->install(['stable']);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @} End of "addtogroup updates-8.0.0-rc".
|
||||
*/
|
||||
|
|
|
@ -35,6 +35,7 @@ services:
|
|||
- { name: theme_negotiator, priority: 100 }
|
||||
system.config_subscriber:
|
||||
class: Drupal\system\SystemConfigSubscriber
|
||||
arguments: ['@router.builder']
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
system.config_cache_tag:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% extends "@block/block.html.twig" %}
|
||||
{% extends "block.html.twig" %}
|
||||
{#
|
||||
/**
|
||||
* @file
|
||||
|
|
BIN
core/modules/system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz
vendored
Normal file
BIN
core/modules/system/tests/fixtures/update/drupal-8-rc1.bare.standard.php.gz
vendored
Normal file
Binary file not shown.
BIN
core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz
vendored
Normal file
BIN
core/modules/system/tests/fixtures/update/drupal-8-rc1.filled.standard.php.gz
vendored
Normal file
Binary file not shown.
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
namespace Drupal\test_page_test\Controller;
|
||||
use Symfony\Component\HttpKernel\Exception\HttpException;
|
||||
|
||||
/**
|
||||
* Defines a test controller for page titles.
|
||||
|
@ -75,4 +76,14 @@ class Test {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Throws a HTTP exception.
|
||||
*
|
||||
* @param int $code
|
||||
* The status code.
|
||||
*/
|
||||
public function httpResponseException($code) {
|
||||
throw new HttpException($code);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -42,3 +42,11 @@ test_page_test.admin_render_title:
|
|||
_controller: '\Drupal\test_page_test\Controller\Test::renderTitle'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
test_page_test.http_response_exception:
|
||||
path: '/test-http-response-exception/{code}'
|
||||
defaults:
|
||||
_controller: '\Drupal\test_page_test\Controller\Test::httpResponseException'
|
||||
code: 200
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
|
@ -135,6 +135,7 @@ class MenuLinkTreeTest extends UnitTestCase {
|
|||
'max-age' => Cache::PERMANENT,
|
||||
],
|
||||
'#sorted' => TRUE,
|
||||
'#menu_name' => 'mock',
|
||||
'#theme' => 'menu__mock',
|
||||
'#items' => [
|
||||
// To be filled when generating test cases, using $get_built_element().
|
||||
|
|
|
@ -44,6 +44,10 @@ class SystemLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
->will($this->returnValue(array(
|
||||
'bartik' => $theme,
|
||||
)));
|
||||
$this->themeHandler->expects($this->any())
|
||||
->method('hasUi')
|
||||
->with('bartik')
|
||||
->willReturn(TRUE);
|
||||
$this->container->set('theme_handler', $this->themeHandler);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,8 @@ description: 'Test theme which acts as a base theme for other test subthemes.'
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
base theme: false
|
||||
hidden: true
|
||||
|
||||
libraries:
|
||||
- test_basetheme/global-styling
|
||||
stylesheets-remove:
|
||||
|
|
|
@ -44,12 +44,12 @@ libraries-override:
|
|||
core/drupal.dropbutton:
|
||||
css:
|
||||
component:
|
||||
misc/dropbutton/dropbutton.css: /themes/my_theme/css/dropbutton.css
|
||||
/core/themes/stable/css/core/dropbutton/dropbutton.css: /themes/my_theme/css/dropbutton.css
|
||||
# Use stream wrappers.
|
||||
core/drupal.vertical-tabs:
|
||||
css:
|
||||
component:
|
||||
misc/vertical-tabs.css: public://my_css/vertical-tabs.css
|
||||
/core/themes/stable/css/core/vertical-tabs.css: public://my_css/vertical-tabs.css
|
||||
# Use a protocol-relative URI.
|
||||
core/jquery.ui:
|
||||
css:
|
||||
|
|
Reference in a new issue