Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -0,0 +1,8 @@
|
|||
name: 'Views test field'
|
||||
type: module
|
||||
description: 'Add custom global field for testing purposes.'
|
||||
package: Testing
|
||||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- views_ui
|
|
@ -0,0 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* ViewsUI Test field module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_form_FORM_ID_alter() for views_ui_add_handler_form.
|
||||
*
|
||||
* Changes the label for one of the tests fields to validate this label is not
|
||||
* searched on.
|
||||
*/
|
||||
function views_ui_test_field_form_views_ui_add_handler_form_alter(&$form, FormStateInterface $form_state) {
|
||||
$form['options']['name']['#options']['views.views_test_field_1']['title']['data']['#title'] .= ' FIELD_1_LABEL';
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Provide views data for testing purposes.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
function views_ui_test_field_views_data() {
|
||||
|
||||
$data['views']['views_test_field_1'] = [
|
||||
'title' => t('Views test field 1 - FIELD_1_TITLE'),
|
||||
'help' => t('Field 1 for testing purposes - FIELD_1_DESCRIPTION'),
|
||||
'field' => [
|
||||
'id' => 'views_test_field_1',
|
||||
],
|
||||
];
|
||||
$data['views']['views_test_field_2'] = [
|
||||
'title' => t('Views test field 2 - FIELD_2_TITLE'),
|
||||
'help' => t('Field 2 for testing purposes - FIELD_2_DESCRIPTION'),
|
||||
'field' => [
|
||||
'id' => 'views_test_field_2',
|
||||
],
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views_ui\FunctionalJavascript;
|
||||
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
|
||||
/**
|
||||
* Tests the JavaScript filtering of options in add handler form.
|
||||
*
|
||||
* @group views_ui
|
||||
*/
|
||||
class FilterOptionsTest extends JavascriptTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'views', 'views_ui', 'views_ui_test_field'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer views',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests filtering options in the 'Add fields' dialog.
|
||||
*/
|
||||
public function testFilterOptionsAddFields() {
|
||||
$this->drupalGet('admin/structure/views/view/content');
|
||||
|
||||
$session = $this->getSession();
|
||||
$web_assert = $this->assertSession();
|
||||
$page = $session->getPage();
|
||||
|
||||
// Open the dialog.
|
||||
$page->clickLink('views-add-field');
|
||||
|
||||
// Wait for the popup to open and the search field to be available.
|
||||
$options_search = $web_assert->waitForField('override[controls][options_search]');
|
||||
|
||||
// Test that the both special fields are visible.
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
|
||||
// Test the ".title" field in search.
|
||||
$options_search->setValue('FIELD_1_TITLE');
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
return !$page->findField('name[views.views_test_field_2]')->isVisible();
|
||||
});
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
|
||||
// Test the ".description" field in search.
|
||||
$options_search->setValue('FIELD_2_DESCRIPTION');
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
return !$page->findField('name[views.views_test_field_1]')->isVisible();
|
||||
});
|
||||
$this->assertTrue($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
|
||||
// Test the "label" field not in search.
|
||||
$options_search->setValue('FIELD_1_LABEL');
|
||||
$page->waitFor(10, function () use ($page) {
|
||||
return !$page->findField('name[views.views_test_field_2]')->isVisible();
|
||||
});
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_2]')->isVisible());
|
||||
$this->assertFalse($page->findField('name[views.views_test_field_1]')->isVisible());
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ class TagTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views', 'views_ui', 'user');
|
||||
public static $modules = ['views', 'views_ui', 'user'];
|
||||
|
||||
/**
|
||||
* Tests the views_ui_autocomplete_tag function.
|
||||
|
@ -28,15 +28,15 @@ class TagTest extends ViewsKernelTestBase {
|
|||
\Drupal::moduleHandler()->loadInclude('views_ui', 'inc', 'admin');
|
||||
|
||||
// Save 15 views with a tag.
|
||||
$tags = array();
|
||||
$tags = [];
|
||||
for ($i = 0; $i < 16; $i++) {
|
||||
$suffix = $i % 2 ? 'odd' : 'even';
|
||||
$tag = 'autocomplete_tag_test_' . $suffix . $this->randomMachineName();
|
||||
$tags[] = $tag;
|
||||
View::create(array('tag' => $tag, 'id' => $this->randomMachineName()))->save();
|
||||
View::create(['tag' => $tag, 'id' => $this->randomMachineName()])->save();
|
||||
}
|
||||
|
||||
// Make sure just ten results are returns.
|
||||
// Make sure just ten results are returned.
|
||||
$controller = ViewsUIController::create($this->container);
|
||||
$request = $this->container->get('request_stack')->getCurrentRequest();
|
||||
$request->query->set('q', 'autocomplete_tag_test');
|
||||
|
@ -46,7 +46,7 @@ class TagTest extends ViewsKernelTestBase {
|
|||
|
||||
// Make sure the returned array has the proper format.
|
||||
$suggestions = array_map(function ($tag) {
|
||||
return array('value' => $tag, 'label' => Html::escape($tag));
|
||||
return ['value' => $tag, 'label' => Html::escape($tag)];
|
||||
}, $tags);
|
||||
foreach ($matches as $match) {
|
||||
$this->assertTrue(in_array($match, $suggestions), 'Make sure the returned array has the proper format.');
|
||||
|
@ -59,7 +59,7 @@ class TagTest extends ViewsKernelTestBase {
|
|||
$matches = (array) json_decode($result->getContent(), TRUE);
|
||||
$this->assertEqual(count($matches), 8, 'Make sure that only a subset is returned.');
|
||||
foreach ($matches as $tag) {
|
||||
$this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', array('@tag' => $tag['value'])));
|
||||
$this->assertTrue(array_search($tag['value'], $tags) !== FALSE, format_string('Make sure the returned tag @tag actually exists.', ['@tag' => $tag['value']]));
|
||||
}
|
||||
|
||||
// Make sure an invalid result doesn't return anything.
|
||||
|
|
|
@ -17,8 +17,8 @@ class RearrangeFilterTest extends UnitTestCase {
|
|||
*/
|
||||
public function testStaticMethods() {
|
||||
// Test the RearrangeFilter::arrayKeyPlus method.
|
||||
$original = array(0 => 'one', 1 => 'two', 2 => 'three');
|
||||
$expected = array(1 => 'one', 2 => 'two', 3 => 'three');
|
||||
$original = [0 => 'one', 1 => 'two', 2 => 'three'];
|
||||
$expected = [1 => 'one', 2 => 'two', 3 => 'three'];
|
||||
$this->assertSame(RearrangeFilter::arrayKeyPlus($original), $expected);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,54 +38,54 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
|
||||
$display_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->will($this->returnValueMap(array(
|
||||
array(
|
||||
->will($this->returnValueMap([
|
||||
[
|
||||
'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'),
|
||||
'contextual_links_locations' => ['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'))
|
||||
['initDisplay'],
|
||||
[[], '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)
|
||||
['initDisplay', 'getPath'],
|
||||
[[], 'default', $display_manager->getDefinition('page'), $route_provider, $state, $menu_storage]
|
||||
);
|
||||
$page_display->expects($this->any())
|
||||
->method('getPath')
|
||||
|
@ -94,11 +94,11 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
$this->returnValue('<object>malformed_path</object>'),
|
||||
$this->returnValue('<script>alert("placeholder_page/%")</script>')));
|
||||
|
||||
$embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', array('initDisplay'),
|
||||
array(array(), 'default', $display_manager->getDefinition('embed'))
|
||||
$embed_display = $this->getMock('Drupal\views\Plugin\views\display\Embed', ['initDisplay'],
|
||||
[[], 'default', $display_manager->getDefinition('embed')]
|
||||
);
|
||||
|
||||
$values = array();
|
||||
$values = [];
|
||||
$values['status'] = FALSE;
|
||||
$values['display']['default']['id'] = 'default';
|
||||
$values['display']['default']['display_title'] = 'Display';
|
||||
|
@ -125,13 +125,13 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
|
||||
$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('page', $values['display']['page_2'], $page_display),
|
||||
array('page', $values['display']['page_3'], $page_display),
|
||||
array('embed', $values['display']['embed'], $embed_display),
|
||||
)));
|
||||
->will($this->returnValueMap([
|
||||
['default', $values['display']['default'], $default_display],
|
||||
['page', $values['display']['page_1'], $page_display],
|
||||
['page', $values['display']['page_2'], $page_display],
|
||||
['page', $values['display']['page_3'], $page_display],
|
||||
['embed', $values['display']['embed'], $embed_display],
|
||||
]));
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$user = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
|
@ -152,21 +152,34 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
$view_list_builder = new TestViewListBuilder($entity_type, $storage, $display_manager);
|
||||
$view_list_builder->setStringTranslation($this->getStringTranslationStub());
|
||||
|
||||
// Create new view with test values.
|
||||
$view = new View($values, 'view');
|
||||
|
||||
// Get the row object created by ViewListBuilder for this test view.
|
||||
$row = $view_list_builder->buildRow($view);
|
||||
|
||||
$expected_displays = array(
|
||||
'Embed admin label',
|
||||
'Page admin label',
|
||||
'Page admin label',
|
||||
'Page admin label',
|
||||
);
|
||||
$this->assertEquals($expected_displays, $row['data']['view_name']['data']['#displays']);
|
||||
// Expected output array for view's displays.
|
||||
$expected_displays = [
|
||||
'0' => [
|
||||
'display' => 'Embed admin label',
|
||||
'path' => FALSE,
|
||||
],
|
||||
'1' => [
|
||||
'display' => 'Page admin label',
|
||||
'path' => '/<object>malformed_path</object>',
|
||||
],
|
||||
'2' => [
|
||||
'display' => 'Page admin label',
|
||||
'path' => '/<script>alert("placeholder_page/%")</script>',
|
||||
],
|
||||
'3' => [
|
||||
'display' => 'Page admin label',
|
||||
'path' => '/test_page',
|
||||
],
|
||||
];
|
||||
|
||||
$display_paths = $row['data']['path']['data']['#items'];
|
||||
// These values will be escaped by Twig when rendered.
|
||||
$this->assertEquals('/test_page, /<object>malformed_path</object>, /<script>alert("placeholder_page/%")</script>', implode(', ', $display_paths));
|
||||
// Compare the expected and generated output.
|
||||
$this->assertEquals($expected_displays, $row['data']['displays']['data']['#displays']);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -174,7 +187,7 @@ class ViewListBuilderTest extends UnitTestCase {
|
|||
class TestViewListBuilder extends ViewListBuilder {
|
||||
|
||||
public function buildOperations(EntityInterface $entity) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,14 +18,14 @@ 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);
|
||||
$method_args = [];
|
||||
$method_args['setOriginalId'] = [12];
|
||||
$method_args['setStatus'] = [TRUE];
|
||||
$method_args['enforceIsNew'] = [FALSE];
|
||||
$method_args['label'] = [LanguageInterface::LANGCODE_NOT_SPECIFIED];
|
||||
|
||||
$reflection = new \ReflectionClass('Drupal\Core\Config\Entity\ConfigEntityInterface');
|
||||
$interface_methods = array();
|
||||
$interface_methods = [];
|
||||
foreach ($reflection->getMethods() as $reflection_method) {
|
||||
$interface_methods[] = $reflection_method->getName();
|
||||
|
||||
|
@ -38,15 +38,15 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
// 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();
|
||||
$method_args[$reflection_method->getName()] = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, array(array(), 'view'));
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', $interface_methods, [[], 'view']);
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs(array($storage))
|
||||
->setConstructorArgs([$storage])
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
|
||||
|
@ -58,7 +58,7 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
foreach ($args as $arg) {
|
||||
$method_mock->with($this->equalTo($arg));
|
||||
}
|
||||
call_user_func_array(array($view_ui, $method), $args);
|
||||
call_user_func_array([$view_ui, $method], $args);
|
||||
}
|
||||
|
||||
$storage->expects($this->once())
|
||||
|
@ -70,10 +70,10 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
* Tests the isLocked method.
|
||||
*/
|
||||
public function testIsLocked() {
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', array(), array(array(), 'view'));
|
||||
$storage = $this->getMock('Drupal\views\Entity\View', [], [[], 'view']);
|
||||
$executable = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->setConstructorArgs(array($storage))
|
||||
->setConstructorArgs([$storage])
|
||||
->getMock();
|
||||
$storage->set('executable', $executable);
|
||||
$account = $this->getMock('Drupal\Core\Session\AccountInterface');
|
||||
|
@ -91,20 +91,20 @@ class ViewUIObjectTest extends UnitTestCase {
|
|||
$this->assertFalse($view_ui->isLocked());
|
||||
|
||||
// Set the lock object with a different owner than the mocked account above.
|
||||
$lock = (object) array(
|
||||
$lock = (object) [
|
||||
'owner' => 2,
|
||||
'data' => array(),
|
||||
'data' => [],
|
||||
'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(
|
||||
$lock = (object) [
|
||||
'owner' => 1,
|
||||
'data' => array(),
|
||||
'data' => [],
|
||||
'updated' => (int) $_SERVER['REQUEST_TIME'],
|
||||
);
|
||||
];
|
||||
$view_ui->lock = $lock;
|
||||
$this->assertFalse($view_ui->isLocked());
|
||||
}
|
||||
|
|
Reference in a new issue