Update to Drupal 8.2.4. For more information, see https://www.drupal.org/project/drupal/releases/8.2.4

This commit is contained in:
Pantheon Automation 2016-12-07 12:19:38 -08:00 committed by Greg Anderson
parent 0a95b8440e
commit 8544b60b39
284 changed files with 12980 additions and 3199 deletions

View file

@ -21,6 +21,8 @@ display:
display_options:
access:
type: perm
options:
perm: 'access content overview'
cache:
type: tag
query:
@ -159,6 +161,108 @@ display:
hide_empty: false
empty_zero: false
hide_alter_empty: false
edit_node:
id: edit_node
table: node
field: edit_node
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: true
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: edit
entity_type: node
plugin_id: entity_link_edit
delete_node:
id: delete_node
table: node
field: delete_node
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: true
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: delete
entity_type: node
plugin_id: entity_link_delete
dropbutton:
id: dropbutton
table: views
@ -211,6 +315,8 @@ display:
fields:
title: title
nothing: nothing
edit_node: edit_node
delete_node: delete_node
nid: '0'
destination: true
filters:

View file

@ -123,3 +123,46 @@ display:
position: null
display_options:
path: test-entity-operations
page_2:
display_plugin: page
id: page_2
display_title: 'Page 2'
position: null
display_options:
path: test-entity-operations-table
style:
type: table
options:
grouping: { }
row_class: ''
default_row_class: true
override: true
sticky: false
caption: ''
summary: ''
description: ''
columns:
title: title
operations: operations
info:
title:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
operations:
align: ''
separator: ''
empty_column: false
responsive: ''
default: '-1'
empty_table: false
row:
type: fields
options: { }
display_extenders: { }
defaults:
style: false
row: false

View file

@ -0,0 +1,167 @@
<?php
namespace Drupal\Tests\views\Kernel\Handler;
use Drupal\Core\Render\RenderContext;
use Drupal\simpletest\ContentTypeCreationTrait;
use Drupal\simpletest\NodeCreationTrait;
use Drupal\simpletest\UserCreationTrait;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Views;
/**
* Tests the core Drupal\views\Plugin\views\field\Dropbutton handler.
*
* @group views
*/
class FieldDropbuttonTest extends ViewsKernelTestBase {
use ContentTypeCreationTrait;
use UserCreationTrait;
use NodeCreationTrait;
/**
* {@inheritdoc}
*/
public static $testViews = ['test_dropbutton'];
/**
* {@inheritdoc}
*/
public static $modules = [
'system',
'user',
'node',
'field',
'text',
'filter',
'views',
];
/**
* Test node.
*
* @var \Drupal\node\NodeInterface
*/
protected $node1;
/**
* Test node.
*
* @var \Drupal\node\NodeInterface
*/
protected $node2;
/**
* Test node.
*
* @var \Drupal\node\NodeInterface
*/
protected $node3;
/**
* Test user.
*
* @var \Drupal\user\UserInterface
*/
protected $testUser;
/**
* {@inheritdoc}
*/
protected function setUp($import_test_views = TRUE) {
parent::setUp(FALSE);
$this->installEntitySchema('node');
$this->installEntitySchema('user');
$this->installSchema('node', 'node_access');
$this->installConfig('node');
$this->installConfig('filter');
ViewTestData::createTestViews(get_class($this), ['views_test_config']);
// Create two node types.
$this->createContentType(['type' => 'foo']);
$this->createContentType(['type' => 'bar']);
// Create user 1.
$admin = $this->createUser();
// And three nodes.
$this->node1 = $this->createNode([
'type' => 'bar',
'title' => 'bazs',
'status' => 1,
'uid' => $admin->id(),
'created' => REQUEST_TIME - 10,
]);
$this->node2 = $this->createNode([
'type' => 'foo',
'title' => 'foos',
'status' => 1,
'uid' => $admin->id(),
'created' => REQUEST_TIME - 5,
]);
$this->node3 = $this->createNode([
'type' => 'bar',
'title' => 'bars',
'status' => 1,
'uid' => $admin->id(),
'created' => REQUEST_TIME,
]);
// Now create a user with the ability to edit bar but not foo.
$this->testUser = $this->createUser([
'access content overview',
'access content',
'edit any bar content',
'delete any bar content',
]);
// And switch to that user.
$this->container->get('account_switcher')->switchTo($this->testUser);
}
/**
* Tests that dropbutton markup doesn't leak between rows.
*/
public function testDropbuttonMarkupShouldNotLeakBetweenRows() {
$view = Views::getView('test_dropbutton');
$view->setDisplay();
$view->preExecute([]);
$view->execute();
$renderer = $this->container->get('renderer');
$dropbutton_output = [];
// Render each row and field in turn - the dropbutton plugin relies on
// output being set in previous versions.
foreach ($view->result as $index => $row) {
foreach (array_keys($view->field) as $field) {
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row, $field) {
return $view->field[$field]->advancedRender($row);
});
if ($field === 'dropbutton') {
$dropbutton_output[] = $output;
}
}
}
// The first row should contain edit links to node 3, as the user has
// access.
$this->assertContains($this->node3->toUrl('edit-form')->toString(), (string) $dropbutton_output[0]);
$this->assertContains($this->node3->toUrl('delete-form')->toString(), (string) $dropbutton_output[0]);
// Second row should be not contain links to edit/delete any content as user
// has no edit/delete permissions.
// It most certainly should not contain links to node 3, as node 2 is the
// entity that forms this row.
$this->assertNotContains($this->node3->toUrl('edit-form')->toString(), (string) $dropbutton_output[1]);
$this->assertNotContains($this->node3->toUrl('delete-form')->toString(), (string) $dropbutton_output[1]);
$this->assertNotContains($this->node2->toUrl('edit-form')->toString(), (string) $dropbutton_output[1]);
$this->assertNotContains($this->node2->toUrl('delete-form')->toString(), (string) $dropbutton_output[1]);
// Third row should contain links for node 1.
$this->assertContains($this->node1->toUrl('edit-form')->toString(), (string) $dropbutton_output[2]);
$this->assertContains($this->node1->toUrl('delete-form')->toString(), (string) $dropbutton_output[2]);
}
}

View file

@ -168,6 +168,67 @@ class FieldKernelTest extends ViewsKernelTestBase {
$this->assertSubString($output, $random_text);
}
/**
* Tests rewriting of the output with HTML.
*/
public function testRewriteHtmlWithTokens() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_view');
$view->initHandlers();
$this->executeView($view);
$row = $view->result[0];
$id_field = $view->field['id'];
$id_field->options['alter']['text'] = '<p>{{ id }}</p>';
$id_field->options['alter']['alter_text'] = TRUE;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
$this->assertSubString($output, '<p>1</p>');
// Add a non-safe HTML tag and make sure this gets removed.
$id_field->options['alter']['text'] = '<p>{{ id }} <script>alert("Script removed")</script></p>';
$id_field->options['alter']['alter_text'] = TRUE;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
$this->assertSubString($output, '<p>1 alert("Script removed")</p>');
}
/**
* Tests rewriting of the output with HTML and aggregation.
*/
public function testRewriteHtmlWithTokensAndAggregation() {
/** @var \Drupal\Core\Render\RendererInterface $renderer */
$renderer = \Drupal::service('renderer');
$view = Views::getView('test_view');
$view->setDisplay();
$view->displayHandlers->get('default')->options['fields']['id']['group_type'] = 'sum';
$view->displayHandlers->get('default')->setOption('group_by', TRUE);
$view->initHandlers();
$this->executeView($view);
$row = $view->result[0];
$id_field = $view->field['id'];
$id_field->options['alter']['text'] = '<p>{{ id }}</p>';
$id_field->options['alter']['alter_text'] = TRUE;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
$this->assertSubString($output, '<p>1</p>');
// Add a non-safe HTML tag and make sure this gets removed.
$id_field->options['alter']['text'] = '<p>{{ id }} <script>alert("Script removed")</script></p>';
$id_field->options['alter']['alter_text'] = TRUE;
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($id_field, $row) {
return $id_field->theme($row);
});
$this->assertSubString($output, '<p>1 alert("Script removed")</p>');
}
/**
* Tests the arguments tokens on field level.
*/

View file

@ -5,6 +5,7 @@ namespace Drupal\Tests\views\Kernel\Plugin;
use Drupal\views\Plugin\Block\ViewsBlock;
use Drupal\views\Tests\ViewTestData;
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
use Drupal\views\Views;
/**
* Tests native behaviors of the block views plugin.
@ -51,4 +52,79 @@ class ViewsBlockTest extends ViewsKernelTestBase {
$this->assertEqual($views_block->getMachineNameSuggestion(), 'views_block__test_view_block_block_1');
}
/**
* Tests that ViewsBlock::build() produces the right output with title tokens.
*
* @see \Drupal\views\Plugin\Block::build()
*/
public function testBuildWithTitleToken() {
$view = Views::getView('test_view_block');
$view->setDisplay();
$sorts = [
'name' => [
'id' => 'name',
'field' => 'name',
'table' => 'views_test_data',
'plugin_id' => 'standard',
'order' => 'asc',
],
];
// Set the title to the 'name' field in the first row and add a sort order
// for consistent results on different databases.
$view->display_handler->setOption('title', '{{ name }}');
$view->display_handler->setOption('sorts', $sorts);
$view->save();
$plugin_definition = [
'provider' => 'views',
];
$plugin_id = 'views_block:test_view_block-block_1';
$views_block = ViewsBlock::create($this->container, [], $plugin_id, $plugin_definition);
$build = $views_block->build();
$this->assertEquals('George', $build['#title']['#markup']);
}
/**
* Tests ViewsBlock::build() with a title override.
*
* @see \Drupal\views\Plugin\Block::build()
*/
public function testBuildWithTitleOverride() {
$view = Views::getView('test_view_block');
$view->setDisplay();
// Add a fixed argument that sets a title and save the view.
$view->displayHandlers->get('default')->overrideOption('arguments', array(
'name' => array(
'default_action' => 'default',
'title_enable' => TRUE,
'title' => 'Overridden title',
'default_argument_type' => 'fixed',
'default_argument_options' => [
'argument' => 'fixed'
],
'validate' => array(
'type' => 'none',
'fail' => 'not found',
),
'id' => 'name',
'table' => 'views_test_data',
'field' => 'name',
'plugin_id' => 'string',
)
));
$view->save();
$plugin_definition = [
'provider' => 'views',
];
$plugin_id = 'views_block:test_view_block-block_1';
$views_block = ViewsBlock::create($this->container, [], $plugin_id, $plugin_definition);
$build = $views_block->build();
$this->assertEquals('Overridden title', $build['#title']['#markup']);
}
}