Update to Drupal 8.0.3. For more information, see https://www.drupal.org/drupal-8.0.3-release-notes
This commit is contained in:
parent
10f9f7fbde
commit
9db4fae9a7
202 changed files with 3806 additions and 760 deletions
|
@ -133,7 +133,6 @@ class CronForm extends FormBase {
|
|||
drupal_set_message(t('Cron run failed.'), 'error');
|
||||
}
|
||||
|
||||
return new RedirectResponse($this->url('system.cron_settings', array(), array('absolute' => TRUE)));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ class SystemConfigSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
public static function getSubscribedEvents() {
|
||||
$events[ConfigEvents::SAVE][] = array('onConfigSave', 0);
|
||||
// The empty check has a high priority so that is can stop propagation if
|
||||
// The empty check has a high priority so that it can stop propagation if
|
||||
// there is no configuration to import.
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateNotEmpty', 512);
|
||||
$events[ConfigEvents::IMPORT_VALIDATE][] = array('onConfigImporterValidateSiteUUID', 256);
|
||||
|
|
|
@ -22,13 +22,13 @@ use Drupal\Core\Asset\AttachedAssets;
|
|||
*/
|
||||
class FrameworkTest extends AjaxTestBase {
|
||||
/**
|
||||
* Ensures \Drupal\Core\Ajax\AjaxResponse::ajaxRender() returns JavaScript settings from the page request.
|
||||
* Verifies the Ajax rendering of a command in the settings.
|
||||
*/
|
||||
public function testAJAXRender() {
|
||||
// Verify that settings command is generated if JavaScript settings exist.
|
||||
$commands = $this->drupalGetAjax('ajax-test/render');
|
||||
$expected = new SettingsCommand(array('ajax' => 'test'), TRUE);
|
||||
$this->assertCommand($commands, $expected->render(), '\Drupal\Core\Ajax\AjaxResponse::ajaxRender() loads JavaScript settings.');
|
||||
$this->assertCommand($commands, $expected->render(), 'JavaScript settings command is present.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -59,8 +59,8 @@ class FrameworkTest extends AjaxTestBase {
|
|||
|
||||
// Load any page with at least one CSS file, at least one JavaScript file
|
||||
// and at least one #ajax-powered element. The latter is an assumption of
|
||||
// drupalPostAjaxForm(), the two former are assumptions of
|
||||
// AjaxResponse::ajaxRender().
|
||||
// drupalPostAjaxForm(), the two former are assumptions of the Ajax
|
||||
// renderer.
|
||||
// @todo refactor AJAX Framework + tests to make less assumptions.
|
||||
$this->drupalGet('ajax_forms_test_lazy_load_form');
|
||||
|
||||
|
|
|
@ -96,8 +96,8 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$rendered_css = $this->renderer->renderPlain($css_render_array);
|
||||
$rendered_js = $this->renderer->renderPlain($js_render_array);
|
||||
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
|
||||
$this->assertNotIdentical(strpos($rendered_css, '<link rel="stylesheet" href="' . file_create_url('core/modules/system/tests/modules/common_test/bar.css') . '?' . $query_string . '" media="all" />'), FALSE, 'Rendering an external CSS file.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_create_url('core/modules/system/tests/modules/common_test/foo.js') . '?' . $query_string . '"></script>'), FALSE, 'Rendering an external JavaScript file.');
|
||||
$this->assertNotIdentical(strpos($rendered_css, '<link rel="stylesheet" href="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/bar.css')) . '?' . $query_string . '" media="all" />'), FALSE, 'Rendering an external CSS file.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/foo.js')) . '?' . $query_string . '"></script>'), FALSE, 'Rendering an external JavaScript file.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,7 +150,7 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
|
||||
$rendered_js = $this->renderer->renderPlain($js_render_array);
|
||||
$expected_1 = '<script src="http://example.com/deferred-external.js" foo="bar" defer></script>';
|
||||
$expected_2 = '<script src="' . file_create_url('core/modules/system/tests/modules/common_test/deferred-internal.js') . '?v=1" defer bar="foo"></script>';
|
||||
$expected_2 = '<script src="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/deferred-internal.js')) . '?v=1" defer bar="foo"></script>';
|
||||
$this->assertNotIdentical(strpos($rendered_js, $expected_1), FALSE, 'Rendered external JavaScript with correct defer and random attributes.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, $expected_2), FALSE, 'Rendered internal JavaScript with correct defer and random attributes.');
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
|
||||
$rendered_js = $this->renderer->renderPlain($js_render_array);
|
||||
$expected_1 = '<script src="http://example.com/deferred-external.js" foo="bar" defer></script>';
|
||||
$expected_2 = '<script src="' . file_create_url('core/modules/system/tests/modules/common_test/deferred-internal.js') . '?v=1" defer bar="foo"></script>';
|
||||
$expected_2 = '<script src="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/deferred-internal.js')) . '?v=1" defer bar="foo"></script>';
|
||||
$this->assertNotIdentical(strpos($rendered_js, $expected_1), FALSE, 'Rendered external JavaScript with correct defer and random attributes.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, $expected_2), FALSE, 'Rendered internal JavaScript with correct defer and random attributes.');
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$rendered_footer_js = \Drupal::service('asset.js.collection_renderer')->render($footer_js);
|
||||
$this->assertEqual(2, count($rendered_footer_js), 'There are 2 JavaScript assets in the footer.');
|
||||
$this->assertEqual('drupal-settings-json', $rendered_footer_js[0]['#attributes']['data-drupal-selector'], 'The first of the two JavaScript assets in the footer has drupal settings.');
|
||||
$this->assertEqual('http://', substr($rendered_footer_js[1]['#attributes']['src'], 0, 7), 'The second of the two JavaScript assets in the footer has the sole aggregated JavaScript asset.');
|
||||
$this->assertEqual(0, strpos($rendered_footer_js[1]['#attributes']['src'], base_path()), 'The second of the two JavaScript assets in the footer has the sole aggregated JavaScript asset.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,9 +237,9 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
|
||||
$rendered_js = $this->renderer->renderPlain($js_render_array);
|
||||
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_create_url('core/modules/system/tests/modules/common_test/header.js') . '?' . $query_string . '"></script>'), FALSE, 'The JS asset in common_test/js-header appears in the header.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_create_url('core/misc/drupal.js')), FALSE, 'The JS asset of the direct dependency (core/drupal) of common_test/js-header appears in the header.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_create_url('core/assets/vendor/domready/ready.min.js')), FALSE, 'The JS asset of the indirect dependency (core/domready) of common_test/js-header appears in the header.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/header.js')) . '?' . $query_string . '"></script>'), FALSE, 'The JS asset in common_test/js-header appears in the header.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_url_transform_relative(file_create_url('core/misc/drupal.js'))), FALSE, 'The JS asset of the direct dependency (core/drupal) of common_test/js-header appears in the header.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . file_url_transform_relative(file_create_url('core/assets/vendor/domready/ready.min.js'))), FALSE, 'The JS asset of the indirect dependency (core/domready) of common_test/js-header appears in the header.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -267,8 +267,8 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$js = $this->assetResolver->getJsAssets($assets, FALSE)[1];
|
||||
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
|
||||
$rendered_js = $this->renderer->renderPlain($js_render_array);
|
||||
$expected_1 = "<!--[if lte IE 8]>\n" . '<script src="' . file_create_url('core/modules/system/tests/modules/common_test/old-ie.js') . '?' . $default_query_string . '"></script>' . "\n<![endif]-->";
|
||||
$expected_2 = "<!--[if !IE]><!-->\n" . '<script src="' . file_create_url('core/modules/system/tests/modules/common_test/no-ie.js') . '?' . $default_query_string . '"></script>' . "\n<!--<![endif]-->";
|
||||
$expected_1 = "<!--[if lte IE 8]>\n" . '<script src="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/old-ie.js')) . '?' . $default_query_string . '"></script>' . "\n<![endif]-->";
|
||||
$expected_2 = "<!--[if !IE]><!-->\n" . '<script src="' . file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/no-ie.js')) . '?' . $default_query_string . '"></script>' . "\n<!--<![endif]-->";
|
||||
|
||||
$this->assertNotIdentical(strpos($rendered_js, $expected_1), FALSE, 'Rendered JavaScript within downlevel-hidden conditional comments.');
|
||||
$this->assertNotIdentical(strpos($rendered_js, $expected_2), FALSE, 'Rendered JavaScript within downlevel-revealed conditional comments.');
|
||||
|
@ -476,8 +476,8 @@ class AttachedAssetsTest extends KernelTestBase {
|
|||
$js_render_array = \Drupal::service('asset.js.collection_renderer')->render($js);
|
||||
$rendered_js = $this->renderer->renderPlain($js_render_array);
|
||||
$query_string = $this->container->get('state')->get('system.css_js_query_string') ?: '0';
|
||||
$this->assertNotIdentical(strpos($rendered_css, '<link rel="stylesheet" href="' . str_replace('&', '&', file_create_url('core/modules/system/tests/modules/common_test/querystring.css?arg1=value1&arg2=value2')) . '&' . $query_string . '" media="all" />'), FALSE, 'CSS file with query string gets version query string correctly appended..');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . str_replace('&', '&', file_create_url('core/modules/system/tests/modules/common_test/querystring.js?arg1=value1&arg2=value2')) . '&' . $query_string . '"></script>'), FALSE, 'JavaScript file with query string gets version query string correctly appended.');
|
||||
$this->assertNotIdentical(strpos($rendered_css, '<link rel="stylesheet" href="' . str_replace('&', '&', file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/querystring.css?arg1=value1&arg2=value2'))) . '&' . $query_string . '" media="all" />'), FALSE, 'CSS file with query string gets version query string correctly appended..');
|
||||
$this->assertNotIdentical(strpos($rendered_js, '<script src="' . str_replace('&', '&', file_url_transform_relative(file_create_url('core/modules/system/tests/modules/common_test/querystring.js?arg1=value1&arg2=value2'))) . '&' . $query_string . '"></script>'), FALSE, 'JavaScript file with query string gets version query string correctly appended.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ namespace Drupal\system\Tests\Entity;
|
|||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\entity_test\Entity\EntityTestMulRev;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
|
||||
/**
|
||||
|
@ -810,4 +812,97 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if entity translation statuses are correct after removing two
|
||||
* translation.
|
||||
*/
|
||||
public function testDeleteEntityTranslation() {
|
||||
$entity_type = 'entity_test_mul';
|
||||
$controller = $this->entityManager->getStorage($entity_type);
|
||||
|
||||
// Create a translatable test field.
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'entity_type' => $entity_type,
|
||||
'field_name' => 'translatable_test_field',
|
||||
'type' => 'field_test',
|
||||
]);
|
||||
$field_storage->save();
|
||||
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $field_storage,
|
||||
'label' => $this->randomMachineName(),
|
||||
'bundle' => $entity_type,
|
||||
]);
|
||||
$field->save();
|
||||
|
||||
// Create an untranslatable test field.
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'entity_type' => $entity_type,
|
||||
'field_name' => 'untranslatable_test_field',
|
||||
'type' => 'field_test',
|
||||
'translatable' => FALSE,
|
||||
]);
|
||||
$field_storage->save();
|
||||
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $field_storage,
|
||||
'label' => $this->randomMachineName(),
|
||||
'bundle' => $entity_type,
|
||||
]);
|
||||
$field->save();
|
||||
|
||||
// Create an entity with both translatable and untranslatable test fields.
|
||||
$values = array(
|
||||
'name' => $this->randomString(),
|
||||
'translatable_test_field' => $this->randomString(),
|
||||
'untranslatable_test_field' => $this->randomString(),
|
||||
);
|
||||
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
$entity = $controller->create($values);
|
||||
|
||||
foreach ($this->langcodes as $langcode) {
|
||||
$entity->addTranslation($langcode, $values);
|
||||
}
|
||||
$entity->save();
|
||||
|
||||
// Assert there are no deleted languages in the lists yet.
|
||||
$this->assertNull(\Drupal::state()->get('entity_test.delete.translatable_test_field'));
|
||||
$this->assertNull(\Drupal::state()->get('entity_test.delete.untranslatable_test_field'));
|
||||
|
||||
// Remove the second and third langcodes from the entity.
|
||||
$entity->removeTranslation('l1');
|
||||
$entity->removeTranslation('l2');
|
||||
$entity->save();
|
||||
|
||||
// Ensure that for the translatable test field the second and third
|
||||
// langcodes are in the deleted languages list.
|
||||
$actual = \Drupal::state()->get('entity_test.delete.translatable_test_field');
|
||||
$expected_translatable = ['l1', 'l2'];
|
||||
sort($actual);
|
||||
sort($expected_translatable);
|
||||
$this->assertEqual($actual, $expected_translatable);
|
||||
// Ensure that the untranslatable test field is untouched.
|
||||
$this->assertNull(\Drupal::state()->get('entity_test.delete.untranslatable_test_field'));
|
||||
|
||||
// Delete the entity, which removes all remaining translations.
|
||||
$entity->delete();
|
||||
|
||||
// All languages have been deleted now.
|
||||
$actual = \Drupal::state()->get('entity_test.delete.translatable_test_field');
|
||||
$expected_translatable[] = 'en';
|
||||
$expected_translatable[] = 'l0';
|
||||
sort($actual);
|
||||
sort($expected_translatable);
|
||||
$this->assertEqual($actual, $expected_translatable);
|
||||
|
||||
// The untranslatable field is shared and only deleted once, for the
|
||||
// default langcode.
|
||||
$actual = \Drupal::state()->get('entity_test.delete.untranslatable_test_field');
|
||||
$expected_untranslatable = ['en'];
|
||||
sort($actual);
|
||||
sort($expected_untranslatable);
|
||||
$this->assertEqual($actual, $expected_untranslatable);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,6 +48,22 @@ class LocalActionTest extends WebTestBase {
|
|||
[Url::fromRoute('menu_test.local_action3'), 'My YAML discovery action'],
|
||||
[Url::fromRoute('menu_test.local_action5'), 'Title override'],
|
||||
]);
|
||||
// Test a local action title that changes based on a config value.
|
||||
$this->drupalGet(Url::fromRoute('menu_test.local_action6'));
|
||||
$this->assertLocalAction([
|
||||
[Url::fromRoute('menu_test.local_action5'), 'Original title'],
|
||||
]);
|
||||
// Verify the expected cache tag in the response headers.
|
||||
$header_values = explode(' ', $this->drupalGetHeader('x-drupal-cache-tags'));
|
||||
$this->assertTrue(in_array('config:menu_test.links.action', $header_values), "Found 'config:menu_test.links.action' cache tag in header");
|
||||
/** @var \Drupal\Core\Config\Config $config */
|
||||
$config = $this->container->get('config.factory')->getEditable('menu_test.links.action');
|
||||
$config->set('title', 'New title');
|
||||
$config->save();
|
||||
$this->drupalGet(Url::fromRoute('menu_test.local_action6'));
|
||||
$this->assertLocalAction([
|
||||
[Url::fromRoute('menu_test.local_action5'), 'New title'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ class AjaxPageStateTest extends WebTestBase {
|
|||
);
|
||||
$this->assertRaw(
|
||||
'/core/misc/drupalSettingsLoader.js',
|
||||
'The Dupalsettings library from core should be loaded.'
|
||||
'The drupalSettings library from core should be loaded.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ class AjaxPageStateTest extends WebTestBase {
|
|||
|
||||
$this->assertRaw(
|
||||
'/core/misc/drupalSettingsLoader.js',
|
||||
'The Dupalsettings library from core should be loaded.'
|
||||
'The drupalSettings library from core should be loaded.'
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ class AjaxPageStateTest extends WebTestBase {
|
|||
|
||||
$this->assertNoRaw(
|
||||
'/core/misc/drupalSettingsLoader.js',
|
||||
'The Dupalsettings library from core should be excluded from loading.'
|
||||
'The drupalSettings library from core should be excluded from loading.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,6 +109,10 @@ class CronRunTest extends WebTestBase {
|
|||
// fail randomly. Look for the word 'years', because without a timestamp,
|
||||
// the time will start at 1 January 1970.
|
||||
$this->assertNoText('years');
|
||||
|
||||
$this->drupalPostForm(NULL, [], t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
$this->assertUrl('admin/config/system/cron');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -86,6 +86,11 @@ class HtaccessTest extends WebTestBase {
|
|||
foreach ($file_exts_to_allow as $file_ext) {
|
||||
$file_paths["$path/access_test.$file_ext"] = 200;
|
||||
}
|
||||
|
||||
// Ensure composer.json and composer.lock cannot be accessed.
|
||||
$file_paths["$path/composer.json"] = 403;
|
||||
$file_paths["$path/composer.lock"] = 403;
|
||||
|
||||
return $file_paths;
|
||||
}
|
||||
|
||||
|
|
|
@ -65,27 +65,27 @@ class ThemeTest extends WebTestBase {
|
|||
// Raw stream wrapper URI.
|
||||
$file->uri => array(
|
||||
'form' => file_uri_target($file->uri),
|
||||
'src' => file_create_url($file->uri),
|
||||
'src' => file_url_transform_relative(file_create_url($file->uri)),
|
||||
),
|
||||
// Relative path within the public filesystem.
|
||||
file_uri_target($file->uri) => array(
|
||||
'form' => file_uri_target($file->uri),
|
||||
'src' => file_create_url($file->uri),
|
||||
'src' => file_url_transform_relative(file_create_url($file->uri)),
|
||||
),
|
||||
// Relative path to a public file.
|
||||
$file_relative => array(
|
||||
'form' => $file_relative,
|
||||
'src' => file_create_url($file->uri),
|
||||
'src' => file_url_transform_relative(file_create_url($file->uri)),
|
||||
),
|
||||
// Relative path to an arbitrary file.
|
||||
'core/misc/druplicon.png' => array(
|
||||
'form' => 'core/misc/druplicon.png',
|
||||
'src' => $GLOBALS['base_url'] . '/' . 'core/misc/druplicon.png',
|
||||
'src' => base_path() . 'core/misc/druplicon.png',
|
||||
),
|
||||
// Relative path to a file in a theme.
|
||||
$default_theme_path . '/logo.svg' => array(
|
||||
'form' => $default_theme_path . '/logo.svg',
|
||||
'src' => $GLOBALS['base_url'] . '/' . $default_theme_path . '/logo.svg',
|
||||
'src' => base_path() . $default_theme_path . '/logo.svg',
|
||||
),
|
||||
);
|
||||
foreach ($supported_paths as $input => $expected) {
|
||||
|
@ -186,7 +186,7 @@ class ThemeTest extends WebTestBase {
|
|||
':rel' => 'home',
|
||||
)
|
||||
);
|
||||
$this->assertEqual($elements[0]['src'], file_create_url($uploaded_filename));
|
||||
$this->assertEqual($elements[0]['src'], file_url_transform_relative(file_create_url($uploaded_filename)));
|
||||
|
||||
$this->container->get('theme_handler')->install(array('bartik'));
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ class EngineTwigTest extends WebTestBase {
|
|||
*/
|
||||
public function testTwigFileUrls() {
|
||||
$this->drupalGet('/twig-theme-test/file-url');
|
||||
$filepath = file_create_url('core/modules/system/tests/modules/twig_theme_test/twig_theme_test.js');
|
||||
$filepath = file_url_transform_relative(file_create_url('core/modules/system/tests/modules/twig_theme_test/twig_theme_test.js'));
|
||||
$this->assertRaw('<div>file_url: ' . $filepath . '</div>');
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\system\Tests\Theme;
|
||||
|
||||
use Drupal\simpletest\KernelTestBase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Tests built-in image theme functions.
|
||||
|
@ -32,9 +33,17 @@ class ImageTest extends KernelTestBase {
|
|||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// The code under test uses file_url_transform_relative(), which relies on
|
||||
// the Request containing the correct hostname. KernelTestBase doesn't set
|
||||
// it, so push another request onto the stack to ensure it's correct.
|
||||
$request = Request::create('/', 'GET', [], [], [], $_SERVER);
|
||||
$this->container = $this->kernel->getContainer();
|
||||
$this->container->get('request_stack')->push($request);
|
||||
|
||||
$this->testImages = array(
|
||||
'/core/misc/druplicon.png',
|
||||
'/core/misc/loading.gif',
|
||||
'core/misc/druplicon.png',
|
||||
'core/misc/loading.gif',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -75,7 +84,7 @@ class ImageTest extends KernelTestBase {
|
|||
$this->render($image);
|
||||
|
||||
// Make sure the src attribute has the correct value.
|
||||
$this->assertRaw(file_create_url($image['#uri']), 'Correct output for an image with the src attribute.');
|
||||
$this->assertRaw(file_url_transform_relative(file_create_url($image['#uri'])), 'Correct output for an image with the src attribute.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -103,7 +112,7 @@ class ImageTest extends KernelTestBase {
|
|||
$this->render($image);
|
||||
|
||||
// Make sure the srcset attribute has the correct value.
|
||||
$this->assertRaw(file_create_url($this->testImages[0]) . ' 1x, ' . file_create_url($this->testImages[1]) . ' 2x', 'Correct output for image with srcset attribute and multipliers.');
|
||||
$this->assertRaw(file_url_transform_relative(file_create_url($this->testImages[0])) . ' 1x, ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' 2x', 'Correct output for image with srcset attribute and multipliers.');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -135,7 +144,7 @@ class ImageTest extends KernelTestBase {
|
|||
$this->render($image);
|
||||
|
||||
// Make sure the srcset attribute has the correct value.
|
||||
$this->assertRaw(file_create_url($this->testImages[0]) . ' ' . $widths[0] . ', ' . file_create_url($this->testImages[1]) . ' ' . $widths[1], 'Correct output for image with srcset attribute and width descriptors.');
|
||||
$this->assertRaw(file_url_transform_relative(file_create_url($this->testImages[0])) . ' ' . $widths[0] . ', ' . file_url_transform_relative(file_create_url($this->testImages[1])) . ' ' . $widths[1], 'Correct output for image with srcset attribute and width descriptors.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,9 @@ class UpdatePathTestJavaScriptTest extends UpdatePathTestBase {
|
|||
if (!isset($script['src'])) {
|
||||
continue;
|
||||
}
|
||||
$src = (string) $script['src'];
|
||||
// Source is a root-relative URL. Transform it to an absolute URL to allow
|
||||
// file_get_contents() to access the file.
|
||||
$src = preg_replace('#^' . $GLOBALS['base_path'] . '(.*)#i', $GLOBALS['base_url'] . '/' . '${1}', (string) $script['src']);
|
||||
$file_content = file_get_contents($src);
|
||||
|
||||
if (strpos($file_content, 'window.drupalSettings =') !== FALSE) {
|
||||
|
|
0
core/modules/system/tests/fixtures/HtaccessTest/composer.json
vendored
Normal file
0
core/modules/system/tests/fixtures/HtaccessTest/composer.json
vendored
Normal file
0
core/modules/system/tests/fixtures/HtaccessTest/composer.lock
generated
vendored
Normal file
0
core/modules/system/tests/fixtures/HtaccessTest/composer.lock
generated
vendored
Normal file
|
@ -50,9 +50,8 @@ class AjaxTestController {
|
|||
/**
|
||||
* Returns a render array that will be rendered by AjaxRenderer.
|
||||
*
|
||||
* Ensures that \Drupal\Core\Ajax\AjaxResponse::ajaxRender()
|
||||
* incorporates JavaScript settings generated during the page request by
|
||||
* adding a dummy setting.
|
||||
* Verifies that the response incorporates JavaScript settings generated
|
||||
* during the page request by adding a dummy setting.
|
||||
*/
|
||||
public function render() {
|
||||
return [
|
||||
|
|
|
@ -115,4 +115,14 @@ class FieldTestItem extends FieldItemBase {
|
|||
return $this->getValue()['value'] == 'resave';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete() {
|
||||
parent::delete();
|
||||
$deleted_languages = \Drupal::state()->get('entity_test.delete.' . $this->getFieldDefinition()->getName()) ?: [];
|
||||
$deleted_languages[] = $this->getLangcode();
|
||||
\Drupal::state()->set('entity_test.delete.' . $this->getFieldDefinition()->getName(), $deleted_languages);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
title: 'Original title'
|
|
@ -7,3 +7,10 @@ menu_test.menu_item:
|
|||
title:
|
||||
type: label
|
||||
label: 'Title'
|
||||
menu_test.links.action:
|
||||
type: config_object
|
||||
label: 'Menu test local action'
|
||||
mapping:
|
||||
title:
|
||||
type: label
|
||||
label: 'Title'
|
||||
|
|
|
@ -11,6 +11,12 @@ menu_test.local_action5:
|
|||
appears_on:
|
||||
- menu_test.local_action1
|
||||
|
||||
menu_test.local_action.cache_check:
|
||||
route_name: menu_test.local_action5
|
||||
class: '\Drupal\menu_test\Plugin\Menu\LocalAction\TestLocalActionWithConfig'
|
||||
appears_on:
|
||||
- menu_test.local_action6
|
||||
|
||||
menu_test.local_action2:
|
||||
route_name: menu_test.local_action2
|
||||
title: 'My hook_menu action'
|
||||
|
|
|
@ -118,6 +118,13 @@ menu_test.local_action5:
|
|||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
menu_test.local_action6:
|
||||
path: '/menu-test-local-action/cache-check'
|
||||
defaults:
|
||||
_controller: '\Drupal\menu_test\TestControllers::test2'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
menu_test.contextual_test:
|
||||
path: '/menu-test-contextual/default'
|
||||
defaults:
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\menu_test\Plugin\Menu\LocalAction\TestLocalActionWithConfig.
|
||||
*/
|
||||
|
||||
namespace Drupal\menu_test\Plugin\Menu\LocalAction;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Cache\CacheableDependencyInterface;
|
||||
use Drupal\Core\Config\Config;
|
||||
use Drupal\Core\Menu\LocalActionDefault;
|
||||
use Drupal\Core\Routing\RouteProviderInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Defines a test local action plugin class that has cache tags.
|
||||
*/
|
||||
class TestLocalActionWithConfig extends LocalActionDefault implements CacheableDependencyInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheContexts() {
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheTags() {
|
||||
return ['config:menu_test.links.action'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCacheMaxAge() {
|
||||
return Cache::PERMANENT;
|
||||
}
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Config\Config
|
||||
*/
|
||||
protected $config;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTitle() {
|
||||
return $this->config->get('title');
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a TestLocalActionWithConfig object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
|
||||
* The route provider to load routes by name.
|
||||
* @param \Drupal\Core\Config\Config $config
|
||||
* The 'menu_test.links.action' config.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, RouteProviderInterface $route_provider, Config $config) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $route_provider);
|
||||
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$container->get('router.route_provider'),
|
||||
$container->get('config.factory')->get('menu_test.links.action')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -341,4 +341,16 @@ class SystemTestController extends ControllerBase {
|
|||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current date.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response $response
|
||||
* A Response object containing the current date.
|
||||
*/
|
||||
public function getCurrentDate() {
|
||||
// Uses specific time to test that the right timezone is used.
|
||||
$response = new Response(\Drupal::service('date.formatter')->format(1452702549));
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -150,3 +150,12 @@ system_test.respond_cacheable_response:
|
|||
_controller: '\Drupal\system_test\Controller\SystemTestController::respondWithCacheableReponse'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
system_test.date:
|
||||
path: '/system-test/date'
|
||||
defaults:
|
||||
_controller: '\Drupal\system_test\Controller\SystemTestController::getCurrentDate'
|
||||
options:
|
||||
no_cache: 'TRUE'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
Reference in a new issue