Drupal 8.0.0 beta 12. More info: https://www.drupal.org/node/2514176
This commit is contained in:
commit
9921556621
13277 changed files with 1459781 additions and 0 deletions
|
@ -0,0 +1,187 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- user
|
||||
id: sa_contrib_2013_035
|
||||
label: SA_CONTRIB_2013_035
|
||||
module: views
|
||||
description: ''
|
||||
tag: '<script>alert("foo");</script>, <marquee>test</marquee>'
|
||||
base_table: node_field_data
|
||||
base_field: nid
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
display_plugin: default
|
||||
id: default
|
||||
display_title: Master
|
||||
position: 0
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
options:
|
||||
perm: 'access content'
|
||||
cache:
|
||||
type: tag
|
||||
options: { }
|
||||
query:
|
||||
type: views_query
|
||||
options:
|
||||
disable_sql_rewrite: false
|
||||
distinct: false
|
||||
replica: false
|
||||
query_comment: ''
|
||||
query_tags: { }
|
||||
exposed_form:
|
||||
type: basic
|
||||
options:
|
||||
submit_button: Apply
|
||||
reset_button: false
|
||||
reset_button_label: Reset
|
||||
exposed_sorts_label: 'Sort by'
|
||||
expose_sort_order: true
|
||||
sort_asc_label: Asc
|
||||
sort_desc_label: Desc
|
||||
pager:
|
||||
type: none
|
||||
options:
|
||||
offset: 0
|
||||
style:
|
||||
type: default
|
||||
options:
|
||||
grouping: { }
|
||||
row_class: ''
|
||||
default_row_class: true
|
||||
uses_fields: false
|
||||
row:
|
||||
type: fields
|
||||
options:
|
||||
inline: { }
|
||||
separator: ''
|
||||
hide_empty: false
|
||||
default_field_elements: true
|
||||
fields:
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: '<marquee>test</marquee>'
|
||||
label: ''
|
||||
exclude: false
|
||||
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: false
|
||||
ellipsis: false
|
||||
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
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
title_1:
|
||||
id: title_1
|
||||
table: node_field_data
|
||||
field: title
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: '<script>alert("XSS")</script>'
|
||||
label: ''
|
||||
exclude: false
|
||||
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
|
||||
plugin_id: field
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
filters: { }
|
||||
sorts: { }
|
||||
header:
|
||||
area:
|
||||
id: area
|
||||
table: views
|
||||
field: area
|
||||
plugin_id: text
|
||||
footer: { }
|
||||
empty: { }
|
||||
relationships: { }
|
||||
arguments: { }
|
||||
title: '<marquee>VIEWS TITLE</marquee>'
|
||||
page_1:
|
||||
display_plugin: page
|
||||
id: page_1
|
||||
display_title: Page
|
||||
position: 2
|
||||
display_options:
|
||||
path: foobar
|
|
@ -0,0 +1,4 @@
|
|||
/**
|
||||
* @file
|
||||
* Just a placeholder file for the test.
|
||||
*/
|
|
@ -0,0 +1,8 @@
|
|||
name: 'Views UI Test'
|
||||
type: module
|
||||
description: 'Test module for Views UI.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- views_ui
|
|
@ -0,0 +1,4 @@
|
|||
views_ui_test.test:
|
||||
css:
|
||||
component:
|
||||
css/views_ui_test.test.css: {}
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Helper module for Views UI tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_preview_info_alter().
|
||||
*
|
||||
* Add a row count row to the live preview area.
|
||||
*/
|
||||
function views_ui_test_views_preview_info_alter(&$rows, $view) {
|
||||
$data = ['#markup' => t('Test row count')];
|
||||
$data['#attached']['library'][] = 'views_ui_test/views_ui_test.test';
|
||||
$rows['query'][] = [['data' => $data], count($view->result)];
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\views_ui\Unit\Form\Ajax\RearrangeFilterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views_ui\Unit\Form\Ajax;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views_ui\Form\Ajax\RearrangeFilter;
|
||||
|
||||
/**
|
||||
* Unit tests for Views UI module functions.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class RearrangeFilterTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests static methods.
|
||||
*/
|
||||
public function testStaticMethods() {
|
||||
// Test the RearrangeFilter::arrayKeyPlus method.
|
||||
$original = array(0 => 'one', 1 => 'two', 2 => 'three');
|
||||
$expected = array(1 => 'one', 2 => 'two', 3 => 'three');
|
||||
$this->assertSame(RearrangeFilter::arrayKeyPlus($original), $expected);
|
||||
}
|
||||
|
||||
}
|
156
core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
Normal file
156
core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php
Normal file
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\views_ui\Unit\ViewListBuilderTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views_ui\Unit;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\ViewExecutableFactory;
|
||||
use Drupal\views_ui\ViewListBuilder;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\views_ui\ViewListBuilder
|
||||
* @group views_ui
|
||||
*/
|
||||
class ViewListBuilderTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests the listing of displays on a views list builder.
|
||||
*
|
||||
* @see \Drupal\views_ui\ViewListBuilder::getDisplaysList()
|
||||
* @covers ::buildRow
|
||||
*/
|
||||
public function testBuildRowEntityList() {
|
||||
$storage = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigEntityStorage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$display_manager = $this->getMockBuilder('\Drupal\views\Plugin\ViewsPluginManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$display_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValueMap(array(
|
||||
array(
|
||||
'default',
|
||||
TRUE,
|
||||
array(
|
||||
'id' => 'default',
|
||||
'title' => 'Master',
|
||||
'theme' => 'views_view',
|
||||
'no_ui' => TRUE,
|
||||
'admin' => '',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'page',
|
||||
TRUE,
|
||||
array(
|
||||
'id' => 'page',
|
||||
'title' => 'Page',
|
||||
'uses_menu_links' => TRUE,
|
||||
'uses_route' => TRUE,
|
||||
'contextual_links_locations' => array('page'),
|
||||
'theme' => 'views_view',
|
||||
'admin' => 'Page admin label',
|
||||
)
|
||||
),
|
||||
array(
|
||||
'embed',
|
||||
TRUE,
|
||||
array(
|
||||
'id' => 'embed',
|
||||
'title' => 'embed',
|
||||
'theme' => 'views_view',
|
||||
'admin' => 'Embed admin label',
|
||||
)
|
||||
),
|
||||
)));
|
||||
|
||||
|
||||
$default_display = $this->getMock('Drupal\views\Plugin\views\display\DefaultDisplay',
|
||||
array('initDisplay'),
|
||||
array(array(), 'default', $display_manager->getDefinition('default'))
|
||||
);
|
||||
$route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
|
||||
$state = $this->getMock('\Drupal\Core\State\StateInterface');
|
||||
$menu_storage = $this->getMock('\Drupal\Core\Entity\EntityStorageInterface');
|
||||
$page_display = $this->getMock('Drupal\views\Plugin\views\display\Page',
|
||||
array('initDisplay', 'getPath'),
|
||||
array(array(), 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage)
|
||||
);
|
||||
$page_display->expects($this->any())
|
||||
->method('getPath')
|
||||
->will($this->returnValue('test_page'));
|
||||
|
||||
$embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', array('initDisplay'),
|
||||
array(array(), 'default', $display_manager->getDefinition('embed'))
|
||||
);
|
||||
|
||||
$values = array();
|
||||
$values['status'] = FALSE;
|
||||
$values['display']['default']['id'] = 'default';
|
||||
$values['display']['default']['display_title'] = 'Display';
|
||||
$values['display']['default']['display_plugin'] = 'default';
|
||||
|
||||
$values['display']['page_1']['id'] = 'page_1';
|
||||
$values['display']['page_1']['display_title'] = 'Page 1';
|
||||
$values['display']['page_1']['display_plugin'] = 'page';
|
||||
$values['display']['page_1']['display_options']['path'] = 'test_page';
|
||||
|
||||
$values['display']['embed']['id'] = 'embed';
|
||||
$values['display']['embed']['display_title'] = 'Embedded';
|
||||
$values['display']['embed']['display_plugin'] = 'embed';
|
||||
|
||||
$display_manager->expects($this->any())
|
||||
->method('createInstance')
|
||||
->will($this->returnValueMap(array(
|
||||
array('default', $values['display']['default'], $default_display),
|
||||
array('page', $values['display']['page_1'], $page_display),
|
||||
array('embed', $values['display']['embed'], $embed_display),
|
||||
)));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
$request_stack = new RequestStack();
|
||||
$request_stack->push(new Request());
|
||||
$views_data = $this->getMockBuilder('Drupal\views\ViewsData')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$route_provider = $this->getMock('Drupal\Core\Routing\RouteProviderInterface');
|
||||
$executable_factory = new ViewExecutableFactory($user, $request_stack, $views_data, $route_provider);
|
||||
$container->set('views.executable', $executable_factory);
|
||||
$container->set('plugin.manager.views.display', $display_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
// Setup a view list builder with a mocked buildOperations method,
|
||||
// because t() is called on there.
|
||||
$entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface');
|
||||
$view_list_builder = new TestViewListBuilder($entity_type, $storage, $display_manager);
|
||||
$view_list_builder->setStringTranslation($this->getStringTranslationStub());
|
||||
|
||||
$view = new View($values, 'view');
|
||||
|
||||
$row = $view_list_builder->buildRow($view);
|
||||
|
||||
$this->assertEquals(array('Embed admin label', 'Page admin label'), $row['data']['view_name']['data']['#displays'], 'Wrong displays got added to view list');
|
||||
$this->assertEquals($row['data']['path'], '/test_page', 'The path of the page display is not added.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class TestViewListBuilder extends ViewListBuilder {
|
||||
|
||||
public function buildOperations(EntityInterface $entity) {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
148
core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
Normal file
148
core/modules/views_ui/tests/src/Unit/ViewUIObjectTest.php
Normal file
|
@ -0,0 +1,148 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\views_ui\Unit\ViewUIObjectTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\views_ui\Unit;
|
||||
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views_ui\ViewUI;
|
||||
use Symfony\Component\DependencyInjection\Container;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\views_ui\ViewUI
|
||||
* @group views_ui
|
||||
*/
|
||||
class ViewUIObjectTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests entity method decoration.
|
||||
*/
|
||||
public function testEntityDecoration() {
|
||||
$method_args = array();
|
||||
$method_args['setOriginalId'] = array(12);
|
||||
$method_args['setStatus'] = array(TRUE);
|
||||
$method_args['enforceIsNew'] = array(FALSE);
|
||||
$method_args['label'] = array(LanguageInterface::LANGCODE_NOT_SPECIFIED);
|
||||
|
||||
$reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface');
|
||||
$interface_methods = array();
|
||||
foreach ($reflection->getMethods() as $reflection_method) {
|
||||
$interface_methods[] = $reflection_method->getName();
|
||||
|
||||
// EntityInterface::isNew() is missing from the list of methods, because it
|
||||
// calls id(), which breaks the ->expect($this->once()) call. Call it later.
|
||||
// EntityInterface::isSyncing() is only called during syncing process.
|
||||
// EntityInterface::isUninstalling() is only called during uninstallation
|
||||
// process. EntityInterface::getConfigDependencyName() and
|
||||
// ConfigEntityInterface::calculateDependencies() are only used for
|
||||
// dependency management.
|
||||
if (!in_array($reflection_method->getName(), ['isNew', 'isSyncing', 'isUninstalling', 'getConfigDependencyKey', 'getConfigDependencyName', 'calculateDependencies'])) {
|
||||
if (count($reflection_method->getParameters()) == 0) {
|
||||
$method_args[$reflection_method->getName()] = array();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, array(array(), 'view'));
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs(array($storage))
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
|
||||
$view_ui = new ViewUI($storage);
|
||||
|
||||
foreach ($method_args as $method => $args) {
|
||||
$method_mock = $storage->expects($this->once())
|
||||
->method($method);
|
||||
foreach ($args as $arg) {
|
||||
$method_mock->with($this->equalTo($arg));
|
||||
}
|
||||
call_user_func_array(array($view_ui, $method), $args);
|
||||
}
|
||||
|
||||
$storage->expects($this->once())
|
||||
->method('isNew');
|
||||
$view_ui->isNew();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the isLocked method.
|
||||
*/
|
||||
public function testIsLocked() {
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', array(), array(array(), 'view'));
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs(array($storage))
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
$account->expects($this->exactly(2))
|
||||
->method('id')
|
||||
->will($this->returnValue(1));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('current_user', $account);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
$view_ui = new ViewUI($storage);
|
||||
|
||||
// A view_ui without a lock object is not locked.
|
||||
$this->assertFalse($view_ui->isLocked());
|
||||
|
||||
// Set the lock object with a different owner than the mocked account above.
|
||||
$lock = (object) array(
|
||||
'owner' => 2,
|
||||
'data' => array(),
|
||||
'updated' => (int) $_SERVER['REQUEST_TIME'],
|
||||
);
|
||||
$view_ui->lock = $lock;
|
||||
$this->assertTrue($view_ui->isLocked());
|
||||
|
||||
// Set a different lock object with the same object as the mocked account.
|
||||
$lock = (object) array(
|
||||
'owner' => 1,
|
||||
'data' => array(),
|
||||
'updated' => (int) $_SERVER['REQUEST_TIME'],
|
||||
);
|
||||
$view_ui->lock = $lock;
|
||||
$this->assertFalse($view_ui->isLocked());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests serialization of the ViewUI object.
|
||||
*/
|
||||
public function testSerialization() {
|
||||
// Set a container so the DependencySerializationTrait has it.
|
||||
$container = new ContainerBuilder();
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
$storage = new View([], 'view');
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs([$storage])
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
|
||||
$view_ui = new ViewUI($storage);
|
||||
|
||||
// Make sure the executable is returned before serializing.
|
||||
$this->assertInstanceOf('Drupal\views\ViewExecutable', $view_ui->getExecutable());
|
||||
|
||||
$serialized = serialize($view_ui);
|
||||
|
||||
// Make sure the ViewExecutable class is not found in the serialized string.
|
||||
$this->assertSame(strpos($serialized, '"Drupal\views\ViewExecutable"'), FALSE);
|
||||
|
||||
$unserialized = unserialize($serialized);
|
||||
$this->assertInstanceOf('Drupal\views_ui\ViewUI', $unserialized);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue