Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -27,26 +27,26 @@ function contextual_toolbar() {
|
|||
return $items;
|
||||
}
|
||||
|
||||
$items['contextual'] += array(
|
||||
$items['contextual'] += [
|
||||
'#type' => 'toolbar_item',
|
||||
'tab' => array(
|
||||
'tab' => [
|
||||
'#type' => 'html_tag',
|
||||
'#tag' => 'button',
|
||||
'#value' => t('Edit'),
|
||||
'#attributes' => array(
|
||||
'class' => array('toolbar-icon', 'toolbar-icon-edit'),
|
||||
'#attributes' => [
|
||||
'class' => ['toolbar-icon', 'toolbar-icon-edit'],
|
||||
'aria-pressed' => 'false',
|
||||
),
|
||||
),
|
||||
'#wrapper_attributes' => array(
|
||||
'class' => array('hidden', 'contextual-toolbar-tab'),
|
||||
),
|
||||
'#attached' => array(
|
||||
'library' => array(
|
||||
],
|
||||
],
|
||||
'#wrapper_attributes' => [
|
||||
'class' => ['hidden', 'contextual-toolbar-tab'],
|
||||
],
|
||||
'#attached' => [
|
||||
'library' => [
|
||||
'contextual/drupal.contextual-toolbar',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ function contextual_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.contextual':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Contextual links module gives users with the <em>Use contextual links</em> permission quick access to tasks associated with certain areas of pages on your site. For example, a menu displayed as a block has links to edit the menu and configure the block. For more information, see the <a href=":contextual">online documentation for the Contextual Links module</a>.', array(':contextual' => 'https://www.drupal.org/documentation/modules/contextual')) . '</p>';
|
||||
$output .= '<p>' . t('The Contextual links module gives users with the <em>Use contextual links</em> permission quick access to tasks associated with certain areas of pages on your site. For example, a menu displayed as a block has links to edit the menu and configure the block. For more information, see the <a href=":contextual">online documentation for the Contextual Links module</a>.', [':contextual' => 'https://www.drupal.org/documentation/modules/contextual']) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl>';
|
||||
$output .= '<dt>' . t('Displaying contextual links') . '</dt>';
|
||||
|
@ -88,8 +88,8 @@ function contextual_help($route_name, RouteMatchInterface $route_match) {
|
|||
'#alt' => t('contextual links button')
|
||||
];
|
||||
$sample_picture = \Drupal::service('renderer')->render($sample_picture);
|
||||
$output .= '<li>' . t('Hovering over the area of interest will temporarily make the contextual links button visible (which looks like a pencil in most themes, and is normally displayed in the upper right corner of the area). The icon typically looks like this: @picture', array('@picture' => $sample_picture)) . '</li>';
|
||||
$output .= '<li>' . t('If you have the <a href=":toolbar">Toolbar module</a> enabled, clicking the contextual links button in the toolbar (which looks like a pencil) will make all contextual links buttons on the page visible. Clicking this button again will toggle them to invisible.', array(':toolbar' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', array('name' => 'toolbar')) : '#')) . '</li>';
|
||||
$output .= '<li>' . t('Hovering over the area of interest will temporarily make the contextual links button visible (which looks like a pencil in most themes, and is normally displayed in the upper right corner of the area). The icon typically looks like this: @picture', ['@picture' => $sample_picture]) . '</li>';
|
||||
$output .= '<li>' . t('If you have the <a href=":toolbar">Toolbar module</a> enabled, clicking the contextual links button in the toolbar (which looks like a pencil) will make all contextual links buttons on the page visible. Clicking this button again will toggle them to invisible.', [':toolbar' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', ['name' => 'toolbar']) : '#']) . '</li>';
|
||||
$output .= '</ol>';
|
||||
$output .= t('Once the contextual links button for the area of interest is visible, click the button to display the links.');
|
||||
$output .= '</dd>';
|
||||
|
@ -132,10 +132,10 @@ function contextual_preprocess(&$variables, $hook, $info) {
|
|||
// users, contextual_page_attachments() only adds the asset library for
|
||||
// users with the 'access contextual links' permission, thus preventing
|
||||
// unnecessary HTTP requests for users without that permission.
|
||||
$variables['title_suffix']['contextual_links'] = array(
|
||||
$variables['title_suffix']['contextual_links'] = [
|
||||
'#type' => 'contextual_links_placeholder',
|
||||
'#id' => _contextual_links_to_id($element['#contextual_links']),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ function contextual_contextual_links_view_alter(&$element, $items) {
|
|||
* use in a data- attribute.
|
||||
*/
|
||||
function _contextual_links_to_id($contextual_links) {
|
||||
$ids = array();
|
||||
$ids = [];
|
||||
$langcode = \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_URL)->getId();
|
||||
foreach ($contextual_links as $group => $args) {
|
||||
$route_parameters = UrlHelper::buildQuery($args['route_parameters']);
|
||||
|
@ -199,17 +199,17 @@ function _contextual_links_to_id($contextual_links) {
|
|||
* The value for a #contextual_links property.
|
||||
*/
|
||||
function _contextual_id_to_links($id) {
|
||||
$contextual_links = array();
|
||||
$contextual_links = [];
|
||||
$contexts = explode('|', $id);
|
||||
foreach ($contexts as $context) {
|
||||
list($group, $route_parameters_raw, $metadata_raw) = explode(':', $context);
|
||||
parse_str($route_parameters_raw, $route_parameters);
|
||||
$metadata = array();
|
||||
$metadata = [];
|
||||
parse_str($metadata_raw, $metadata);
|
||||
$contextual_links[$group] = array(
|
||||
$contextual_links[$group] = [
|
||||
'route_parameters' => $route_parameters,
|
||||
'metadata' => $metadata,
|
||||
);
|
||||
];
|
||||
}
|
||||
return $contextual_links;
|
||||
}
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function contextual_views_data_alter(&$data) {
|
||||
$data['views']['contextual_links'] = array(
|
||||
$data['views']['contextual_links'] = [
|
||||
'title' => t('Contextual Links'),
|
||||
'help' => t('Display fields in a contextual links menu.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'contextual_links',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@
|
|||
// Update all contextual links placeholders whose HTML is cached.
|
||||
var uncachedIDs = _.filter(ids, function initIfCached(contextualID) {
|
||||
var html = storage.getItem('Drupal.contextual.' + contextualID);
|
||||
if (html !== null) {
|
||||
if (html && html.length) {
|
||||
// Initialize after the current execution cycle, to make the AJAX
|
||||
// request for retrieving the uncached contextual links as soon as
|
||||
// possible, but also to ensure that other Drupal behaviors have had
|
||||
|
|
|
@ -32,12 +32,12 @@ class ContextualController implements ContainerAwareInterface {
|
|||
throw new BadRequestHttpException(t('No contextual ids specified.'));
|
||||
}
|
||||
|
||||
$rendered = array();
|
||||
$rendered = [];
|
||||
foreach ($ids as $id) {
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'contextual_links',
|
||||
'#contextual_links' => _contextual_id_to_links($id),
|
||||
);
|
||||
];
|
||||
$rendered[$id] = $this->container->get('renderer')->renderRoot($element);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,19 +18,19 @@ class ContextualLinks extends RenderElement {
|
|||
*/
|
||||
public function getInfo() {
|
||||
$class = get_class($this);
|
||||
return array(
|
||||
'#pre_render' => array(
|
||||
array($class, 'preRenderLinks'),
|
||||
),
|
||||
return [
|
||||
'#pre_render' => [
|
||||
[$class, 'preRenderLinks'],
|
||||
],
|
||||
'#theme' => 'links__contextual',
|
||||
'#links' => array(),
|
||||
'#attributes' => array('class' => array('contextual-links')),
|
||||
'#attached' => array(
|
||||
'library' => array(
|
||||
'#links' => [],
|
||||
'#attributes' => ['class' => ['contextual-links']],
|
||||
'#attached' => [
|
||||
'library' => [
|
||||
'contextual/drupal.contextual-links',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -60,26 +60,26 @@ class ContextualLinks extends RenderElement {
|
|||
*/
|
||||
public static function preRenderLinks(array $element) {
|
||||
// Retrieve contextual menu links.
|
||||
$items = array();
|
||||
$items = [];
|
||||
|
||||
$contextual_links_manager = static::contextualLinkManager();
|
||||
|
||||
foreach ($element['#contextual_links'] as $group => $args) {
|
||||
$args += array(
|
||||
'route_parameters' => array(),
|
||||
'metadata' => array(),
|
||||
);
|
||||
$args += [
|
||||
'route_parameters' => [],
|
||||
'metadata' => [],
|
||||
];
|
||||
$items += $contextual_links_manager->getContextualLinksArrayByGroup($group, $args['route_parameters'], $args['metadata']);
|
||||
}
|
||||
|
||||
// Transform contextual links into parameters suitable for links.html.twig.
|
||||
$links = array();
|
||||
$links = [];
|
||||
foreach ($items as $class => $item) {
|
||||
$class = Html::getClass($class);
|
||||
$links[$class] = array(
|
||||
$links[$class] = [
|
||||
'title' => $item['title'],
|
||||
'url' => Url::fromRoute(isset($item['route_name']) ? $item['route_name'] : '', isset($item['route_parameters']) ? $item['route_parameters'] : []),
|
||||
);
|
||||
];
|
||||
}
|
||||
$element['#links'] = $links;
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ class ContextualLinksPlaceholder extends RenderElement {
|
|||
*/
|
||||
public function getInfo() {
|
||||
$class = get_class($this);
|
||||
return array(
|
||||
'#pre_render' => array(
|
||||
array($class, 'preRenderPlaceholder'),
|
||||
),
|
||||
return [
|
||||
'#pre_render' => [
|
||||
[$class, 'preRenderPlaceholder'],
|
||||
],
|
||||
'#id' => NULL,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -35,8 +35,8 @@ class ContextualLinks extends FieldPluginBase {
|
|||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
|
||||
$options['fields'] = array('default' => array());
|
||||
$options['destination'] = array('default' => 1);
|
||||
$options['fields'] = ['default' => []];
|
||||
$options['destination'] = ['default' => 1];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -48,23 +48,23 @@ class ContextualLinks extends FieldPluginBase {
|
|||
$all_fields = $this->view->display_handler->getFieldLabels();
|
||||
// Offer to include only those fields that follow this one.
|
||||
$field_options = array_slice($all_fields, 0, array_search($this->options['id'], array_keys($all_fields)));
|
||||
$form['fields'] = array(
|
||||
$form['fields'] = [
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => $this->t('Fields'),
|
||||
'#description' => $this->t('Fields to be included as contextual links.'),
|
||||
'#options' => $field_options,
|
||||
'#default_value' => $this->options['fields'],
|
||||
);
|
||||
$form['destination'] = array(
|
||||
];
|
||||
$form['destination'] = [
|
||||
'#type' => 'select',
|
||||
'#title' => $this->t('Include destination'),
|
||||
'#description' => $this->t('Include a "destination" parameter in the link to return the user to the original view upon completing the contextual action.'),
|
||||
'#options' => array(
|
||||
'#options' => [
|
||||
'0' => $this->t('No'),
|
||||
'1' => $this->t('Yes'),
|
||||
),
|
||||
],
|
||||
'#default_value' => $this->options['destination'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -93,7 +93,7 @@ class ContextualLinks extends FieldPluginBase {
|
|||
* @see contextual_contextual_links_view_alter()
|
||||
*/
|
||||
public function render(ResultRow $values) {
|
||||
$links = array();
|
||||
$links = [];
|
||||
foreach ($this->options['fields'] as $field) {
|
||||
$rendered_field = $this->view->style_plugin->getField($values->index, $field);
|
||||
if (empty($rendered_field)) {
|
||||
|
@ -109,13 +109,13 @@ class ContextualLinks extends FieldPluginBase {
|
|||
}
|
||||
if (!empty($title) && !empty($path)) {
|
||||
// Make sure that tokens are replaced for this paths as well.
|
||||
$tokens = $this->getRenderTokens(array());
|
||||
$tokens = $this->getRenderTokens([]);
|
||||
$path = strip_tags(Html::decodeEntities(strtr($path, $tokens)));
|
||||
|
||||
$links[$field] = array(
|
||||
$links[$field] = [
|
||||
'href' => $path,
|
||||
'title' => $title,
|
||||
);
|
||||
];
|
||||
if (!empty($this->options['destination'])) {
|
||||
$links[$field]['query'] = $this->getDestinationArray();
|
||||
}
|
||||
|
@ -124,20 +124,20 @@ class ContextualLinks extends FieldPluginBase {
|
|||
|
||||
// Renders a contextual links placeholder.
|
||||
if (!empty($links)) {
|
||||
$contextual_links = array(
|
||||
'contextual' => array(
|
||||
$contextual_links = [
|
||||
'contextual' => [
|
||||
'',
|
||||
array(),
|
||||
array(
|
||||
[],
|
||||
[
|
||||
'contextual-views-field-links' => UrlHelper::encodePath(Json::encode($links)),
|
||||
)
|
||||
)
|
||||
);
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
$element = array(
|
||||
$element = [
|
||||
'#type' => 'contextual_links_placeholder',
|
||||
'#id' => _contextual_links_to_id($contextual_links),
|
||||
);
|
||||
];
|
||||
return drupal_render($element);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -42,20 +42,20 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contextual', 'node', 'views', 'views_ui', 'language', 'menu_test');
|
||||
public static $modules = ['contextual', 'node', 'views', 'views_ui', 'language', 'menu_test'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
|
||||
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
|
||||
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
|
||||
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
|
||||
|
||||
ConfigurableLanguage::createFromLangcode('it')->save();
|
||||
$this->rebuildContainer();
|
||||
|
||||
$this->editorUser = $this->drupalCreateUser(array('access content', 'access contextual links', 'edit any article content'));
|
||||
$this->authenticatedUser = $this->drupalCreateUser(array('access content', 'access contextual links'));
|
||||
$this->anonymousUser = $this->drupalCreateUser(array('access content'));
|
||||
$this->editorUser = $this->drupalCreateUser(['access content', 'access contextual links', 'edit any article content']);
|
||||
$this->authenticatedUser = $this->drupalCreateUser(['access content', 'access contextual links']);
|
||||
$this->anonymousUser = $this->drupalCreateUser(['access content']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -64,16 +64,16 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
* Ensures that contextual link placeholders always exist, even if the user is
|
||||
* not allowed to use contextual links.
|
||||
*/
|
||||
function testDifferentPermissions() {
|
||||
public function testDifferentPermissions() {
|
||||
$this->drupalLogin($this->editorUser);
|
||||
|
||||
// Create three nodes in the following order:
|
||||
// - An article, which should be user-editable.
|
||||
// - A page, which should not be user-editable.
|
||||
// - A second article, which should also be user-editable.
|
||||
$node1 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
|
||||
$node2 = $this->drupalCreateNode(array('type' => 'page', 'promote' => 1));
|
||||
$node3 = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
|
||||
$node1 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
|
||||
$node2 = $this->drupalCreateNode(['type' => 'page', 'promote' => 1]);
|
||||
$node3 = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
|
||||
|
||||
// Now, on the front page, all article nodes should have contextual links
|
||||
// placeholders, as should the view that contains them.
|
||||
|
@ -89,7 +89,7 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
for ($i = 0; $i < count($ids); $i++) {
|
||||
$this->assertContextualLinkPlaceHolder($ids[$i]);
|
||||
}
|
||||
$this->renderContextualLinks(array(), 'node');
|
||||
$this->renderContextualLinks([], 'node');
|
||||
$this->assertResponse(400);
|
||||
$this->assertRaw('No contextual ids specified.');
|
||||
$response = $this->renderContextualLinks($ids, 'node');
|
||||
|
@ -112,7 +112,7 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
for ($i = 0; $i < count($ids); $i++) {
|
||||
$this->assertContextualLinkPlaceHolder($ids[$i]);
|
||||
}
|
||||
$this->renderContextualLinks(array(), 'node');
|
||||
$this->renderContextualLinks([], 'node');
|
||||
$this->assertResponse(400);
|
||||
$this->assertRaw('No contextual ids specified.');
|
||||
$response = $this->renderContextualLinks($ids, 'node');
|
||||
|
@ -129,7 +129,7 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
for ($i = 0; $i < count($ids); $i++) {
|
||||
$this->assertNoContextualLinkPlaceHolder($ids[$i]);
|
||||
}
|
||||
$this->renderContextualLinks(array(), 'node');
|
||||
$this->renderContextualLinks([], 'node');
|
||||
$this->assertResponse(403);
|
||||
$this->renderContextualLinks($ids, 'node');
|
||||
$this->assertResponse(403);
|
||||
|
@ -150,7 +150,7 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
* The result of the assertion.
|
||||
*/
|
||||
protected function assertContextualLinkPlaceHolder($id) {
|
||||
return $this->assertRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id exists.', array('@id' => $id)));
|
||||
return $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -163,7 +163,7 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
* The result of the assertion.
|
||||
*/
|
||||
protected function assertNoContextualLinkPlaceHolder($id) {
|
||||
return $this->assertNoRaw('<div' . new Attribute(array('data-contextual-id' => $id)) . '></div>', format_string('Contextual link placeholder with id @id does not exist.', array('@id' => $id)));
|
||||
return $this->assertNoRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id does not exist.', ['@id' => $id]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -178,11 +178,11 @@ class ContextualDynamicContextTest extends WebTestBase {
|
|||
* The response body.
|
||||
*/
|
||||
protected function renderContextualLinks($ids, $current_path) {
|
||||
$post = array();
|
||||
$post = [];
|
||||
for ($i = 0; $i < count($ids); $i++) {
|
||||
$post['ids[' . $i . ']'] = $ids[$i];
|
||||
}
|
||||
return $this->drupalPostWithFormat('contextual/render', 'json', $post, array('query' => array('destination' => $current_path)));
|
||||
return $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => $current_path]]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\contextual\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
|
||||
/**
|
||||
* Tests the UI for correct contextual links.
|
||||
*
|
||||
* @group contextual
|
||||
*/
|
||||
class ContextualLinksTest extends JavascriptTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['block', 'contextual'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->placeBlock('system_branding_block', ['id' => 'branding']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the visibility of contextual links.
|
||||
*/
|
||||
public function testContextualLinksVisibility() {
|
||||
$this->drupalLogin($this->drupalCreateUser([
|
||||
'access contextual links'
|
||||
]));
|
||||
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertEmpty($contextualLinks);
|
||||
|
||||
// Ensure visibility remains correct after cached paged load.
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertEmpty($contextualLinks);
|
||||
|
||||
// Grant permissions to use contextual links on blocks.
|
||||
$this->grantPermissions(Role::load(Role::AUTHENTICATED_ID), [
|
||||
'access contextual links',
|
||||
'administer blocks',
|
||||
]);
|
||||
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertNotEmpty($contextualLinks);
|
||||
|
||||
// Ensure visibility remains correct after cached paged load.
|
||||
$this->drupalGet('user');
|
||||
$contextualLinks = $this->assertSession()->waitForElement('css', '.contextual button');
|
||||
$this->assertNotEmpty($contextualLinks);
|
||||
}
|
||||
|
||||
}
|
|
@ -17,92 +17,92 @@ class ContextualUnitTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('contextual');
|
||||
public static $modules = ['contextual'];
|
||||
|
||||
/**
|
||||
* Provides testcases for testContextualLinksToId() and
|
||||
*/
|
||||
function _contextual_links_id_testcases() {
|
||||
public function _contextual_links_id_testcases() {
|
||||
// Test branch conditions:
|
||||
// - one group.
|
||||
// - one dynamic path argument.
|
||||
// - no metadata.
|
||||
$tests[] = array(
|
||||
'links' => array(
|
||||
'node' => array(
|
||||
'route_parameters' => array(
|
||||
$tests[] = [
|
||||
'links' => [
|
||||
'node' => [
|
||||
'route_parameters' => [
|
||||
'node' => '14031991',
|
||||
),
|
||||
'metadata' => array('langcode' => 'en'),
|
||||
),
|
||||
),
|
||||
],
|
||||
'metadata' => ['langcode' => 'en'],
|
||||
],
|
||||
],
|
||||
'id' => 'node:node=14031991:langcode=en',
|
||||
);
|
||||
];
|
||||
|
||||
// Test branch conditions:
|
||||
// - one group.
|
||||
// - multiple dynamic path arguments.
|
||||
// - no metadata.
|
||||
$tests[] = array(
|
||||
'links' => array(
|
||||
'foo' => array(
|
||||
'route_parameters' => array(
|
||||
$tests[] = [
|
||||
'links' => [
|
||||
'foo' => [
|
||||
'route_parameters' => [
|
||||
'bar',
|
||||
'key' => 'baz',
|
||||
'qux',
|
||||
),
|
||||
'metadata' => array('langcode' => 'en'),
|
||||
),
|
||||
),
|
||||
],
|
||||
'metadata' => ['langcode' => 'en'],
|
||||
],
|
||||
],
|
||||
'id' => 'foo:0=bar&key=baz&1=qux:langcode=en',
|
||||
);
|
||||
];
|
||||
|
||||
// Test branch conditions:
|
||||
// - one group.
|
||||
// - one dynamic path argument.
|
||||
// - metadata.
|
||||
$tests[] = array(
|
||||
'links' => array(
|
||||
'views_ui_edit' => array(
|
||||
'route_parameters' => array(
|
||||
$tests[] = [
|
||||
'links' => [
|
||||
'views_ui_edit' => [
|
||||
'route_parameters' => [
|
||||
'view' => 'frontpage'
|
||||
),
|
||||
'metadata' => array(
|
||||
],
|
||||
'metadata' => [
|
||||
'location' => 'page',
|
||||
'display' => 'page_1',
|
||||
'langcode' => 'en',
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
],
|
||||
'id' => 'views_ui_edit:view=frontpage:location=page&display=page_1&langcode=en',
|
||||
);
|
||||
];
|
||||
|
||||
// Test branch conditions:
|
||||
// - multiple groups.
|
||||
// - multiple dynamic path arguments.
|
||||
$tests[] = array(
|
||||
'links' => array(
|
||||
'node' => array(
|
||||
'route_parameters' => array(
|
||||
$tests[] = [
|
||||
'links' => [
|
||||
'node' => [
|
||||
'route_parameters' => [
|
||||
'node' => '14031991',
|
||||
),
|
||||
'metadata' => array('langcode' => 'en'),
|
||||
),
|
||||
'foo' => array(
|
||||
'route_parameters' => array(
|
||||
],
|
||||
'metadata' => ['langcode' => 'en'],
|
||||
],
|
||||
'foo' => [
|
||||
'route_parameters' => [
|
||||
'bar',
|
||||
'key' => 'baz',
|
||||
'qux',
|
||||
),
|
||||
'metadata' => array('langcode' => 'en'),
|
||||
),
|
||||
'edge' => array(
|
||||
'route_parameters' => array('20011988'),
|
||||
'metadata' => array('langcode' => 'en'),
|
||||
),
|
||||
),
|
||||
],
|
||||
'metadata' => ['langcode' => 'en'],
|
||||
],
|
||||
'edge' => [
|
||||
'route_parameters' => ['20011988'],
|
||||
'metadata' => ['langcode' => 'en'],
|
||||
],
|
||||
],
|
||||
'id' => 'node:node=14031991:langcode=en|foo:0=bar&key=baz&1=qux:langcode=en|edge:0=20011988:langcode=en',
|
||||
);
|
||||
];
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ class ContextualUnitTest extends KernelTestBase {
|
|||
/**
|
||||
* Tests _contextual_links_to_id().
|
||||
*/
|
||||
function testContextualLinksToId() {
|
||||
public function testContextualLinksToId() {
|
||||
$tests = $this->_contextual_links_id_testcases();
|
||||
foreach ($tests as $test) {
|
||||
$this->assertIdentical(_contextual_links_to_id($test['links']), $test['id']);
|
||||
|
@ -120,7 +120,7 @@ class ContextualUnitTest extends KernelTestBase {
|
|||
/**
|
||||
* Tests _contextual_id_to_links().
|
||||
*/
|
||||
function testContextualIdToLinks() {
|
||||
public function testContextualIdToLinks() {
|
||||
$tests = $this->_contextual_links_id_testcases();
|
||||
foreach ($tests as $test) {
|
||||
$this->assertIdentical(_contextual_id_to_links($test['id']), $test['links']);
|
||||
|
|
Reference in a new issue