Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -11,9 +11,9 @@ use Drupal\Core\Serialization\Yaml;
|
|||
$connection = Database::getConnection();
|
||||
|
||||
$connection->insert('config')
|
||||
->fields(array(
|
||||
->fields([
|
||||
'collection' => '',
|
||||
'name' => 'views.view.test_token_view',
|
||||
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_token_view.yml'))),
|
||||
))
|
||||
])
|
||||
->execute();
|
||||
|
|
|
@ -11,9 +11,9 @@ use Drupal\Core\Serialization\Yaml;
|
|||
$connection = Database::getConnection();
|
||||
|
||||
$connection->insert('config')
|
||||
->fields(array(
|
||||
->fields([
|
||||
'collection' => '',
|
||||
'name' => 'views.view.test_boolean_filter_values',
|
||||
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/fixtures/update/views.view.test_boolean_filter_values.yml'))),
|
||||
))
|
||||
])
|
||||
->execute();
|
||||
|
|
|
@ -11,9 +11,9 @@ use Drupal\Core\Serialization\Yaml;
|
|||
$connection = Database::getConnection();
|
||||
|
||||
$connection->insert('config')
|
||||
->fields(array(
|
||||
->fields([
|
||||
'collection' => '',
|
||||
'name' => 'views.view.test_duplicate_field_handlers',
|
||||
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/modules/views_test_config/test_views/views.view.test_duplicate_field_handlers.yml'))),
|
||||
))
|
||||
])
|
||||
->execute();
|
||||
|
|
|
@ -22,10 +22,10 @@ function views_entity_test_entity_base_field_info(EntityTypeInterface $entity_ty
|
|||
->setLabel(t('Test access'))
|
||||
->setTranslatable(FALSE)
|
||||
->setSetting('max_length', 64)
|
||||
->setDisplayOptions('form', array(
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'string_textfield',
|
||||
'weight' => 10,
|
||||
));
|
||||
]);
|
||||
return $definitions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ display:
|
|||
field: type
|
||||
id: type
|
||||
table: node_field_data
|
||||
plugin_id: node_type
|
||||
plugin_id: bundle
|
||||
entity_type: node
|
||||
entity_field: type
|
||||
body_value:
|
||||
|
@ -76,6 +76,72 @@ display:
|
|||
plugin_id: string
|
||||
entity_type: node
|
||||
entity_field: body
|
||||
created:
|
||||
id: created
|
||||
table: node_field_data
|
||||
field: created
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
operator: '='
|
||||
value:
|
||||
min: ''
|
||||
max: ''
|
||||
value: ''
|
||||
type: date
|
||||
group: 1
|
||||
exposed: true
|
||||
expose:
|
||||
operator_id: created_op
|
||||
label: 'Authored on'
|
||||
description: null
|
||||
use_operator: false
|
||||
operator: created_op
|
||||
identifier: created
|
||||
required: false
|
||||
remember: false
|
||||
multiple: false
|
||||
remember_roles:
|
||||
authenticated: authenticated
|
||||
is_grouped: true
|
||||
group_info:
|
||||
label: 'Authored on'
|
||||
description: ''
|
||||
identifier: created
|
||||
optional: true
|
||||
widget: select
|
||||
multiple: false
|
||||
remember: false
|
||||
default_group: All
|
||||
default_group_multiple: { }
|
||||
group_items:
|
||||
1:
|
||||
title: Between
|
||||
operator: between
|
||||
value:
|
||||
type: date
|
||||
value: ''
|
||||
min: '2015-01-01'
|
||||
max: '2016-01-01'
|
||||
2:
|
||||
title: 'Not Between'
|
||||
operator: 'not between'
|
||||
value:
|
||||
type: date
|
||||
value: ''
|
||||
min: '2015-01-01'
|
||||
max: '2016-01-01'
|
||||
3:
|
||||
title: Equal
|
||||
operator: '='
|
||||
value:
|
||||
type: date
|
||||
value: '2016-01-01'
|
||||
min: ''
|
||||
max: ''
|
||||
entity_type: node
|
||||
entity_field: created
|
||||
plugin_id: date
|
||||
pager:
|
||||
type: full
|
||||
sorts:
|
||||
|
|
|
@ -77,3 +77,34 @@ display:
|
|||
operator: '='
|
||||
value: 'not an existing name'
|
||||
path: test_tokens_empty
|
||||
page_3:
|
||||
display_plugin: page
|
||||
id: page_3
|
||||
display_title: Page
|
||||
position: 1
|
||||
display_options:
|
||||
defaults:
|
||||
title: false
|
||||
pager: false
|
||||
header: false
|
||||
pager:
|
||||
type: mini
|
||||
options:
|
||||
items_per_page: 2
|
||||
title: 'Test token page with minipager'
|
||||
path: test_tokens_minipager
|
||||
display_extenders: { }
|
||||
header:
|
||||
area:
|
||||
id: area
|
||||
table: views
|
||||
field: area
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
empty: false
|
||||
tokenize: false
|
||||
content:
|
||||
value: "Total rows: [view:total-rows] - Page count: [view:page-count]"
|
||||
format: basic_html
|
||||
plugin_id: text
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_test_data\Controller;
|
||||
|
||||
/**
|
||||
* Controller class for views_test_data callbacks.
|
||||
*/
|
||||
class ViewsTestDataController {
|
||||
|
||||
/**
|
||||
* Renders an error form page.
|
||||
*
|
||||
* This contains a form that will contain an error and an embedded view with
|
||||
* an exposed form.
|
||||
*/
|
||||
public function errorFormPage() {
|
||||
$build = [];
|
||||
$build['view'] = [
|
||||
'#type' => 'view',
|
||||
'#name' => 'test_exposed_form_buttons',
|
||||
];
|
||||
$build['error_form'] = \Drupal::formBuilder()->getForm('Drupal\views_test_data\Form\ViewsTestDataErrorForm');
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
}
|
|
@ -21,13 +21,13 @@ class ViewsTestDataElementEmbedForm extends FormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['view'] = array(
|
||||
$form['view'] = [
|
||||
'#type' => 'view',
|
||||
'#name' => 'test_view_embed',
|
||||
'#display_id' => 'embed_1',
|
||||
'#arguments' => array(25),
|
||||
'#arguments' => [25],
|
||||
'#embed' => TRUE,
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -21,13 +21,13 @@ class ViewsTestDataElementForm extends FormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['view'] = array(
|
||||
$form['view'] = [
|
||||
'#type' => 'view',
|
||||
'#name' => 'test_view_embed',
|
||||
'#display_id' => 'default',
|
||||
'#arguments' => array(25),
|
||||
'#arguments' => [25],
|
||||
'#embed' => FALSE,
|
||||
);
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_test_data\Form;
|
||||
|
||||
use Drupal\Core\Form\FormInterface;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Implements a test form that has a validation error.
|
||||
*/
|
||||
class ViewsTestDataErrorForm implements FormInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'views_test_data_error_form';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state) {
|
||||
$form['text'] = [
|
||||
'#type' => 'textfield',
|
||||
];
|
||||
$form['submit'] = [
|
||||
'#type' => 'submit',
|
||||
'#value' => t('Submit'),
|
||||
];
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$form_state->setErrorByName('text', t('Form validation error'));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
}
|
||||
|
||||
}
|
|
@ -19,7 +19,7 @@ class StaticTest extends AccessPluginBase {
|
|||
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['access'] = array('default' => FALSE);
|
||||
$options['access'] = ['default' => FALSE];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ class TestExample extends AreaPluginBase {
|
|||
*/
|
||||
public function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['string'] = array('default' => '');
|
||||
$options['custom_access'] = array('default' => TRUE);
|
||||
$options['string'] = ['default' => ''];
|
||||
$options['custom_access'] = ['default' => TRUE];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -46,11 +46,11 @@ class TestExample extends AreaPluginBase {
|
|||
*/
|
||||
public function render($empty = FALSE) {
|
||||
if (!$empty || !empty($this->options['empty'])) {
|
||||
return array(
|
||||
return [
|
||||
'#markup' => $this->globalTokenReplace($this->options['string']),
|
||||
);
|
||||
];
|
||||
}
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ArgumentDefaultTest extends ArgumentDefaultPluginBase {
|
|||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['value'] = array('default' => '');
|
||||
$options['value'] = ['default' => ''];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ class ArgumentDefaultTest extends ArgumentDefaultPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArgument() {
|
||||
$this->view->element['#cache']['tags'][] = 'example_tag';
|
||||
return $this->options['value'];
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class DisplayTest extends DisplayPluginBase {
|
|||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['test_option'] = array('default' => '');
|
||||
$options['test_option'] = ['default' => ''];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -50,21 +50,21 @@ class DisplayTest extends DisplayPluginBase {
|
|||
public function optionsSummary(&$categories, &$options) {
|
||||
parent::optionsSummary($categories, $options);
|
||||
|
||||
$categories['display_test'] = array(
|
||||
$categories['display_test'] = [
|
||||
'title' => $this->t('Display test settings'),
|
||||
'column' => 'second',
|
||||
'build' => array(
|
||||
'build' => [
|
||||
'#weight' => -100,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$test_option = $this->getOption('test_option') ?: $this->t('Empty');
|
||||
|
||||
$options['test_option'] = array(
|
||||
$options['test_option'] = [
|
||||
'category' => 'display_test',
|
||||
'title' => $this->t('Test option'),
|
||||
'value' => views_ui_truncate($test_option, 24),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -76,12 +76,12 @@ class DisplayTest extends DisplayPluginBase {
|
|||
switch ($form_state->get('section')) {
|
||||
case 'test_option':
|
||||
$form['#title'] .= $this->t('Test option');
|
||||
$form['test_option'] = array(
|
||||
$form['test_option'] = [
|
||||
'#title' => $this->t('Test option'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => $this->t('This is a textfield for test_option.'),
|
||||
'#default_value' => $this->getOption('test_option'),
|
||||
);
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,19 +39,19 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
|
|||
public function optionsSummary(&$categories, &$options) {
|
||||
parent::optionsSummary($categories, $options);
|
||||
|
||||
$categories['display_extender_test'] = array(
|
||||
$categories['display_extender_test'] = [
|
||||
'title' => $this->t('Display extender test settings'),
|
||||
'column' => 'second',
|
||||
'build' => array(
|
||||
'build' => [
|
||||
'#weight' => -100,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$options['test_extender_test_option'] = array(
|
||||
$options['test_extender_test_option'] = [
|
||||
'category' => 'display_extender_test',
|
||||
'title' => $this->t('Test option'),
|
||||
'value' => views_ui_truncate($this->options['test_extender_test_option'], 24),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,12 +61,12 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
|
|||
switch ($form_state->get('section')) {
|
||||
case 'test_extender_test_option':
|
||||
$form['#title'] .= $this->t('Test option');
|
||||
$form['test_extender_test_option'] = array(
|
||||
$form['test_extender_test_option'] = [
|
||||
'#title' => $this->t('Test option'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => $this->t('This is a textfield for test_option.'),
|
||||
'#default_value' => $this->options['test_extender_test_option'],
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ class DisplayExtenderTest extends DisplayExtenderPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultableSections(&$sections, $section = NULL) {
|
||||
$sections['test_extender_test_option'] = array('test_extender_test_option');
|
||||
$sections['test_extender_test_option'] = ['test_extender_test_option'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\views_test_data\Plugin\views\filter;
|
||||
|
||||
use Drupal\views\Plugin\views\filter\BooleanOperator;
|
||||
|
||||
/**
|
||||
* Filter to test queryOpBoolean() with default operator.
|
||||
*
|
||||
* @ingroup views_filter_handlers
|
||||
*
|
||||
* @ViewsFilter("boolean_default")
|
||||
*/
|
||||
class FilterBooleanOperatorDefaultTest extends BooleanOperator {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
$this->ensureMyTable();
|
||||
$field = "$this->tableAlias.$this->realField";
|
||||
$this->queryOpBoolean($field);
|
||||
}
|
||||
|
||||
}
|
|
@ -18,7 +18,7 @@ class FilterTest extends FilterPluginBase {
|
|||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
|
||||
$options['test_enable'] = array('default' => TRUE);
|
||||
$options['test_enable'] = ['default' => TRUE];
|
||||
return $options;
|
||||
}
|
||||
|
||||
|
@ -30,11 +30,11 @@ class FilterTest extends FilterPluginBase {
|
|||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
|
||||
$form['test_enable'] = array(
|
||||
$form['test_enable'] = [
|
||||
'#type' => 'checkbox',
|
||||
'#title' => $this->t('Controls whether the filter plugin should be active'),
|
||||
'#default_value' => $this->options['test_enable'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -18,17 +18,17 @@ use Drupal\views\ViewExecutable;
|
|||
* )
|
||||
*/
|
||||
class QueryTest extends QueryPluginBase {
|
||||
protected $conditions = array();
|
||||
protected $fields = array();
|
||||
protected $allItems = array();
|
||||
protected $orderBy = array();
|
||||
protected $conditions = [];
|
||||
protected $fields = [];
|
||||
protected $allItems = [];
|
||||
protected $orderBy = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['test_setting'] = array('default' => '');
|
||||
$options['test_setting'] = ['default' => ''];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -39,11 +39,11 @@ class QueryTest extends QueryPluginBase {
|
|||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
|
||||
$form['test_setting'] = array(
|
||||
$form['test_setting'] = [
|
||||
'#title' => $this->t('Test setting'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['test_setting'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,21 +57,21 @@ class QueryTest extends QueryPluginBase {
|
|||
}
|
||||
|
||||
public function addWhere($group, $field, $value = NULL, $operator = NULL) {
|
||||
$this->conditions[] = array(
|
||||
$this->conditions[] = [
|
||||
'field' => $field,
|
||||
'value' => $value,
|
||||
'operator' => $operator
|
||||
);
|
||||
];
|
||||
|
||||
}
|
||||
|
||||
public function addField($table, $field, $alias = '', $params = array()) {
|
||||
public function addField($table, $field, $alias = '', $params = []) {
|
||||
$this->fields[$field] = $field;
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) {
|
||||
$this->orderBy = array('field' => $field, 'order' => $order);
|
||||
public function addOrderBy($table, $field = NULL, $order = 'ASC', $alias = '', $params = []) {
|
||||
$this->orderBy = ['field' => $field, 'order' => $order];
|
||||
}
|
||||
|
||||
|
||||
|
@ -96,7 +96,7 @@ class QueryTest extends QueryPluginBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function execute(ViewExecutable $view) {
|
||||
$result = array();
|
||||
$result = [];
|
||||
foreach ($this->allItems as $element) {
|
||||
// Run all conditions on the element, and add it to the result if they
|
||||
// match.
|
||||
|
|
|
@ -32,7 +32,7 @@ class RowTest extends RowPluginBase {
|
|||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['test_option'] = array('default' => '');
|
||||
$options['test_option'] = ['default' => ''];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -43,12 +43,12 @@ class RowTest extends RowPluginBase {
|
|||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
|
||||
$form['test_option'] = array(
|
||||
$form['test_option'] = [
|
||||
'#title' => $this->t('Test option'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => $this->t('This is a textfield for test_option.'),
|
||||
'#default_value' => $this->options['test_option'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,26 +24,26 @@ class MappingTest extends Mapping {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function defineMapping() {
|
||||
return array(
|
||||
'title_field' => array(
|
||||
return [
|
||||
'title_field' => [
|
||||
'#title' => $this->t('Title field'),
|
||||
'#description' => $this->t('Choose the field with the custom title.'),
|
||||
'#toggle' => TRUE,
|
||||
'#required' => TRUE,
|
||||
),
|
||||
'name_field' => array(
|
||||
],
|
||||
'name_field' => [
|
||||
'#title' => $this->t('Name field'),
|
||||
'#description' => $this->t('Choose the field with the custom name.'),
|
||||
),
|
||||
'numeric_field' => array(
|
||||
],
|
||||
'numeric_field' => [
|
||||
'#title' => $this->t('Numeric field'),
|
||||
'#description' => $this->t('Select one or more numeric fields.'),
|
||||
'#multiple' => TRUE,
|
||||
'#toggle' => TRUE,
|
||||
'#filter' => 'filterNumericFields',
|
||||
'#required' => TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -40,7 +40,7 @@ class StyleTest extends StylePluginBase {
|
|||
*/
|
||||
protected function defineOptions() {
|
||||
$options = parent::defineOptions();
|
||||
$options['test_option'] = array('default' => '');
|
||||
$options['test_option'] = ['default' => ''];
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
@ -51,12 +51,12 @@ class StyleTest extends StylePluginBase {
|
|||
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
|
||||
$form['test_option'] = array(
|
||||
$form['test_option'] = [
|
||||
'#title' => $this->t('Test option'),
|
||||
'#type' => 'textfield',
|
||||
'#description' => $this->t('This is a textfield for test_option.'),
|
||||
'#default_value' => $this->options['test_option'],
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ function views_test_data_schema() {
|
|||
*/
|
||||
function views_test_data_install() {
|
||||
// Add the marquee tag to possible html elements to test the field handler.
|
||||
$values = array(
|
||||
$values = [
|
||||
'div' => 'DIV',
|
||||
'span' => 'SPAN',
|
||||
'h1' => 'H1',
|
||||
|
@ -30,6 +30,6 @@ function views_test_data_install() {
|
|||
'strong' => 'STRONG',
|
||||
'em' => 'EM',
|
||||
'marquee' => 'MARQUEE'
|
||||
);
|
||||
];
|
||||
\Drupal::configFactory()->getEditable('views.settings')->set('field_rewrite_elements', $values)->save();
|
||||
}
|
||||
|
|
|
@ -66,13 +66,13 @@ function views_test_data_preprocess_views_view_table(&$variables) {
|
|||
* - view: The view object.
|
||||
*/
|
||||
function template_preprocess_views_view_mapping_test(&$variables) {
|
||||
$variables['element'] = array();
|
||||
$variables['element'] = [];
|
||||
|
||||
foreach ($variables['rows'] as $delta => $row) {
|
||||
$fields = array();
|
||||
$fields = [];
|
||||
foreach ($variables['options']['mapping'] as $type => $field_names) {
|
||||
if (!is_array($field_names)) {
|
||||
$field_names = array($field_names);
|
||||
$field_names = [$field_names];
|
||||
}
|
||||
foreach ($field_names as $field_name) {
|
||||
if ($value = $variables['view']->style_plugin->getField($delta, $field_name)) {
|
||||
|
@ -87,26 +87,26 @@ function template_preprocess_views_view_mapping_test(&$variables) {
|
|||
}
|
||||
|
||||
// Build a container for the row.
|
||||
$variables['element'][$delta] = array(
|
||||
$variables['element'][$delta] = [
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array(
|
||||
'#attributes' => [
|
||||
'class' => [
|
||||
'views-row-mapping-test',
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
// Add each field to the row.
|
||||
foreach ($fields as $key => $render) {
|
||||
$variables['element'][$delta][$key] = array(
|
||||
$variables['element'][$delta][$key] = [
|
||||
'#children' => $render,
|
||||
'#type' => 'container',
|
||||
'#attributes' => array(
|
||||
'class' => array(
|
||||
'#attributes' => [
|
||||
'class' => [
|
||||
$key,
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,3 +19,11 @@ views_test_data.form_multiple:
|
|||
_controller: '\Drupal\views_test_data\Controller\ViewsTestFormMultipleController::testPage'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
views_test_data.error_form_page:
|
||||
path: '/views_test_data_error_form_page'
|
||||
defaults:
|
||||
_title: 'Test Views Form Exposed Errors'
|
||||
_controller: '\Drupal\views_test_data\Controller\ViewsTestDataController::errorFormPage'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
|
|
@ -39,7 +39,7 @@ function views_test_data_views_data_alter() {
|
|||
function views_test_data_views_analyze(ViewExecutable $view) {
|
||||
\Drupal::state()->set('views_hook_test_views_analyze', TRUE);
|
||||
|
||||
$ret = array();
|
||||
$ret = [];
|
||||
|
||||
$ret[] = Analyzer::formatMessage(t('Test ok message'), 'ok');
|
||||
$ret[] = Analyzer::formatMessage(t('Test warning message'), 'warning');
|
||||
|
|
|
@ -22,10 +22,10 @@ function views_test_data_views_query_substitutions(ViewExecutable $view) {
|
|||
function views_test_data_views_form_substitutions() {
|
||||
\Drupal::state()->set('views_hook_test_views_form_substitutions', TRUE);
|
||||
$render = ['#markup' => '<em>unescaped</em>'];
|
||||
return array(
|
||||
return [
|
||||
'<!--will-be-escaped-->' => '<em>escaped</em>',
|
||||
'<!--will-be-not-escaped-->' => \Drupal::service('renderer')->renderPlain($render),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -42,7 +42,7 @@ class GlossaryViewTest extends JavascriptTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
|
||||
ViewTestData::createTestViews(get_class($this), ['views_test_config']);
|
||||
|
||||
// Create a Content type and some test nodes with titles that start with
|
||||
// different letters.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\FunctionalJavascript\Plugin\views\Handler;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
* Tests the grouped exposed filter admin UI.
|
||||
*
|
||||
* @group views
|
||||
*/
|
||||
class GroupedExposedFilterTest extends JavascriptTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['node', 'views', 'views_ui', 'user', 'views_test_config'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = ['test_exposed_admin_ui'];
|
||||
|
||||
/**
|
||||
* The account.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $account;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), ['views_test_config']);
|
||||
|
||||
// Disable automatic live preview to make the sequence of calls clearer.
|
||||
\Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
|
||||
|
||||
$this->account = $this->drupalCreateUser(['administer views']);
|
||||
$this->drupalLogin($this->account);
|
||||
|
||||
// Setup a node type that has the right fields for the test view.
|
||||
NodeType::create([
|
||||
'type' => 'page',
|
||||
])->save();
|
||||
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'body',
|
||||
'bundle' => 'page',
|
||||
])->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the right fields are shown and the right values set.
|
||||
*/
|
||||
public function testGroupedFilterValuesUI() {
|
||||
$web_assert = $this->assertSession();
|
||||
|
||||
$this->drupalGet('/admin/structure/views/view/test_exposed_admin_ui');
|
||||
$page = $this->getSession()->getPage();
|
||||
|
||||
// Open the dialog for the grouped filter.
|
||||
$page->clickLink('Content: Authored on (grouped)');
|
||||
$web_assert->assertWaitOnAjaxRequest();
|
||||
|
||||
// Test that the 'min' field is shown and that it contains the right value.
|
||||
$between_from = $page->findField('options[group_info][group_items][1][value][min]');
|
||||
$this->assertNotEmpty($between_from->isVisible());
|
||||
$this->assertEquals('2015-01-01', $between_from->getValue());
|
||||
|
||||
// Test that the 'max' field is shown and that it contains the right value.
|
||||
$between_to = $page->findField('options[group_info][group_items][1][value][max]');
|
||||
$this->assertNotEmpty($between_to->isVisible());
|
||||
$this->assertEquals('2016-01-01', $between_to->getValue());
|
||||
|
||||
$weight = $page->findField('options[group_info][group_items][1][weight]');
|
||||
|
||||
// If there are 3 items, values from -3 to 3 should be available.
|
||||
$this->assertFalse($weight->find('named', ['option', -4]));
|
||||
foreach (range(-3, 3) as $value) {
|
||||
$this->assertTrue($weight->find('named', ['option', $value]));
|
||||
}
|
||||
$this->assertFalse($weight->find('named', ['option', 4]));
|
||||
|
||||
$page->pressButton("Add another item");
|
||||
$web_assert->waitForField('options[group_info][group_items][4][title]');
|
||||
|
||||
// A new items was added, weight options should now be -4 to 4.
|
||||
$this->assertFalse($weight->find('named', ['option', -5]));
|
||||
foreach (range(-4, 4) as $value) {
|
||||
$this->assertTrue($weight->find('named', ['option', $value]));
|
||||
}
|
||||
$this->assertFalse($weight->find('named', ['option', 5]));
|
||||
}
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ class BasicTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_simple_argument');
|
||||
public static $testViews = ['test_view', 'test_simple_argument'];
|
||||
|
||||
/**
|
||||
* Tests a trivial result set.
|
||||
|
@ -30,10 +30,10 @@ class BasicTest extends ViewsKernelTestBase {
|
|||
|
||||
// Verify the result.
|
||||
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->dataSet(), array(
|
||||
$this->assertIdenticalResultset($view, $this->dataSet(), [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -44,55 +44,55 @@ class BasicTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a filter.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'operator' => '<',
|
||||
'value' => array(
|
||||
'value' => [
|
||||
'value' => '28',
|
||||
'min' => '',
|
||||
'max' => '',
|
||||
),
|
||||
],
|
||||
'group' => '0',
|
||||
'exposed' => FALSE,
|
||||
'expose' => array(
|
||||
'expose' => [
|
||||
'operator' => FALSE,
|
||||
'label' => '',
|
||||
),
|
||||
],
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
||||
// Build the expected result.
|
||||
$dataset = array(
|
||||
array(
|
||||
$dataset = [
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'id' => 4,
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(3, count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultSet($view, $dataset, array(
|
||||
$this->assertIdenticalResultSet($view, $dataset, [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,24 +101,24 @@ class BasicTest extends ViewsKernelTestBase {
|
|||
public function testSimpleArgument() {
|
||||
// Execute with a view
|
||||
$view = Views::getView('test_simple_argument');
|
||||
$view->setArguments(array(27));
|
||||
$view->setArguments([27]);
|
||||
$this->executeView($view);
|
||||
|
||||
// Build the expected result.
|
||||
$dataset = array(
|
||||
array(
|
||||
$dataset = [
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(1, count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultSet($view, $dataset, array(
|
||||
$this->assertIdenticalResultSet($view, $dataset, [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
|
||||
// Test "show all" if no argument is present.
|
||||
$view = Views::getView('test_simple_argument');
|
||||
|
@ -128,10 +128,10 @@ class BasicTest extends ViewsKernelTestBase {
|
|||
$dataset = $this->dataSet();
|
||||
|
||||
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultSet($view, $dataset, array(
|
||||
$this->assertIdenticalResultSet($view, $dataset, [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_entity_row_renderers');
|
||||
public static $testViews = ['test_entity_row_renderers'];
|
||||
|
||||
/**
|
||||
* An array of added languages.
|
||||
|
@ -51,13 +51,13 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('user');
|
||||
$this->installSchema('node', array('node_access'));
|
||||
$this->installConfig(array('node', 'language'));
|
||||
$this->installSchema('node', ['node_access']);
|
||||
$this->installConfig(['node', 'language']);
|
||||
|
||||
// The entity.node.canonical route must exist when nodes are rendered.
|
||||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->langcodes = array(\Drupal::languageManager()->getDefaultLanguage()->getId());
|
||||
$this->langcodes = [\Drupal::languageManager()->getDefaultLanguage()->getId()];
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$langcode = 'l' . $i;
|
||||
$this->langcodes[] = $langcode;
|
||||
|
@ -65,27 +65,27 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
}
|
||||
|
||||
// Make sure we do not try to render non-existing user data.
|
||||
$node_type = NodeType::create(array('type' => 'test'));
|
||||
$node_type = NodeType::create(['type' => 'test']);
|
||||
$node_type->setDisplaySubmitted(FALSE);
|
||||
$node_type->save();
|
||||
|
||||
$this->values = array();
|
||||
$this->values = [];
|
||||
$controller = \Drupal::entityManager()->getStorage('node');
|
||||
$langcode_index = 0;
|
||||
|
||||
for ($i = 0; $i < count($this->langcodes); $i++) {
|
||||
// Create a node with a different default language each time.
|
||||
$default_langcode = $this->langcodes[$langcode_index++];
|
||||
$node = $controller->create(array('type' => 'test', 'uid' => 0, 'langcode' => $default_langcode));
|
||||
$node = $controller->create(['type' => 'test', 'uid' => 0, 'langcode' => $default_langcode]);
|
||||
// Ensure the default language is processed first.
|
||||
$langcodes = array_merge(array($default_langcode), array_diff($this->langcodes, array($default_langcode)));
|
||||
$langcodes = array_merge([$default_langcode], array_diff($this->langcodes, [$default_langcode]));
|
||||
|
||||
foreach ($langcodes as $langcode) {
|
||||
// Ensure we have a predictable result order.
|
||||
$this->values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName();
|
||||
|
||||
if ($langcode != $default_langcode) {
|
||||
$node->addTranslation($langcode, array('title' => $this->values[$i][$langcode]));
|
||||
$node->addTranslation($langcode, ['title' => $this->values[$i][$langcode]]);
|
||||
}
|
||||
else {
|
||||
$node->setTitle($this->values[$i][$langcode]);
|
||||
|
@ -121,7 +121,7 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
* node.
|
||||
*/
|
||||
protected function checkLanguageRenderers($display, $values) {
|
||||
$expected = array(
|
||||
$expected = [
|
||||
$values[0]['en'],
|
||||
$values[0]['en'],
|
||||
$values[0]['en'],
|
||||
|
@ -131,10 +131,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
$values[2]['en'],
|
||||
$values[2]['en'],
|
||||
$values[2]['en'],
|
||||
);
|
||||
];
|
||||
$this->assertTranslations($display, '***LANGUAGE_language_content***', $expected, 'The current language renderer behaves as expected.');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
$values[0]['en'],
|
||||
$values[0]['en'],
|
||||
$values[0]['en'],
|
||||
|
@ -144,10 +144,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
$values[2]['l1'],
|
||||
$values[2]['l1'],
|
||||
$values[2]['l1'],
|
||||
);
|
||||
];
|
||||
$this->assertTranslations($display, '***LANGUAGE_entity_default***', $expected, 'The default language renderer behaves as expected.');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
$values[0]['en'],
|
||||
$values[0]['l0'],
|
||||
$values[0]['l1'],
|
||||
|
@ -157,10 +157,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
$values[2]['en'],
|
||||
$values[2]['l0'],
|
||||
$values[2]['l1'],
|
||||
);
|
||||
];
|
||||
$this->assertTranslations($display, '***LANGUAGE_entity_translation***', $expected, 'The translation language renderer behaves as expected.');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
$values[0][$this->langcodes[0]],
|
||||
$values[0][$this->langcodes[0]],
|
||||
$values[0][$this->langcodes[0]],
|
||||
|
@ -170,10 +170,10 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
$values[2][$this->langcodes[0]],
|
||||
$values[2][$this->langcodes[0]],
|
||||
$values[2][$this->langcodes[0]],
|
||||
);
|
||||
];
|
||||
$this->assertTranslations($display, '***LANGUAGE_site_default***', $expected, 'The site default language renderer behaves as expected.');
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
$values[0]['l0'],
|
||||
$values[0]['l0'],
|
||||
$values[0]['l0'],
|
||||
|
@ -183,7 +183,7 @@ class RowEntityRenderersTest extends ViewsKernelTestBase {
|
|||
$values[2]['l0'],
|
||||
$values[2]['l0'],
|
||||
$values[2]['l0'],
|
||||
);
|
||||
];
|
||||
$this->assertTranslations($display, 'l0', $expected, 'The language specific renderer behaves as expected.');
|
||||
}
|
||||
|
||||
|
|
|
@ -40,14 +40,14 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase {
|
|||
|
||||
// Install the necessary dependencies for node type creation to work.
|
||||
$this->installEntitySchema('node');
|
||||
$this->installConfig(array('field', 'node'));
|
||||
$this->installConfig(['field', 'node']);
|
||||
|
||||
$comment_type = CommentType::create(array(
|
||||
$comment_type = CommentType::create([
|
||||
'id' => 'comment',
|
||||
'label' => 'Comment settings',
|
||||
'description' => 'Comment settings',
|
||||
'target_entity_type_id' => 'node',
|
||||
));
|
||||
]);
|
||||
$comment_type->save();
|
||||
|
||||
$content_type = NodeType::create([
|
||||
|
@ -55,29 +55,29 @@ class ViewEntityDependenciesTest extends ViewsKernelTestBase {
|
|||
'name' => $this->randomString(),
|
||||
]);
|
||||
$content_type->save();
|
||||
$field_storage = FieldStorageConfig::create(array(
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'field_name' => Unicode::strtolower($this->randomMachineName()),
|
||||
'entity_type' => 'node',
|
||||
'type' => 'comment',
|
||||
));
|
||||
]);
|
||||
$field_storage->save();
|
||||
FieldConfig::create([
|
||||
'field_storage' => $field_storage,
|
||||
'bundle' => $content_type->id(),
|
||||
'label' => $this->randomMachineName() . '_label',
|
||||
'description' => $this->randomMachineName() . '_description',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'comment_type' => $comment_type->id(),
|
||||
),
|
||||
],
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'field_storage' => FieldStorageConfig::loadByName('node', 'body'),
|
||||
'bundle' => $content_type->id(),
|
||||
'label' => $this->randomMachineName() . '_body',
|
||||
'settings' => array('display_summary' => TRUE),
|
||||
'settings' => ['display_summary' => TRUE],
|
||||
])->save();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
|
||||
ViewTestData::createTestViews(get_class($this), ['views_test_config']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ class ViewsEntitySchemaSubscriberIntegrationTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['entity_test', 'user', 'text'];
|
||||
public static $modules = ['entity_test', 'entity_test_update', 'user', 'text'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
|
@ -79,7 +79,7 @@ class ViewsEntitySchemaSubscriberIntegrationTest extends ViewsKernelTestBase {
|
|||
|
||||
// Install every entity type's schema that wasn't installed in the parent
|
||||
// method.
|
||||
foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(array('user', 'entity_test'))) as $entity_type_id => $entity_type) {
|
||||
foreach (array_diff_key($this->entityManager->getDefinitions(), array_flip(['user', 'entity_test'])) as $entity_type_id => $entity_type) {
|
||||
$this->installEntitySchema($entity_type_id);
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,10 @@ class ViewsEntitySchemaSubscriberIntegrationTest extends ViewsKernelTestBase {
|
|||
public function testDeleteEntityType() {
|
||||
$entity_storage = $this->entityManager->getStorage('view');
|
||||
|
||||
// Make the test entity type revisionable.
|
||||
$this->updateEntityTypeToRevisionable();
|
||||
$this->entityDefinitionUpdateManager->applyUpdates();
|
||||
|
||||
$views = $entity_storage->loadMultiple();
|
||||
|
||||
// Ensure that all test views exists.
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\simpletest\BlockCreationTrait;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Entity\View;
|
||||
use Drupal\views\Views;
|
||||
|
@ -17,6 +17,8 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class AreaEntityTest extends ViewsKernelTestBase {
|
||||
|
||||
use BlockCreationTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
|
@ -29,7 +31,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_entity_area');
|
||||
public static $testViews = ['test_entity_area'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -42,14 +44,15 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpFixtures() {
|
||||
// Install the themes used for this test.
|
||||
$this->container->get('theme_installer')->install(['bartik']);
|
||||
$this->container->get('config.factory')->getEditable('system.theme')->set('default', 'bartik')->save();
|
||||
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('entity_test');
|
||||
$this->installConfig(['entity_test']);
|
||||
|
||||
Block::create([
|
||||
'id' => 'test_block',
|
||||
'plugin' => 'system_main_block',
|
||||
])->save();
|
||||
$this->placeBlock('system_main_block', ['id' => 'test_block']);
|
||||
|
||||
parent::setUpFixtures();
|
||||
}
|
||||
|
@ -67,9 +70,9 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test that all expected entity types have data.
|
||||
foreach (array_keys($expected_entities) as $entity) {
|
||||
$this->assertTrue(!empty($data['entity_' . $entity]), format_string('Views entity area data found for @entity', array('@entity' => $entity)));
|
||||
$this->assertTrue(!empty($data['entity_' . $entity]), format_string('Views entity area data found for @entity', ['@entity' => $entity]));
|
||||
// Test that entity_type is set correctly in the area data.
|
||||
$this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], format_string('Correct entity_type set for @entity', array('@entity' => $entity)));
|
||||
$this->assertEqual($entity, $data['entity_' . $entity]['area']['entity_type'], format_string('Correct entity_type set for @entity', ['@entity' => $entity]));
|
||||
}
|
||||
|
||||
$expected_entities = array_filter($entity_types, function (EntityTypeInterface $type) {
|
||||
|
@ -78,7 +81,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test that no configuration entity types have data.
|
||||
foreach (array_keys($expected_entities) as $entity) {
|
||||
$this->assertTrue(empty($data['entity_' . $entity]), format_string('Views config entity area data not found for @entity', array('@entity' => $entity)));
|
||||
$this->assertTrue(empty($data['entity_' . $entity]), format_string('Views config entity area data not found for @entity', ['@entity' => $entity]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,10 +90,10 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testEntityArea() {
|
||||
/** @var \Drupal\Core\Entity\EntityInterface[] $entities */
|
||||
$entities = array();
|
||||
$entities = [];
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
$random_label = $this->randomMachineName();
|
||||
$data = array('bundle' => 'entity_test', 'name' => $random_label);
|
||||
$data = ['bundle' => 'entity_test', 'name' => $random_label];
|
||||
$entity_test = $this->container->get('entity.manager')
|
||||
->getStorage('entity_test')
|
||||
->create($data);
|
||||
|
@ -134,7 +137,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
$this->assertTrue(strpos(trim((string) $result[0]), $entities[1]->label()) !== FALSE, 'The rendered entity appears in the footer of the view.');
|
||||
$this->assertTrue(strpos(trim((string) $result[0]), 'full') !== FALSE, 'The rendered entity appeared in the right view mode.');
|
||||
|
||||
$preview = $view->preview('default', array($entities[1]->id()));
|
||||
$preview = $view->preview('default', [$entities[1]->id()]);
|
||||
$this->setRawContent($renderer->renderRoot($preview));
|
||||
|
||||
$result = $this->xpath($header_xpath);
|
||||
|
@ -156,7 +159,7 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
$item['view_mode'] = 'test';
|
||||
$view->setHandler('default', 'header', 'entity_entity_test', $item);
|
||||
|
||||
$preview = $view->preview('default', array($entities[1]->id()));
|
||||
$preview = $view->preview('default', [$entities[1]->id()]);
|
||||
$this->setRawContent($renderer->renderRoot($preview));
|
||||
$view_class = 'js-view-dom-id-' . $view->dom_id;
|
||||
$result = $this->xpath('//div[@class = "' . $view_class . '"]/header[1]');
|
||||
|
@ -165,14 +168,14 @@ class AreaEntityTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test entity access.
|
||||
$view = Views::getView('test_entity_area');
|
||||
$preview = $view->preview('default', array($entities[2]->id()));
|
||||
$preview = $view->preview('default', [$entities[2]->id()]);
|
||||
$this->setRawContent($renderer->renderRoot($preview));
|
||||
$view_class = 'js-view-dom-id-' . $view->dom_id;
|
||||
$result = $this->xpath('//div[@class = "' . $view_class . '"]/footer[1]');
|
||||
$this->assertTrue(strpos($result[0], $entities[2]->label()) === FALSE, 'The rendered entity does not appear in the footer of the view.');
|
||||
|
||||
// Test the available view mode options.
|
||||
$form = array();
|
||||
$form = [];
|
||||
$form_state = (new FormState())
|
||||
->set('type', 'header');
|
||||
$view->display_handler->getHandler('header', 'entity_entity_test')->buildOptionsForm($form, $form_state);
|
||||
|
|
|
@ -18,7 +18,7 @@ class AreaMessagesTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_area_messages');
|
||||
public static $testViews = ['test_area_messages'];
|
||||
|
||||
/**
|
||||
* Tests the messages area handler.
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\block\Entity\Block;
|
||||
use Drupal\simpletest\BlockCreationTrait;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
|
@ -14,41 +14,41 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class AreaOrderTest extends ViewsKernelTestBase {
|
||||
|
||||
use BlockCreationTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'block');
|
||||
public static $modules = ['user', 'block'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_area_order');
|
||||
public static $testViews = ['test_area_order'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpFixtures() {
|
||||
Block::create(
|
||||
[
|
||||
'id' => 'bartik_branding',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_branding_block',
|
||||
'weight' => 1,
|
||||
]
|
||||
)->save();
|
||||
// Install the themes used for this test.
|
||||
$this->container->get('theme_installer')->install(['bartik']);
|
||||
|
||||
Block::create(
|
||||
[
|
||||
'id' => 'bartik_powered',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_powered_by_block',
|
||||
'weight' => 2,
|
||||
]
|
||||
)->save();
|
||||
$this->placeBlock('system_branding_block', [
|
||||
'id' => 'bartik_branding',
|
||||
'theme' => 'bartik',
|
||||
'plugin' => 'system_branding_block',
|
||||
'weight' => 1,
|
||||
]);
|
||||
|
||||
$this->placeBlock('system_powered_by_block', [
|
||||
'id' => 'bartik_powered',
|
||||
'theme' => 'bartik',
|
||||
'weight' => 2,
|
||||
]);
|
||||
|
||||
parent::setUpFixtures();
|
||||
}
|
||||
|
|
|
@ -13,19 +13,19 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class AreaTextTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('system', 'user', 'filter');
|
||||
public static $modules = ['system', 'user', 'filter'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(array('system', 'filter'));
|
||||
$this->installConfig(['system', 'filter']);
|
||||
$this->installEntitySchema('user');
|
||||
}
|
||||
|
||||
|
@ -37,16 +37,16 @@ class AreaTextTest extends ViewsKernelTestBase {
|
|||
|
||||
// add a text header
|
||||
$string = $this->randomMachineName();
|
||||
$view->displayHandlers->get('default')->overrideOption('header', array(
|
||||
'area' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('header', [
|
||||
'area' => [
|
||||
'id' => 'area',
|
||||
'table' => 'views',
|
||||
'field' => 'area',
|
||||
'content' => array(
|
||||
'content' => [
|
||||
'value' => $string,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
@ -60,7 +60,7 @@ class AreaTextTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual(check_markup($string), $renderer->renderRoot($build), 'Existent format should return something');
|
||||
|
||||
// Empty results, and it shouldn't be displayed .
|
||||
$this->assertEqual(array(), $view->display_handler->handlers['header']['area']->render(TRUE), 'No result should lead to no header');
|
||||
$this->assertEqual([], $view->display_handler->handlers['header']['area']->render(TRUE), 'No result should lead to no header');
|
||||
// Empty results, and it should be displayed.
|
||||
$view->display_handler->handlers['header']['area']->options['empty'] = TRUE;
|
||||
$build = $view->display_handler->handlers['header']['area']->render(TRUE);
|
||||
|
|
|
@ -18,7 +18,7 @@ class AreaTitleTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_area_title');
|
||||
public static $testViews = ['test_area_title'];
|
||||
|
||||
/**
|
||||
* Tests the title area handler.
|
||||
|
@ -34,7 +34,7 @@ class AreaTitleTest extends ViewsKernelTestBase {
|
|||
|
||||
$view->setDisplay('default');
|
||||
$this->executeView($view);
|
||||
$view->result = array();
|
||||
$view->result = [];
|
||||
$view->render();
|
||||
$this->assertEqual($view->getTitle(), 'test_title_empty', 'The title area should override the title if the result is empty.');
|
||||
$view->destroy();
|
||||
|
@ -47,7 +47,7 @@ class AreaTitleTest extends ViewsKernelTestBase {
|
|||
|
||||
$view->setDisplay('page_1');
|
||||
$this->executeView($view);
|
||||
$view->result = array();
|
||||
$view->result = [];
|
||||
$view->render();
|
||||
$this->assertEqual($view->getTitle(), 'test_title_empty', 'The title area should override the title if the result is empty.');
|
||||
$view->destroy();
|
||||
|
|
|
@ -18,14 +18,14 @@ class AreaViewTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user');
|
||||
public static $modules = ['user'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_simple_argument', 'test_area_view');
|
||||
public static $testViews = ['test_simple_argument', 'test_area_view'];
|
||||
|
||||
/**
|
||||
* Tests the view area handler.
|
||||
|
@ -44,7 +44,7 @@ class AreaViewTest extends ViewsKernelTestBase {
|
|||
$this->assertTrue(strpos($output, 'js-view-dom-id-' . $view->dom_id) !== FALSE, 'The test view is correctly embedded.');
|
||||
$view->destroy();
|
||||
|
||||
$view->setArguments(array(27));
|
||||
$view->setArguments([27]);
|
||||
$this->executeView($view);
|
||||
$output = $view->render();
|
||||
$output = $renderer->renderRoot($output);
|
||||
|
|
|
@ -18,16 +18,16 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_argument_date');
|
||||
public static $testViews = ['test_argument_date'];
|
||||
|
||||
/**
|
||||
* Stores the column map for this testCase.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'id' => 'id',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -35,14 +35,14 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
|
||||
$date_plugins = array(
|
||||
$date_plugins = [
|
||||
'date_fulldate',
|
||||
'date_day',
|
||||
'date_month',
|
||||
'date_week',
|
||||
'date_year',
|
||||
'date_year_month',
|
||||
);
|
||||
];
|
||||
foreach ($date_plugins as $plugin_id) {
|
||||
$data['views_test_data'][$plugin_id] = $data['views_test_data']['created'];
|
||||
$data['views_test_data'][$plugin_id]['real field'] = 'created';
|
||||
|
@ -59,25 +59,25 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
public function testCreatedFullDateHandler() {
|
||||
$view = Views::getView('test_argument_date');
|
||||
$view->setDisplay('default');
|
||||
$this->executeView($view, array('20000102'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 2);
|
||||
$this->executeView($view, ['20000102']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 2];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('default');
|
||||
$this->executeView($view, array('20000101'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 1);
|
||||
$expected[] = array('id' => 3);
|
||||
$expected[] = array('id' => 4);
|
||||
$expected[] = array('id' => 5);
|
||||
$this->executeView($view, ['20000101']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 1];
|
||||
$expected[] = ['id' => 3];
|
||||
$expected[] = ['id' => 4];
|
||||
$expected[] = ['id' => 5];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('default');
|
||||
$this->executeView($view, array('20001023'));
|
||||
$expected = array();
|
||||
$this->executeView($view, ['20001023']);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
}
|
||||
|
@ -90,25 +90,25 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
public function testDayHandler() {
|
||||
$view = Views::getView('test_argument_date');
|
||||
$view->setDisplay('embed_1');
|
||||
$this->executeView($view, array('02'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 2);
|
||||
$this->executeView($view, ['02']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 2];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_1');
|
||||
$this->executeView($view, array('01'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 1);
|
||||
$expected[] = array('id' => 3);
|
||||
$expected[] = array('id' => 4);
|
||||
$expected[] = array('id' => 5);
|
||||
$this->executeView($view, ['01']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 1];
|
||||
$expected[] = ['id' => 3];
|
||||
$expected[] = ['id' => 4];
|
||||
$expected[] = ['id' => 5];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_1');
|
||||
$this->executeView($view, array('23'));
|
||||
$expected = array();
|
||||
$this->executeView($view, ['23']);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -120,19 +120,19 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
public function testMonthHandler() {
|
||||
$view = Views::getView('test_argument_date');
|
||||
$view->setDisplay('embed_2');
|
||||
$this->executeView($view, array('01'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 1);
|
||||
$expected[] = array('id' => 2);
|
||||
$expected[] = array('id' => 3);
|
||||
$expected[] = array('id' => 4);
|
||||
$expected[] = array('id' => 5);
|
||||
$this->executeView($view, ['01']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 1];
|
||||
$expected[] = ['id' => 2];
|
||||
$expected[] = ['id' => 3];
|
||||
$expected[] = ['id' => 4];
|
||||
$expected[] = ['id' => 5];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_2');
|
||||
$this->executeView($view, array('12'));
|
||||
$expected = array();
|
||||
$this->executeView($view, ['12']);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -143,27 +143,27 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testWeekHandler() {
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 9, 26, 2008)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 9, 26, 2008)])
|
||||
->condition('id', 1)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 2, 29, 2004)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 2, 29, 2004)])
|
||||
->condition('id', 2)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2000)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2000)])
|
||||
->condition('id', 3)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 1, 10, 2000)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 1, 10, 2000)])
|
||||
->condition('id', 4)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 2, 1, 2000)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 2, 1, 2000)])
|
||||
->condition('id', 5)
|
||||
->execute();
|
||||
|
||||
|
@ -171,46 +171,46 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay('embed_3');
|
||||
// Check the week calculation for a leap year.
|
||||
// @see http://wikipedia.org/wiki/ISO_week_date#Calculation
|
||||
$this->executeView($view, array('39'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 1);
|
||||
$this->executeView($view, ['39']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 1];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_3');
|
||||
// Check the week calculation for the 29th of February in a leap year.
|
||||
// @see http://wikipedia.org/wiki/ISO_week_date#Calculation
|
||||
$this->executeView($view, array('09'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 2);
|
||||
$this->executeView($view, ['09']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 2];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_3');
|
||||
// The first jan 2000 was still in the last week of the previous year.
|
||||
$this->executeView($view, array('52'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 3);
|
||||
$this->executeView($view, ['52']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 3];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_3');
|
||||
$this->executeView($view, array('02'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 4);
|
||||
$this->executeView($view, ['02']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 4];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_3');
|
||||
$this->executeView($view, array('05'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 5);
|
||||
$this->executeView($view, ['05']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 5];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_3');
|
||||
$this->executeView($view, array('23'));
|
||||
$expected = array();
|
||||
$this->executeView($view, ['23']);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -221,47 +221,47 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testYearHandler() {
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2001)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2001)])
|
||||
->condition('id', 3)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2002)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2002)])
|
||||
->condition('id', 4)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2002)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2002)])
|
||||
->condition('id', 5)
|
||||
->execute();
|
||||
|
||||
$view = Views::getView('test_argument_date');
|
||||
$view->setDisplay('embed_4');
|
||||
$this->executeView($view, array('2000'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 1);
|
||||
$expected[] = array('id' => 2);
|
||||
$this->executeView($view, ['2000']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 1];
|
||||
$expected[] = ['id' => 2];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_4');
|
||||
$this->executeView($view, array('2001'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 3);
|
||||
$this->executeView($view, ['2001']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 3];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_4');
|
||||
$this->executeView($view, array('2002'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 4);
|
||||
$expected[] = array('id' => 5);
|
||||
$this->executeView($view, ['2002']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 4];
|
||||
$expected[] = ['id' => 5];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_4');
|
||||
$this->executeView($view, array('23'));
|
||||
$expected = array();
|
||||
$this->executeView($view, ['23']);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -272,47 +272,47 @@ class ArgumentDateTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testYearMonthHandler() {
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 1, 1, 2001)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 1, 1, 2001)])
|
||||
->condition('id', 3)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 4, 1, 2001)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 4, 1, 2001)])
|
||||
->condition('id', 4)
|
||||
->execute();
|
||||
|
||||
$this->container->get('database')->update('views_test_data')
|
||||
->fields(array('created' => gmmktime(0, 0, 0, 4, 1, 2001)))
|
||||
->fields(['created' => gmmktime(0, 0, 0, 4, 1, 2001)])
|
||||
->condition('id', 5)
|
||||
->execute();
|
||||
|
||||
$view = Views::getView('test_argument_date');
|
||||
$view->setDisplay('embed_5');
|
||||
$this->executeView($view, array('200001'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 1);
|
||||
$expected[] = array('id' => 2);
|
||||
$this->executeView($view, ['200001']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 1];
|
||||
$expected[] = ['id' => 2];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_5');
|
||||
$this->executeView($view, array('200101'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 3);
|
||||
$this->executeView($view, ['200101']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 3];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_5');
|
||||
$this->executeView($view, array('200104'));
|
||||
$expected = array();
|
||||
$expected[] = array('id' => 4);
|
||||
$expected[] = array('id' => 5);
|
||||
$this->executeView($view, ['200104']);
|
||||
$expected = [];
|
||||
$expected[] = ['id' => 4];
|
||||
$expected[] = ['id' => 5];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setDisplay('embed_5');
|
||||
$this->executeView($view, array('201301'));
|
||||
$expected = array();
|
||||
$this->executeView($view, ['201301']);
|
||||
$expected = [];
|
||||
$this->assertIdenticalResultset($view, $expected, $this->columnMap);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,9 +17,9 @@ class ArgumentNullTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['id']['argument']['id'] = 'null';
|
||||
|
||||
|
@ -32,13 +32,13 @@ class ArgumentNullTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a null argument.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', array(
|
||||
'null' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'null' => [
|
||||
'id' => 'null',
|
||||
'table' => 'views',
|
||||
'field' => 'null',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -57,15 +57,15 @@ class ArgumentNullTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a argument, which has null as handler.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', array(
|
||||
'id' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'id' => [
|
||||
'id' => 'id',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'id',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view, array(26));
|
||||
$this->executeView($view, [26]);
|
||||
|
||||
// The argument should be ignored, so every result should return.
|
||||
$this->assertEqual(5, count($view->result));
|
||||
|
|
|
@ -17,9 +17,9 @@ class FieldBooleanTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
function dataSet() {
|
||||
public function dataSet() {
|
||||
// Use default dataset but remove the age from john and paul
|
||||
$data = parent::dataSet();
|
||||
$data[0]['age'] = 0;
|
||||
|
@ -27,7 +27,7 @@ class FieldBooleanTest extends ViewsKernelTestBase {
|
|||
return $data;
|
||||
}
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['age']['field']['id'] = 'boolean';
|
||||
return $data;
|
||||
|
@ -37,14 +37,14 @@ class FieldBooleanTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -70,7 +70,7 @@ class FieldBooleanTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual('✔', $view->field['age']->advancedRender($view->result[1]));
|
||||
|
||||
// Set a custom output format.
|
||||
$view->field['age']->formats['test'] = array(t('Test-True'), t('Test-False'));
|
||||
$view->field['age']->formats['test'] = [t('Test-True'), t('Test-False')];
|
||||
$view->field['age']->options['type'] = 'test';
|
||||
$this->assertEqual(t('Test-False'), $view->field['age']->advancedRender($view->result[0]));
|
||||
$this->assertEqual(t('Test-True'), $view->field['age']->advancedRender($view->result[1]));
|
||||
|
|
|
@ -17,77 +17,77 @@ class FieldCounterTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user');
|
||||
public static $modules = ['user'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
function testSimple() {
|
||||
public function testSimple() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'counter' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'counter' => [
|
||||
'id' => 'counter',
|
||||
'table' => 'views',
|
||||
'field' => 'counter',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
],
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view->preview();
|
||||
|
||||
$counter = $view->style_plugin->getField(0, 'counter');
|
||||
$this->assertEqual($counter, '1', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 1, '@counter' => $counter)));
|
||||
$this->assertEqual($counter, '1', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 1, '@counter' => $counter]));
|
||||
$counter = $view->style_plugin->getField(1, 'counter');
|
||||
$this->assertEqual($counter, '2', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 2, '@counter' => $counter)));
|
||||
$this->assertEqual($counter, '2', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 2, '@counter' => $counter]));
|
||||
$counter = $view->style_plugin->getField(2, 'counter');
|
||||
$this->assertEqual($counter, '3', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => 3, '@counter' => $counter)));
|
||||
$this->assertEqual($counter, '3', format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => 3, '@counter' => $counter]));
|
||||
$view->destroy();
|
||||
$view->storage->invalidateCaches();
|
||||
|
||||
$view->setDisplay();
|
||||
$rand_start = rand(5, 10);
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'counter' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'counter' => [
|
||||
'id' => 'counter',
|
||||
'table' => 'views',
|
||||
'field' => 'counter',
|
||||
'relationship' => 'none',
|
||||
'counter_start' => $rand_start
|
||||
),
|
||||
'name' => array(
|
||||
],
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$view->preview();
|
||||
|
||||
$counter = $view->style_plugin->getField(0, 'counter');
|
||||
$expected_number = 0 + $rand_start;
|
||||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
|
||||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
|
||||
$counter = $view->style_plugin->getField(1, 'counter');
|
||||
$expected_number = 1 + $rand_start;
|
||||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
|
||||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
|
||||
$counter = $view->style_plugin->getField(2, 'counter');
|
||||
$expected_number = 2 + $rand_start;
|
||||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', array('@expected' => $expected_number, '@counter' => $counter)));
|
||||
$this->assertEqual($counter, (string) $expected_number, format_string('Make sure the expected number (@expected) patches with the rendered number (@counter)', ['@expected' => $expected_number, '@counter' => $counter]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo: Write tests for pager.
|
||||
*/
|
||||
function testPager() {
|
||||
public function testPager() {
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ class FieldCustomTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['name']['field']['id'] = 'custom';
|
||||
return $data;
|
||||
|
@ -38,17 +38,17 @@ class FieldCustomTest extends ViewsKernelTestBase {
|
|||
|
||||
// Alter the text of the field to a random string.
|
||||
$random = '<div>' . $this->randomMachineName() . '</div>';
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'alter' => array(
|
||||
'alter' => [
|
||||
'text' => $random,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -98,17 +98,17 @@ class FieldCustomTest extends ViewsKernelTestBase {
|
|||
|
||||
// Alter the text of the field to include XSS.
|
||||
$text = '<script>alert("kittens")</script>';
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'alter' => array(
|
||||
'alter' => [
|
||||
'text' => $text,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
$this->assertEqual(Xss::filter($text), $view->style_plugin->getField(0, 'name'));
|
||||
}
|
||||
|
|
|
@ -17,20 +17,20 @@ class FieldDateTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
$schema['views_test_data']['fields']['destroyed'] = array(
|
||||
$schema['views_test_data']['fields']['destroyed'] = [
|
||||
'description' => "The destruction date of this record",
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => FALSE,
|
||||
'default' => 0,
|
||||
);
|
||||
];
|
||||
return $schema;
|
||||
}
|
||||
|
||||
|
@ -40,14 +40,14 @@ class FieldDateTest extends ViewsKernelTestBase {
|
|||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['created']['field']['id'] = 'date';
|
||||
$data['views_test_data']['destroyed'] = array(
|
||||
$data['views_test_data']['destroyed'] = [
|
||||
'title' => 'Destroyed',
|
||||
'help' => 'Date in future this will be destroyed.',
|
||||
'field' => array('id' => 'date'),
|
||||
'argument' => array('id' => 'date'),
|
||||
'filter' => array('id' => 'date'),
|
||||
'sort' => array('id' => 'date'),
|
||||
);
|
||||
'field' => ['id' => 'date'],
|
||||
'argument' => ['id' => 'date'],
|
||||
'filter' => ['id' => 'date'],
|
||||
'sort' => ['id' => 'date'],
|
||||
];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -69,36 +69,36 @@ class FieldDateTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'created' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'created' => [
|
||||
'id' => 'created',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'created',
|
||||
'relationship' => 'none',
|
||||
// ISO 8601 format, see http://php.net/manual/function.date.php
|
||||
'custom_date_format' => 'c',
|
||||
),
|
||||
'destroyed' => array(
|
||||
],
|
||||
'destroyed' => [
|
||||
'id' => 'destroyed',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'destroyed',
|
||||
'relationship' => 'none',
|
||||
'custom_date_format' => 'c',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$time = gmmktime(0, 0, 0, 1, 1, 2000);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$timezones = array(
|
||||
$timezones = [
|
||||
NULL,
|
||||
'UTC',
|
||||
'America/New_York',
|
||||
);
|
||||
];
|
||||
|
||||
// Check each date/time in various timezones.
|
||||
foreach ($timezones as $timezone) {
|
||||
$dates = array(
|
||||
$dates = [
|
||||
'short' => format_date($time, 'short', '', $timezone),
|
||||
'medium' => format_date($time, 'medium', '', $timezone),
|
||||
'long' => format_date($time, 'long', '', $timezone),
|
||||
|
@ -111,30 +111,30 @@ class FieldDateTest extends ViewsKernelTestBase {
|
|||
'html_week' => format_date($time, 'html_week', '', $timezone),
|
||||
'html_year' => format_date($time, 'html_year', '', $timezone),
|
||||
'html_yearless_date' => format_date($time, 'html_yearless_date', '', $timezone),
|
||||
);
|
||||
];
|
||||
$this->assertRenderedDatesEqual($view, $dates, $timezone);
|
||||
}
|
||||
|
||||
// Check times in the past.
|
||||
$time_since = $this->container->get('date.formatter')->formatTimeDiffSince($time);
|
||||
$intervals = array(
|
||||
$intervals = [
|
||||
'raw time ago' => $time_since,
|
||||
'time ago' => t('%time ago', array('%time' => $time_since)),
|
||||
'time ago' => t('%time ago', ['%time' => $time_since]),
|
||||
'raw time span' => $time_since,
|
||||
'inverse time span' => "-$time_since",
|
||||
'time span' => t('%time ago', array('%time' => $time_since)),
|
||||
);
|
||||
'time span' => t('%time ago', ['%time' => $time_since]),
|
||||
];
|
||||
$this->assertRenderedDatesEqual($view, $intervals);
|
||||
|
||||
// Check times in the future.
|
||||
$time = gmmktime(0, 0, 0, 1, 1, 2050);
|
||||
$formatted = $this->container->get('date.formatter')->formatTimeDiffUntil($time);
|
||||
$intervals = array(
|
||||
$intervals = [
|
||||
'raw time span' => "-$formatted",
|
||||
'time span' => t('%time hence', array(
|
||||
'time span' => t('%time hence', [
|
||||
'%time' => $formatted,
|
||||
)),
|
||||
);
|
||||
]),
|
||||
];
|
||||
$this->assertRenderedFutureDatesEqual($view, $intervals);
|
||||
}
|
||||
|
||||
|
@ -151,10 +151,10 @@ class FieldDateTest extends ViewsKernelTestBase {
|
|||
protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
|
||||
foreach ($map as $date_format => $expected_result) {
|
||||
$view->field['created']->options['date_format'] = $date_format;
|
||||
$t_args = array(
|
||||
$t_args = [
|
||||
'%value' => $expected_result,
|
||||
'%format' => $date_format,
|
||||
);
|
||||
];
|
||||
if (isset($timezone)) {
|
||||
$t_args['%timezone'] = $timezone;
|
||||
$message = t('Value %value in %format format for timezone %timezone matches.', $t_args);
|
||||
|
@ -180,11 +180,11 @@ class FieldDateTest extends ViewsKernelTestBase {
|
|||
foreach ($map as $format => $result) {
|
||||
$view->field['destroyed']->options['date_format'] = $format;
|
||||
$view_result = $view->field['destroyed']->advancedRender($view->result[0]);
|
||||
$t_args = array(
|
||||
$t_args = [
|
||||
'%value' => $result,
|
||||
'%format' => $format,
|
||||
'%actual' => $view_result,
|
||||
);
|
||||
];
|
||||
$message = t('Value %value in %format matches %actual', $t_args);
|
||||
$this->assertEqual($view_result, $result, $message);
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ class FieldEntityLinkTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_entity_test_link');
|
||||
public static $testViews = ['test_entity_test_link'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'entity_test');
|
||||
public static $modules = ['user', 'entity_test'];
|
||||
|
||||
/**
|
||||
* An admin user account.
|
||||
|
|
|
@ -8,7 +8,7 @@ use Drupal\entity_test\Entity\EntityTestRev;
|
|||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\views\Plugin\views\field\Field;
|
||||
use Drupal\views\Plugin\views\field\EntityField;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Views;
|
||||
|
@ -16,7 +16,7 @@ use Drupal\views\Views;
|
|||
/**
|
||||
* Provides some integration tests for the Field handler.
|
||||
*
|
||||
* @see \Drupal\views\Plugin\views\field\Field
|
||||
* @see \Drupal\views\Plugin\views\field\EntityField
|
||||
* @group views
|
||||
*/
|
||||
class FieldFieldTest extends ViewsKernelTestBase {
|
||||
|
@ -70,7 +70,7 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$this->installEntitySchema('entity_test');
|
||||
$this->installEntitySchema('entity_test_rev');
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
|
||||
ViewTestData::createTestViews(get_class($this), ['views_test_config']);
|
||||
|
||||
// Bypass any field access.
|
||||
$this->adminUser = User::create(['name' => $this->randomString()]);
|
||||
|
@ -229,8 +229,8 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$executable = Views::getView('test_field_field_test');
|
||||
$executable->execute();
|
||||
|
||||
$this->assertTrue($executable->field['id'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test'] instanceof Field);
|
||||
$this->assertTrue($executable->field['id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test'] instanceof EntityField);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -299,9 +299,9 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$executable = Views::getView('test_field_alias_test');
|
||||
$executable->execute();
|
||||
|
||||
$this->assertTrue($executable->field['id'] instanceof Field);
|
||||
$this->assertTrue($executable->field['name'] instanceof Field);
|
||||
$this->assertTrue($executable->field['name_alias'] instanceof Field);
|
||||
$this->assertTrue($executable->field['id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['name'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['name_alias'] instanceof EntityField);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -348,10 +348,10 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$timezones[] = $user->getTimeZone();
|
||||
}
|
||||
|
||||
$this->assertTrue($executable->field['field_test_multiple'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof Field);
|
||||
$this->assertTrue($executable->field['timezone'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test_multiple'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['timezone'] instanceof EntityField);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -421,8 +421,8 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$executable = Views::getView('test_field_field_revision_test');
|
||||
$executable->execute();
|
||||
|
||||
$this->assertTrue($executable->field['name'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test'] instanceof Field);
|
||||
$this->assertTrue($executable->field['name'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test'] instanceof EntityField);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -475,12 +475,12 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
$timezones[] = $user->getTimeZone();
|
||||
}
|
||||
|
||||
$this->assertTrue($executable->field['id'] instanceof Field);
|
||||
$this->assertTrue($executable->field['revision_id'] instanceof Field);
|
||||
$this->assertTrue($executable->field['timezone'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test_multiple'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof Field);
|
||||
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof Field);
|
||||
$this->assertTrue($executable->field['id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['revision_id'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['timezone'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_1'] instanceof EntityField);
|
||||
$this->assertTrue($executable->field['field_test_multiple_2'] instanceof EntityField);
|
||||
|
||||
$this->assertIdenticalResultset($executable,
|
||||
[
|
||||
|
@ -551,7 +551,7 @@ class FieldFieldTest extends ViewsKernelTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests \Drupal\views\Plugin\views\field\Field::getValue
|
||||
* Tests \Drupal\views\Plugin\views\field\EntityField::getValue
|
||||
*/
|
||||
public function testGetValueMethod() {
|
||||
$bundle = 'test_bundle';
|
||||
|
|
|
@ -18,9 +18,9 @@ class FieldFileSizeTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
function dataSet() {
|
||||
public function dataSet() {
|
||||
$data = parent::dataSet();
|
||||
$data[0]['age'] = 0;
|
||||
$data[1]['age'] = 10;
|
||||
|
@ -30,7 +30,7 @@ class FieldFileSizeTest extends ViewsKernelTestBase {
|
|||
return $data;
|
||||
}
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['age']['field']['id'] = 'file_size';
|
||||
|
||||
|
@ -41,13 +41,13 @@ class FieldFileSizeTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
|
|
@ -15,23 +15,23 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class FieldKernelTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('user');
|
||||
public static $modules = ['user'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_field_tokens', 'test_field_argument_tokens', 'test_field_output');
|
||||
public static $testViews = ['test_view', 'test_field_tokens', 'test_field_argument_tokens', 'test_field_output'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_name' => 'name',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -73,7 +73,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
$id_field = $view->field['id'];
|
||||
$id_field->additional_fields['job'] = 'job';
|
||||
// Choose also a field alias key which doesn't match to the table field.
|
||||
$id_field->additional_fields['created_test'] = array('table' => 'views_test_data', 'field' => 'created');
|
||||
$id_field->additional_fields['created_test'] = ['table' => 'views_test_data', 'field' => 'created'];
|
||||
$view->build();
|
||||
|
||||
// Make sure the field aliases have the expected value.
|
||||
|
@ -412,7 +412,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests everything related to empty output of a field.
|
||||
*/
|
||||
function testEmpty() {
|
||||
public function testEmpty() {
|
||||
$this->_testHideIfEmpty();
|
||||
$this->_testEmptyText();
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
* This tests alters the result to get easier and less coupled results. It is
|
||||
* important that assertIdentical() is used in this test since in PHP 0 == ''.
|
||||
*/
|
||||
function _testHideIfEmpty() {
|
||||
public function _testHideIfEmpty() {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
|
@ -704,7 +704,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests the usage of the empty text.
|
||||
*/
|
||||
function _testEmptyText() {
|
||||
public function _testEmptyText() {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
|
@ -754,7 +754,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests views_handler_field::isValueEmpty().
|
||||
*/
|
||||
function testIsValueEmpty() {
|
||||
public function testIsValueEmpty() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->initHandlers();
|
||||
$field = $view->field['name'];
|
||||
|
@ -778,10 +778,10 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testClickSortable() {
|
||||
// Test that clickSortable is TRUE by default.
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
);
|
||||
];
|
||||
$plugin = $this->container->get('plugin.manager.views.field')->getHandler($item);
|
||||
$this->assertTrue($plugin->clickSortable(), 'TRUE as a default value is correct.');
|
||||
|
||||
|
@ -801,7 +801,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testTrimText() {
|
||||
// Test unicode. See https://www.drupal.org/node/513396#comment-2839416.
|
||||
$text = array(
|
||||
$text = [
|
||||
'Tuy nhiên, những hi vọng',
|
||||
'Giả sử chúng tôi có 3 Apple',
|
||||
'siêu nhỏ này là bộ xử lý',
|
||||
|
@ -810,12 +810,12 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
'của hãng bao gồm ba dòng',
|
||||
'сд асд асд ас',
|
||||
'асд асд асд ас'
|
||||
);
|
||||
];
|
||||
// Just test maxlength without word boundary.
|
||||
$alter = array(
|
||||
$alter = [
|
||||
'max_length' => 10,
|
||||
);
|
||||
$expect = array(
|
||||
];
|
||||
$expect = [
|
||||
'Tuy nhiên,',
|
||||
'Giả sử chú',
|
||||
'siêu nhỏ n',
|
||||
|
@ -824,7 +824,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
'của hãng b',
|
||||
'сд асд асд',
|
||||
'асд асд ас',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($text as $key => $line) {
|
||||
$result_text = FieldPluginBase::trimText($alter, $line);
|
||||
|
@ -833,7 +833,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test also word_boundary
|
||||
$alter['word_boundary'] = TRUE;
|
||||
$expect = array(
|
||||
$expect = [
|
||||
'Tuy nhiên',
|
||||
'Giả sử',
|
||||
'siêu nhỏ',
|
||||
|
@ -842,7 +842,7 @@ class FieldKernelTest extends ViewsKernelTestBase {
|
|||
'của hãng',
|
||||
'сд асд',
|
||||
'асд асд',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($text as $key => $line) {
|
||||
$result_text = FieldPluginBase::trimText($alter, $line);
|
||||
|
|
|
@ -13,16 +13,16 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class FieldUrlTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['name']['field']['id'] = 'url';
|
||||
return $data;
|
||||
|
@ -32,15 +32,15 @@ class FieldUrlTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'display_as_link' => FALSE,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -50,14 +50,14 @@ class FieldUrlTest extends ViewsKernelTestBase {
|
|||
$view->destroy();
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\views\Kernel\Handler;
|
||||
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests the queryOpBoolean() with default operator.
|
||||
*
|
||||
* @group views
|
||||
* @see \Drupal\views\Plugin\views\filter\BooleanOperator
|
||||
*/
|
||||
class FilterBooleanOperatorDefaultTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'views_test_data'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function viewsData() {
|
||||
$views_data = parent::viewsData();
|
||||
|
||||
$views_data['views_test_data']['status']['filter']['id'] = 'boolean_default';
|
||||
|
||||
return $views_data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the queryOpBoolean() with default operator.
|
||||
*/
|
||||
public function testFilterBooleanOperatorDefault() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'field' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'value' => 0,
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
$this->assertCount(2, $view->result);
|
||||
}
|
||||
|
||||
}
|
|
@ -19,23 +19,23 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_id' => 'id',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -43,13 +43,13 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
|
|||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
|
||||
$schema['views_test_data']['fields']['status'] = array(
|
||||
$schema['views_test_data']['fields']['status'] = [
|
||||
'description' => 'The status of this record',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
);
|
||||
];
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
@ -91,20 +91,20 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a the status boolean filter.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'status' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'field' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'value' => 0,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 2),
|
||||
array('id' => 4),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 2],
|
||||
['id' => 4],
|
||||
];
|
||||
|
||||
$this->assertEqual(2, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -113,21 +113,21 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add the status boolean filter.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'status' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'field' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'value' => 1,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 1),
|
||||
array('id' => 3),
|
||||
array('id' => 5),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 1],
|
||||
['id' => 3],
|
||||
['id' => 5],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -140,32 +140,32 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
|
|||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = Views::getView('test_view');
|
||||
|
||||
$view->setExposedInput(array('status' => 1));
|
||||
$view->setExposedInput(['status' => 1]);
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 1),
|
||||
array('id' => 3),
|
||||
array('id' => 5),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 1],
|
||||
['id' => 3],
|
||||
['id' => 5],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setExposedInput(array('status' => 2));
|
||||
$view->setExposedInput(['status' => 2]);
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 2),
|
||||
array('id' => 4),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 2],
|
||||
['id' => 4],
|
||||
];
|
||||
|
||||
$this->assertEqual(2, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -178,38 +178,38 @@ class FilterBooleanOperatorStringTest extends ViewsKernelTestBase {
|
|||
* Returns the filter configuration for exposed filters.
|
||||
*/
|
||||
protected function getGroupedExposedFilters() {
|
||||
$filters = array(
|
||||
'status' => array(
|
||||
$filters = [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'status',
|
||||
'relationship' => 'none',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'expose' => [
|
||||
'operator' => 'status_op',
|
||||
'label' => 'status',
|
||||
'identifier' => 'status',
|
||||
),
|
||||
],
|
||||
'is_grouped' => TRUE,
|
||||
'group_info' => array(
|
||||
'group_info' => [
|
||||
'label' => 'status',
|
||||
'identifier' => 'status',
|
||||
'default_group' => 'All',
|
||||
'group_items' => array(
|
||||
1 => array(
|
||||
'group_items' => [
|
||||
1 => [
|
||||
'title' => 'Active',
|
||||
'operator' => '=',
|
||||
'value' => '1',
|
||||
),
|
||||
2 => array(
|
||||
],
|
||||
2 => [
|
||||
'title' => 'Blocked',
|
||||
'operator' => '=',
|
||||
'value' => '0',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,23 +18,23 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_id' => 'id',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests the BooleanOperator filter.
|
||||
|
@ -44,20 +44,20 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a the status boolean filter.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'status' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'field' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'value' => 0,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 2),
|
||||
array('id' => 4),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 2],
|
||||
['id' => 4],
|
||||
];
|
||||
|
||||
$this->assertEqual(2, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -66,21 +66,21 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add the status boolean filter.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'status' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'field' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'value' => 1,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 1),
|
||||
array('id' => 3),
|
||||
array('id' => 5),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 1],
|
||||
['id' => 3],
|
||||
['id' => 5],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -89,22 +89,22 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Testing the same scenario but using the reverse status and operation.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'status' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'field' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'value' => 0,
|
||||
'operator' => '!=',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 1),
|
||||
array('id' => 3),
|
||||
array('id' => 5),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 1],
|
||||
['id' => 3],
|
||||
['id' => 5],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -117,32 +117,32 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = Views::getView('test_view');
|
||||
|
||||
$view->setExposedInput(array('status' => 1));
|
||||
$view->setExposedInput(['status' => 1]);
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 1),
|
||||
array('id' => 3),
|
||||
array('id' => 5),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 1],
|
||||
['id' => 3],
|
||||
['id' => 5],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
$view->setExposedInput(array('status' => 2));
|
||||
$view->setExposedInput(['status' => 2]);
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 2),
|
||||
array('id' => 4),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 2],
|
||||
['id' => 4],
|
||||
];
|
||||
|
||||
$this->assertEqual(2, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -156,11 +156,11 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array('id' => 1),
|
||||
array('id' => 3),
|
||||
array('id' => 5),
|
||||
);
|
||||
$expected_result = [
|
||||
['id' => 1],
|
||||
['id' => 3],
|
||||
['id' => 5],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -172,45 +172,45 @@ class FilterBooleanOperatorTest extends ViewsKernelTestBase {
|
|||
* @return array
|
||||
*/
|
||||
protected function getGroupedExposedFilters() {
|
||||
$filters = array(
|
||||
'status' => array(
|
||||
$filters = [
|
||||
'status' => [
|
||||
'id' => 'status',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'status',
|
||||
'relationship' => 'none',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'expose' => [
|
||||
'operator' => 'status_op',
|
||||
'label' => 'status',
|
||||
'identifier' => 'status',
|
||||
),
|
||||
],
|
||||
'is_grouped' => TRUE,
|
||||
'group_info' => array(
|
||||
'group_info' => [
|
||||
'label' => 'status',
|
||||
'identifier' => 'status',
|
||||
'default_group' => 'All',
|
||||
'group_items' => array(
|
||||
1 => array(
|
||||
'group_items' => [
|
||||
1 => [
|
||||
'title' => 'Active',
|
||||
'operator' => '=',
|
||||
'value' => '1',
|
||||
),
|
||||
2 => array(
|
||||
],
|
||||
2 => [
|
||||
'title' => 'Blocked',
|
||||
'operator' => '=',
|
||||
'value' => '0',
|
||||
),
|
||||
],
|
||||
// This group should return the same results as group 1, because it
|
||||
// is the negation of group 2.
|
||||
3 => array(
|
||||
3 => [
|
||||
'title' => 'Active (reverse)',
|
||||
'operator' => '!=',
|
||||
'value' => '0',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
|
|
@ -15,24 +15,24 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('entity_test');
|
||||
public static $modules = ['entity_test'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'entity_test_fields');
|
||||
public static $testViews = ['test_view', 'entity_test_fields'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_job' => 'job',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -48,50 +48,50 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
$fields = $view->displayHandlers->get('default')->getOption('fields');
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
|
||||
'job' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + [
|
||||
'job' => [
|
||||
'id' => 'job',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'job',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'combine',
|
||||
'table' => 'views',
|
||||
'field' => 'combine',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'contains',
|
||||
'fields' => array(
|
||||
'fields' => [
|
||||
'name',
|
||||
'job',
|
||||
),
|
||||
],
|
||||
'value' => 'ing',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'job' => 'Singer',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
'job' => 'Singer',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'job' => 'Drummer',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ginger',
|
||||
'job' => NULL,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -103,46 +103,46 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
$fields = $view->displayHandlers->get('default')->getOption('fields');
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
|
||||
'job' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + [
|
||||
'job' => [
|
||||
'id' => 'job',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'job',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'combine',
|
||||
'table' => 'views',
|
||||
'field' => 'combine',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'word',
|
||||
'fields' => array(
|
||||
'fields' => [
|
||||
'name',
|
||||
'job',
|
||||
),
|
||||
],
|
||||
'value' => 'singer ringo',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'job' => 'Singer',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
'job' => 'Singer',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'job' => 'Drummer',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -154,39 +154,39 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
$fields = $view->displayHandlers->get('default')->getOption('fields');
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
|
||||
'job' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + [
|
||||
'job' => [
|
||||
'id' => 'job',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'job',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Set the filtering to allwords and simulate searching for a phrase.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'combine',
|
||||
'table' => 'views',
|
||||
'field' => 'combine',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'allwords',
|
||||
'fields' => array(
|
||||
'fields' => [
|
||||
'name',
|
||||
'job',
|
||||
'age',
|
||||
),
|
||||
],
|
||||
'value' => '25 "john singer"',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'job' => 'Singer',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -202,40 +202,40 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
$fields = $view->displayHandlers->get('default')->getOption('fields');
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
|
||||
'job' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + [
|
||||
'job' => [
|
||||
'id' => 'job',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'job',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'combine',
|
||||
'table' => 'views',
|
||||
'field' => 'combine',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'contains',
|
||||
'fields' => array(
|
||||
'fields' => [
|
||||
'name',
|
||||
'job',
|
||||
// Add a dummy field to the combined fields to simulate
|
||||
// a removed or deleted field.
|
||||
'dummy',
|
||||
),
|
||||
],
|
||||
'value' => 'ing',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
// Make sure this view will not get displayed.
|
||||
$this->assertTrue($view->build_info['fail'], "View build has been marked as failed.");
|
||||
// Make sure this view does not pass validation with the right error.
|
||||
$errors = $view->validate();
|
||||
$this->assertEquals(t('Field %field set in %filter is not set in display %display.', array('%field' => 'dummy', '%filter' => 'Global: Combine fields filter', '%display' => 'Master')), reset($errors['default']));
|
||||
$this->assertEquals(t('Field %field set in %filter is not set in display %display.', ['%field' => 'dummy', '%filter' => 'Global: Combine fields filter', '%display' => 'Master']), reset($errors['default']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -247,30 +247,30 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Set the rows to a plugin type that doesn't support fields.
|
||||
$view->displayHandlers->get('default')->overrideOption('row', array(
|
||||
$view->displayHandlers->get('default')->overrideOption('row', [
|
||||
'type' => 'entity:entity_test',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'view_mode' => 'teaser',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'name' => [
|
||||
'id' => 'combine',
|
||||
'table' => 'views',
|
||||
'field' => 'combine',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'contains',
|
||||
'fields' => array(
|
||||
'fields' => [
|
||||
'name',
|
||||
),
|
||||
],
|
||||
'value' => 'ing',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
$this->executeView($view);
|
||||
$errors = $view->validate();
|
||||
// Check that the right error is shown.
|
||||
$this->assertEquals(t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', array('%filter' => 'Global: Combine fields filter', '%display' => 'Master')), reset($errors['default']));
|
||||
$this->assertEquals(t('%display: %filter can only be used on displays that use fields. Set the style or row format for that display to one using fields to use the combine field filter.', ['%filter' => 'Global: Combine fields filter', '%display' => 'Master']), reset($errors['default']));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,13 +278,13 @@ class FilterCombineTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
protected function dataSet() {
|
||||
$data_set = parent::dataSet();
|
||||
$data_set[] = array(
|
||||
$data_set[] = [
|
||||
'name' => 'Ginger',
|
||||
'age' => 25,
|
||||
'job' => NULL,
|
||||
'created' => gmmktime(0, 0, 0, 1, 2, 2000),
|
||||
'status' => 1,
|
||||
);
|
||||
];
|
||||
return $data_set;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,52 +12,52 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class FilterEqualityTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_name' => 'name',
|
||||
);
|
||||
];
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['name']['filter']['id'] = 'equality';
|
||||
return $data;
|
||||
}
|
||||
|
||||
function testEqual() {
|
||||
public function testEqual() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'operator' => '=',
|
||||
'value' => 'Ringo',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -74,45 +74,45 @@ class FilterEqualityTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
function testNotEqual() {
|
||||
public function testNotEqual() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
'operator' => '!=',
|
||||
'value' => 'Ringo',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Paul',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -129,27 +129,27 @@ class FilterEqualityTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Paul',
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
||||
protected function getGroupedExposedFilters() {
|
||||
$filters = array(
|
||||
'name' => array(
|
||||
$filters = [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'plugin_id' => 'equality',
|
||||
'table' => 'views_test_data',
|
||||
|
@ -157,31 +157,31 @@ class FilterEqualityTest extends ViewsKernelTestBase {
|
|||
'relationship' => 'none',
|
||||
'group' => 1,
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'expose' => [
|
||||
'operator' => 'name_op',
|
||||
'label' => 'name',
|
||||
'identifier' => 'name',
|
||||
),
|
||||
],
|
||||
'is_grouped' => TRUE,
|
||||
'group_info' => array(
|
||||
'group_info' => [
|
||||
'label' => 'name',
|
||||
'identifier' => 'name',
|
||||
'default_group' => 'All',
|
||||
'group_items' => array(
|
||||
1 => array(
|
||||
'group_items' => [
|
||||
1 => [
|
||||
'title' => 'Name is equal to Ringo',
|
||||
'operator' => '=',
|
||||
'value' => 'Ringo',
|
||||
),
|
||||
2 => array(
|
||||
],
|
||||
2 => [
|
||||
'title' => 'Name is not equal to Ringo',
|
||||
'operator' => '!=',
|
||||
'value' => 'Ringo',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,26 +12,26 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class FilterInOperatorTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
);
|
||||
];
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['age']['filter']['id'] = 'in_operator';
|
||||
return $data;
|
||||
|
@ -42,28 +42,28 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a in_operator ordering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'field' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'value' => array(26, 30),
|
||||
'value' => [26, 30],
|
||||
'operator' => 'in',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array(
|
||||
$expected_result = [
|
||||
[
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEqual(2, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -72,32 +72,32 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a in_operator ordering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'field' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'value' => array(26, 30),
|
||||
'value' => [26, 30],
|
||||
'operator' => 'not in',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array(
|
||||
$expected_result = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -114,16 +114,16 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array(
|
||||
$expected_result = [
|
||||
[
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEqual(2, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
|
@ -140,58 +140,58 @@ class FilterInOperatorTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array(
|
||||
$expected_result = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEqual(3, count($view->result));
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
}
|
||||
|
||||
protected function getGroupedExposedFilters() {
|
||||
$filters = array(
|
||||
'age' => array(
|
||||
$filters = [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'expose' => [
|
||||
'operator' => 'age_op',
|
||||
'label' => 'age',
|
||||
'identifier' => 'age',
|
||||
),
|
||||
],
|
||||
'is_grouped' => TRUE,
|
||||
'group_info' => array(
|
||||
'group_info' => [
|
||||
'label' => 'age',
|
||||
'identifier' => 'age',
|
||||
'default_group' => 'All',
|
||||
'group_items' => array(
|
||||
1 => array(
|
||||
'group_items' => [
|
||||
1 => [
|
||||
'title' => 'Age is one of 26, 30',
|
||||
'operator' => 'in',
|
||||
'value' => array(26, 30),
|
||||
),
|
||||
2 => array(
|
||||
'value' => [26, 30],
|
||||
],
|
||||
2 => [
|
||||
'title' => 'Age is not one of 26, 30',
|
||||
'operator' => 'not in',
|
||||
'value' => array(26, 30),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
'value' => [26, 30],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,26 +12,26 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class FilterNumericTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Map column names.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
);
|
||||
];
|
||||
|
||||
function viewsData() {
|
||||
public function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['age']['filter']['allow empty'] = TRUE;
|
||||
$data['views_test_data']['id']['filter']['allow empty'] = FALSE;
|
||||
|
@ -44,24 +44,24 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'operator' => '=',
|
||||
'value' => array('value' => 28),
|
||||
),
|
||||
));
|
||||
'value' => ['value' => 28],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -78,12 +78,12 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -92,35 +92,35 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'between',
|
||||
'value' => array(
|
||||
'value' => [
|
||||
'min' => 26,
|
||||
'max' => 29,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
|
||||
// test not between
|
||||
|
@ -128,31 +128,31 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'not between',
|
||||
'value' => array(
|
||||
'value' => [
|
||||
'min' => 26,
|
||||
'max' => 29,
|
||||
),
|
||||
),
|
||||
));
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -169,20 +169,20 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -199,16 +199,76 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the numeric filter handler with the 'regular_expression' operator.
|
||||
*/
|
||||
public function testFilterNumericRegularExpression() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
// Filtering by regular expression pattern.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'regular_expression',
|
||||
'value' => [
|
||||
'value' => '2[8]',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the numeric filter handler with the 'regular_expression' operator
|
||||
* to grouped exposed filters.
|
||||
*/
|
||||
public function testFilterNumericExposedGroupedRegularExpression() {
|
||||
$filters = $this->getGroupedExposedFilters();
|
||||
$view = Views::getView('test_view');
|
||||
$view->newDisplay('page', 'Page', 'page_1');
|
||||
|
||||
// Filter: Age, Operator: regular_expression, Value: 2[7-8]
|
||||
$filters['age']['group_info']['default_group'] = 6;
|
||||
$view->setDisplay('page_1');
|
||||
$view->displayHandlers->get('page_1')->overrideOption('filters', $filters);
|
||||
$view->save();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -217,58 +277,58 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'empty',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
);
|
||||
$resultset = [
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
|
||||
$view->destroy();
|
||||
$view->setDisplay();
|
||||
|
||||
// Change the filtering
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'operator' => 'not empty',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -285,8 +345,8 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
);
|
||||
$resultset = [
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -303,28 +363,28 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$this->container->get('router.builder')->rebuild();
|
||||
|
||||
$this->executeView($view);
|
||||
$resultset = array(
|
||||
array(
|
||||
$resultset = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'age' => 25,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'George',
|
||||
'age' => 27,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Ringo',
|
||||
'age' => 28,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Paul',
|
||||
'age' => 26,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'Meredith',
|
||||
'age' => 30,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $resultset, $this->columnMap);
|
||||
}
|
||||
|
||||
|
@ -332,20 +392,20 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'id' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'id' => [
|
||||
'id' => 'id',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'age' => array(
|
||||
],
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$view->initHandlers();
|
||||
|
||||
|
@ -359,58 +419,65 @@ class FilterNumericTest extends ViewsKernelTestBase {
|
|||
}
|
||||
|
||||
protected function getGroupedExposedFilters() {
|
||||
$filters = array(
|
||||
'age' => array(
|
||||
$filters = [
|
||||
'age' => [
|
||||
'id' => 'age',
|
||||
'plugin_id' => 'numeric',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'expose' => [
|
||||
'operator' => 'age_op',
|
||||
'label' => 'age',
|
||||
'identifier' => 'age',
|
||||
),
|
||||
],
|
||||
'is_grouped' => TRUE,
|
||||
'group_info' => array(
|
||||
'group_info' => [
|
||||
'label' => 'age',
|
||||
'identifier' => 'age',
|
||||
'default_group' => 'All',
|
||||
'group_items' => array(
|
||||
1 => array(
|
||||
'group_items' => [
|
||||
1 => [
|
||||
'title' => 'Age is 28',
|
||||
'operator' => '=',
|
||||
'value' => array('value' => 28),
|
||||
),
|
||||
2 => array(
|
||||
'value' => ['value' => 28],
|
||||
],
|
||||
2 => [
|
||||
'title' => 'Age is between 26 and 29',
|
||||
'operator' => 'between',
|
||||
'value' => array(
|
||||
'value' => [
|
||||
'min' => 26,
|
||||
'max' => 29,
|
||||
),
|
||||
),
|
||||
3 => array(
|
||||
],
|
||||
],
|
||||
3 => [
|
||||
'title' => 'Age is not between 26 and 29',
|
||||
'operator' => 'not between',
|
||||
'value' => array(
|
||||
'value' => [
|
||||
'min' => 26,
|
||||
'max' => 29,
|
||||
),
|
||||
),
|
||||
4 => array(
|
||||
],
|
||||
],
|
||||
4 => [
|
||||
'title' => 'Age is empty',
|
||||
'operator' => 'empty',
|
||||
),
|
||||
5 => array(
|
||||
],
|
||||
5 => [
|
||||
'title' => 'Age is not empty',
|
||||
'operator' => 'not empty',
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
6 => [
|
||||
'title' => 'Age is regexp 2[7-8]',
|
||||
'operator' => 'regular_expression',
|
||||
'value' => [
|
||||
'value' => '2[7-8]',
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
return $filters;
|
||||
}
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -12,14 +12,14 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class HandlerAliasTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('user');
|
||||
public static $modules = ['user'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_filter', 'test_alias');
|
||||
public static $testViews = ['test_filter', 'test_alias'];
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
@ -45,16 +45,16 @@ class HandlerAliasTest extends ViewsKernelTestBase {
|
|||
$view->initDisplay();
|
||||
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'test_filter' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'test_filter' => [
|
||||
'id' => 'test_filter',
|
||||
'table' => 'views_test_data_alias',
|
||||
'field' => 'name_alias',
|
||||
'operator' => '=',
|
||||
'value' => 'John',
|
||||
'group' => 0,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
|
|
@ -18,123 +18,123 @@ class SortDateTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
protected function expectedResultSet($granularity, $reverse = TRUE) {
|
||||
$expected = array();
|
||||
$expected = [];
|
||||
if (!$reverse) {
|
||||
switch ($granularity) {
|
||||
case 'second':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'George'],
|
||||
];
|
||||
break;
|
||||
case 'minute':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'George'],
|
||||
];
|
||||
break;
|
||||
case 'hour':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'George'],
|
||||
];
|
||||
break;
|
||||
case 'day':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'George'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'George'],
|
||||
];
|
||||
break;
|
||||
case 'month':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
];
|
||||
break;
|
||||
case 'year':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
switch ($granularity) {
|
||||
case 'second':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'John'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'John'],
|
||||
];
|
||||
break;
|
||||
case 'minute':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'John'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'John'],
|
||||
];
|
||||
break;
|
||||
case 'hour':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
array('name' => 'John'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
['name' => 'John'],
|
||||
];
|
||||
break;
|
||||
case 'day':
|
||||
$expected = array(
|
||||
array('name' => 'George'),
|
||||
array('name' => 'John'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'George'],
|
||||
['name' => 'John'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
];
|
||||
break;
|
||||
case 'month':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
];
|
||||
break;
|
||||
case 'year':
|
||||
$expected = array(
|
||||
array('name' => 'John'),
|
||||
array('name' => 'George'),
|
||||
array('name' => 'Ringo'),
|
||||
array('name' => 'Paul'),
|
||||
array('name' => 'Meredith'),
|
||||
);
|
||||
$expected = [
|
||||
['name' => 'John'],
|
||||
['name' => 'George'],
|
||||
['name' => 'Ringo'],
|
||||
['name' => 'Paul'],
|
||||
['name' => 'Meredith'],
|
||||
];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -146,54 +146,54 @@ class SortDateTest extends ViewsKernelTestBase {
|
|||
* Tests numeric ordering of the result set.
|
||||
*/
|
||||
public function testDateOrdering() {
|
||||
foreach (array('second', 'minute', 'hour', 'day', 'month', 'year') as $granularity) {
|
||||
foreach (array(FALSE, TRUE) as $reverse) {
|
||||
foreach (['second', 'minute', 'hour', 'day', 'month', 'year'] as $granularity) {
|
||||
foreach ([FALSE, TRUE] as $reverse) {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
// Change the fields.
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', [
|
||||
'name' => [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'created' => array(
|
||||
],
|
||||
'created' => [
|
||||
'id' => 'created',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'created',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Change the ordering
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', array(
|
||||
'created' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', [
|
||||
'created' => [
|
||||
'id' => 'created',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'created',
|
||||
'relationship' => 'none',
|
||||
'granularity' => $granularity,
|
||||
'order' => $reverse ? 'DESC' : 'ASC',
|
||||
),
|
||||
'id' => array(
|
||||
],
|
||||
'id' => [
|
||||
'id' => 'id',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'id',
|
||||
'relationship' => 'none',
|
||||
'order' => 'ASC',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->expectedResultSet($granularity, $reverse), array(
|
||||
$this->assertIdenticalResultset($view, $this->expectedResultSet($granularity, $reverse), [
|
||||
'views_test_data_name' => 'name',
|
||||
), SafeMarkup::format('Result is returned correctly when ordering by granularity @granularity, @reverse.', array('@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward')));
|
||||
], SafeMarkup::format('Result is returned correctly when ordering by granularity @granularity, @reverse.', ['@granularity' => $granularity, '@reverse' => $reverse ? 'reverse' : 'forward']));
|
||||
$view->destroy();
|
||||
unset($view);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class SortRandomTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Add more items to the test set, to make the order tests more robust.
|
||||
|
@ -34,13 +34,13 @@ class SortRandomTest extends ViewsKernelTestBase {
|
|||
protected function dataSet() {
|
||||
$data = parent::dataSet();
|
||||
for ($i = 0; $i < 55; $i++) {
|
||||
$data[] = array(
|
||||
$data[] = [
|
||||
'name' => 'name_' . $i,
|
||||
'age' => $i,
|
||||
'job' => 'job_' . $i,
|
||||
'created' => rand(0, time()),
|
||||
'status' => 1,
|
||||
);
|
||||
];
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
@ -53,13 +53,13 @@ class SortRandomTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a random ordering.
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', array(
|
||||
'random' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', [
|
||||
'random' => [
|
||||
'id' => 'random',
|
||||
'field' => 'random',
|
||||
'table' => 'views',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
@ -76,28 +76,28 @@ class SortRandomTest extends ViewsKernelTestBase {
|
|||
|
||||
// Verify the result.
|
||||
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->dataSet(), array(
|
||||
$this->assertIdenticalResultset($view, $this->dataSet(), [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
|
||||
// Execute a random view, we expect the result set to be different.
|
||||
$view_random = $this->getBasicRandomView();
|
||||
$this->executeView($view_random);
|
||||
$this->assertEqual(count($this->dataSet()), count($view_random->result), 'The number of returned rows match.');
|
||||
$this->assertNotIdenticalResultset($view_random, $view->result, array(
|
||||
$this->assertNotIdenticalResultset($view_random, $view->result, [
|
||||
'views_test_data_name' => 'views_test_data_name',
|
||||
'views_test_data_age' => 'views_test_data_name',
|
||||
));
|
||||
]);
|
||||
|
||||
// Execute a second random view, we expect the result set to be different again.
|
||||
$view_random_2 = $this->getBasicRandomView();
|
||||
$this->executeView($view_random_2);
|
||||
$this->assertEqual(count($this->dataSet()), count($view_random_2->result), 'The number of returned rows match.');
|
||||
$this->assertNotIdenticalResultset($view_random, $view->result, array(
|
||||
$this->assertNotIdenticalResultset($view_random, $view->result, [
|
||||
'views_test_data_name' => 'views_test_data_name',
|
||||
'views_test_data_age' => 'views_test_data_name',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ class SortTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Tests numeric ordering of the result set.
|
||||
|
@ -27,49 +27,49 @@ class SortTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Change the ordering
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', [
|
||||
'age' => [
|
||||
'order' => 'ASC',
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age'), array(
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age'), [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
|
||||
$view->destroy();
|
||||
$view->setDisplay();
|
||||
|
||||
// Reverse the ordering
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', array(
|
||||
'age' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', [
|
||||
'age' => [
|
||||
'order' => 'DESC',
|
||||
'id' => 'age',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'age',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age', TRUE), array(
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'age', TRUE), [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -80,49 +80,49 @@ class SortTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Change the ordering
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', [
|
||||
'name' => [
|
||||
'order' => 'ASC',
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name'), array(
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name'), [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
|
||||
$view->destroy();
|
||||
$view->setDisplay();
|
||||
|
||||
// Reverse the ordering
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('sorts', [
|
||||
'name' => [
|
||||
'order' => 'DESC',
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Execute the view.
|
||||
$this->executeView($view);
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(count($this->dataSet()), count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name', TRUE), array(
|
||||
$this->assertIdenticalResultset($view, $this->orderResultSet($this->dataSet(), 'name', TRUE), [
|
||||
'views_test_data_name' => 'name',
|
||||
'views_test_data_age' => 'age',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_status', 'test_view', 'test_argument');
|
||||
public static $testViews = ['test_view_status', 'test_view', 'test_argument'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -43,27 +43,27 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
* @see views_get_handler()
|
||||
*/
|
||||
public function testViewsGetHandler() {
|
||||
$types = array('field', 'area', 'filter');
|
||||
$types = ['field', 'area', 'filter'];
|
||||
foreach ($types as $type) {
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => $this->randomMachineName(),
|
||||
'field' => $this->randomMachineName(),
|
||||
);
|
||||
];
|
||||
$handler = $this->container->get('plugin.manager.views.' . $type)->getHandler($item);
|
||||
$this->assertEqual('Drupal\views\Plugin\views\\' . $type . '\Broken', get_class($handler), new FormattableMarkup('Make sure that a broken handler of type: @type is created.', ['@type' => $type]));
|
||||
}
|
||||
|
||||
$views_data = $this->viewsData();
|
||||
$test_tables = array('views_test_data' => array('id', 'name'));
|
||||
$test_tables = ['views_test_data' => ['id', 'name']];
|
||||
foreach ($test_tables as $table => $fields) {
|
||||
foreach ($fields as $field) {
|
||||
$data = $views_data[$table][$field];
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => $table,
|
||||
'field' => $field,
|
||||
);
|
||||
];
|
||||
foreach ($data as $id => $field_data) {
|
||||
if (!in_array($id, array('title', 'help'))) {
|
||||
if (!in_array($id, ['title', 'help'])) {
|
||||
$handler = $this->container->get('plugin.manager.views.' . $id)->getHandler($item);
|
||||
$this->assertInstanceHandler($handler, $table, $field, $id);
|
||||
}
|
||||
|
@ -72,10 +72,10 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
}
|
||||
|
||||
// Test the override handler feature.
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'job',
|
||||
);
|
||||
];
|
||||
$handler = $this->container->get('plugin.manager.views.filter')->getHandler($item, 'standard');
|
||||
$this->assertTrue($handler instanceof Standard);
|
||||
|
||||
|
@ -84,29 +84,29 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
return;
|
||||
|
||||
// Test non-existent tables/fields.
|
||||
set_error_handler(array($this, 'customErrorHandler'));
|
||||
$item = array(
|
||||
set_error_handler([$this, 'customErrorHandler']);
|
||||
$item = [
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'field_invalid',
|
||||
);
|
||||
];
|
||||
$this->container->get('plugin.manager.views.field')->getHandler($item);
|
||||
$this->assertTrue(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'))) !== FALSE, 'An invalid field name throws a debug message.');
|
||||
$this->assertTrue(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", ['@table' => 'views_test_data', '@field' => 'field_invalid', '@type' => 'field'])) !== FALSE, 'An invalid field name throws a debug message.');
|
||||
unset($this->lastErrorMessage);
|
||||
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => 'table_invalid',
|
||||
'field' => 'id',
|
||||
);
|
||||
];
|
||||
$this->container->get('plugin.manager.views.filter')->getHandler($item);
|
||||
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
|
||||
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", ['@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'])) !== FALSE, 'An invalid table name throws a debug message.');
|
||||
unset($this->lastErrorMessage);
|
||||
|
||||
$item = array(
|
||||
$item = [
|
||||
'table' => 'table_invalid',
|
||||
'field' => 'id',
|
||||
);
|
||||
];
|
||||
$this->container->get('plugin.manager.views.filter')->getHandler($item);
|
||||
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", array('@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'))) !== FALSE, 'An invalid table name throws a debug message.');
|
||||
$this->assertEqual(strpos($this->lastErrorMessage, format_string("Missing handler: @table @field @type", ['@table' => 'table_invalid', '@field' => 'id', '@type' => 'filter'])) !== FALSE, 'An invalid table name throws a debug message.');
|
||||
unset($this->lastErrorMessage);
|
||||
|
||||
restore_error_handler();
|
||||
|
@ -139,8 +139,8 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
* Tests the load wrapper/helper functions.
|
||||
*/
|
||||
public function testLoadFunctions() {
|
||||
$this->enableModules(array('text', 'node'));
|
||||
$this->installConfig(array('node'));
|
||||
$this->enableModules(['text', 'node']);
|
||||
$this->installConfig(['node']);
|
||||
$storage = $this->container->get('entity.manager')->getStorage('view');
|
||||
|
||||
// Test views_view_is_enabled/disabled.
|
||||
|
@ -172,7 +172,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
// Test Views::getViewsAsOptions().
|
||||
// Test the $views_only parameter.
|
||||
$this->assertIdentical(array_keys($all_views), array_keys(Views::getViewsAsOptions(TRUE)), 'Expected option keys for all views were returned.');
|
||||
$expected_options = array();
|
||||
$expected_options = [];
|
||||
foreach ($all_views as $id => $view) {
|
||||
$expected_options[$id] = $view->label();
|
||||
}
|
||||
|
@ -196,10 +196,10 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
$this->assertFalse(array_key_exists('archive', Views::getViewsAsOptions(TRUE, 'all', $archive->getExecutable())), 'View excluded from options based on object');
|
||||
|
||||
// Test the $opt_group parameter.
|
||||
$expected_opt_groups = array();
|
||||
$expected_opt_groups = [];
|
||||
foreach ($all_views as $view) {
|
||||
foreach ($view->get('display') as $display) {
|
||||
$expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = (string) t('@view : @display', array('@view' => $view->id(), '@display' => $display['id']));
|
||||
$expected_opt_groups[$view->id()][$view->id() . ':' . $display['id']] = (string) t('@view : @display', ['@view' => $view->id(), '@display' => $display['id']]);
|
||||
}
|
||||
}
|
||||
$this->assertIdentical($expected_opt_groups, $this->castSafeStrings(Views::getViewsAsOptions(FALSE, 'all', NULL, TRUE)), 'Expected option array for an option group returned.');
|
||||
|
@ -208,7 +208,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests view enable and disable procedural wrapper functions.
|
||||
*/
|
||||
function testStatusFunctions() {
|
||||
public function testStatusFunctions() {
|
||||
$view = Views::getView('test_view_status')->storage;
|
||||
|
||||
$this->assertFalse($view->status(), 'The view status is disabled.');
|
||||
|
@ -229,7 +229,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
// All style plugins should be returned, as we have not specified a type.
|
||||
$plugins = Views::fetchPluginNames('style');
|
||||
$definitions = $this->container->get('plugin.manager.views.style')->getDefinitions();
|
||||
$expected = array();
|
||||
$expected = [];
|
||||
foreach ($definitions as $id => $definition) {
|
||||
$expected[$id] = $definition['title'];
|
||||
}
|
||||
|
@ -239,11 +239,11 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
// Test using the 'test' style plugin type only returns the test_style and
|
||||
// mapping_test plugins.
|
||||
$plugins = Views::fetchPluginNames('style', 'test');
|
||||
$this->assertIdentical(array_keys($plugins), array('mapping_test', 'test_style', 'test_template_style'));
|
||||
$this->assertIdentical(array_keys($plugins), ['mapping_test', 'test_style', 'test_template_style']);
|
||||
|
||||
// Test a non existent style plugin type returns no plugins.
|
||||
$plugins = Views::fetchPluginNames('style', $this->randomString());
|
||||
$this->assertIdentical($plugins, array());
|
||||
$this->assertIdentical($plugins, []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -252,11 +252,11 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
public function testViewsPluginList() {
|
||||
$plugin_list = Views::pluginList();
|
||||
// Only plugins used by 'test_view' should be in the plugin list.
|
||||
foreach (array('display:default', 'pager:none') as $key) {
|
||||
foreach (['display:default', 'pager:none'] as $key) {
|
||||
list($plugin_type, $plugin_id) = explode(':', $key);
|
||||
$plugin_def = $this->container->get("plugin.manager.views.$plugin_type")->getDefinition($plugin_id);
|
||||
|
||||
$this->assertTrue(isset($plugin_list[$key]), SafeMarkup::format('The expected @key plugin list key was found.', array('@key' => $key)));
|
||||
$this->assertTrue(isset($plugin_list[$key]), SafeMarkup::format('The expected @key plugin list key was found.', ['@key' => $key]));
|
||||
$plugin_details = $plugin_list[$key];
|
||||
|
||||
$this->assertEqual($plugin_details['type'], $plugin_type, 'The expected plugin type was found.');
|
||||
|
@ -303,35 +303,35 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual(count($result['#view']->result), 5);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('0' => 1));
|
||||
$result = $view->preview('default', ['0' => 1]);
|
||||
$this->assertEqual(count($result['#view']->result), 1);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('3' => 1));
|
||||
$result = $view->preview('default', ['3' => 1]);
|
||||
$this->assertEqual(count($result['#view']->result), 1);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('0' => '1,2'));
|
||||
$result = $view->preview('default', ['0' => '1,2']);
|
||||
$this->assertEqual(count($result['#view']->result), 2);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('3' => '1,2'));
|
||||
$result = $view->preview('default', ['3' => '1,2']);
|
||||
$this->assertEqual(count($result['#view']->result), 2);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('0' => '1,2', '1' => 'John'));
|
||||
$result = $view->preview('default', ['0' => '1,2', '1' => 'John']);
|
||||
$this->assertEqual(count($result['#view']->result), 1);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('3' => '1,2', '4' => 'John'));
|
||||
$result = $view->preview('default', ['3' => '1,2', '4' => 'John']);
|
||||
$this->assertEqual(count($result['#view']->result), 1);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('0' => '1,2', '1' => 'John,George'));
|
||||
$result = $view->preview('default', ['0' => '1,2', '1' => 'John,George']);
|
||||
$this->assertEqual(count($result['#view']->result), 2);
|
||||
|
||||
$view = Views::getView('test_argument');
|
||||
$result = $view->preview('default', array('3' => '1,2', '4' => 'John,George'));
|
||||
$result = $view->preview('default', ['3' => '1,2', '4' => 'John,George']);
|
||||
$this->assertEqual(count($result['#view']->result), 2);
|
||||
}
|
||||
|
||||
|
@ -345,12 +345,12 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
* @return array
|
||||
* A formatted options array that matches the expected output.
|
||||
*/
|
||||
protected function formatViewOptions(array $views = array()) {
|
||||
$expected_options = array();
|
||||
protected function formatViewOptions(array $views = []) {
|
||||
$expected_options = [];
|
||||
foreach ($views as $view) {
|
||||
foreach ($view->get('display') as $display) {
|
||||
$expected_options[$view->id() . ':' . $display['id']] = (string) t('View: @view - Display: @display',
|
||||
array('@view' => $view->id(), '@display' => $display['id']));
|
||||
['@view' => $view->id(), '@display' => $display['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ class ModuleTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Ensure that a certain handler is a instance of a certain table/field.
|
||||
*/
|
||||
function assertInstanceHandler($handler, $table, $field, $id) {
|
||||
public function assertInstanceHandler($handler, $table, $field, $id) {
|
||||
$table_data = $this->container->get('views.views_data')->get($table);
|
||||
$field_data = $table_data[$field][$id];
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class ArgumentValidatorTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public static $testViews = ['test_view_argument_validate_numeric', 'test_view'];
|
||||
|
||||
function testArgumentValidateNumeric() {
|
||||
public function testArgumentValidateNumeric() {
|
||||
$view = Views::getView('test_view_argument_validate_numeric');
|
||||
$view->initHandlers();
|
||||
$this->assertFalse($view->argument['null']->validateArgument($this->randomString()));
|
||||
|
|
|
@ -17,14 +17,14 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_exposed_block');
|
||||
public static $testViews = ['test_exposed_block'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node', 'block', 'user', 'field');
|
||||
public static $modules = ['node', 'block', 'user', 'field'];
|
||||
|
||||
/**
|
||||
* Tests that exposed filter blocks have the correct dependencies.
|
||||
|
@ -34,11 +34,11 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
|
|||
public function testExposedBlock() {
|
||||
$block = $this->createBlock('views_exposed_filter_block:test_exposed_block-page_1');
|
||||
$dependencies = $block->calculateDependencies()->getDependencies();
|
||||
$expected = array(
|
||||
'config' => array('views.view.test_exposed_block'),
|
||||
'module' => array('views'),
|
||||
'theme' => array('stark')
|
||||
);
|
||||
$expected = [
|
||||
'config' => ['views.view.test_exposed_block'],
|
||||
'module' => ['views'],
|
||||
'theme' => ['stark']
|
||||
];
|
||||
$this->assertIdentical($expected, $dependencies);
|
||||
}
|
||||
|
||||
|
@ -50,11 +50,11 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
|
|||
public function testViewsBlock() {
|
||||
$block = $this->createBlock('views_block:content_recent-block_1');
|
||||
$dependencies = $block->calculateDependencies()->getDependencies();
|
||||
$expected = array(
|
||||
'config' => array('views.view.content_recent'),
|
||||
'module' => array('views'),
|
||||
'theme' => array('stark')
|
||||
);
|
||||
$expected = [
|
||||
'config' => ['views.view.content_recent'],
|
||||
'module' => ['views'],
|
||||
'theme' => ['stark']
|
||||
];
|
||||
$this->assertIdentical($expected, $dependencies);
|
||||
}
|
||||
|
||||
|
@ -82,18 +82,18 @@ class BlockDependenciesTest extends ViewsKernelTestBase {
|
|||
* @return \Drupal\block\Entity\Block
|
||||
* The block entity.
|
||||
*/
|
||||
protected function createBlock($plugin_id, array $settings = array()) {
|
||||
$settings += array(
|
||||
protected function createBlock($plugin_id, array $settings = []) {
|
||||
$settings += [
|
||||
'plugin' => $plugin_id,
|
||||
'region' => 'sidebar_first',
|
||||
'id' => strtolower($this->randomMachineName(8)),
|
||||
'theme' => $this->config('system.theme')->get('default'),
|
||||
'label' => $this->randomMachineName(8),
|
||||
'visibility' => array(),
|
||||
'visibility' => [],
|
||||
'weight' => 0,
|
||||
);
|
||||
];
|
||||
$values = [];
|
||||
foreach (array('region', 'id', 'theme', 'plugin', 'weight', 'visibility') as $key) {
|
||||
foreach (['region', 'id', 'theme', 'plugin', 'weight', 'visibility'] as $key) {
|
||||
$values[$key] = $settings[$key];
|
||||
// Remove extra values that do not belong in the settings array.
|
||||
unset($settings[$key]);
|
||||
|
|
|
@ -21,14 +21,14 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view', 'test_cache', 'test_groupwise_term_ui', 'test_display', 'test_filter');
|
||||
public static $testViews = ['test_view', 'test_cache', 'test_groupwise_term_ui', 'test_display', 'test_filter'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('taxonomy', 'text', 'user', 'node');
|
||||
public static $modules = ['taxonomy', 'text', 'user', 'node'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -70,13 +70,13 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
public function testTimeResultCaching() {
|
||||
$view = Views::getView('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'results_lifespan' => '3600',
|
||||
'output_lifespan' => '3600',
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
|
||||
// Test the default (non-paged) display.
|
||||
$this->executeView($view);
|
||||
|
@ -84,11 +84,11 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
|
||||
|
||||
// Add another man to the beatles.
|
||||
$record = array(
|
||||
$record = [
|
||||
'name' => 'Rod Davis',
|
||||
'age' => 29,
|
||||
'job' => 'Banjo',
|
||||
);
|
||||
];
|
||||
db_insert('views_test_data')->fields($record)->execute();
|
||||
|
||||
// The result should be the same as before, because of the caching. (Note
|
||||
|
@ -112,25 +112,25 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
|
||||
$view = Views::getView('test_filter');
|
||||
$view->initDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'results_lifespan' => '3600',
|
||||
'output_lifespan' => '3600',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'test_filter' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'test_filter' => [
|
||||
'id' => 'test_filter',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'operator' => '=',
|
||||
'value' => 'John',
|
||||
'group' => 0,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -138,29 +138,29 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
$cid1 = $view->display_handler->getPlugin('cache')->generateResultsKey();
|
||||
|
||||
// Build the expected result.
|
||||
$dataset = array(array('name' => 'John'));
|
||||
$dataset = [['name' => 'John']];
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(1, count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultSet($view, $dataset, array(
|
||||
$this->assertIdenticalResultSet($view, $dataset, [
|
||||
'views_test_data_name' => 'name',
|
||||
));
|
||||
]);
|
||||
|
||||
$view->destroy();
|
||||
|
||||
$view->initDisplay();
|
||||
|
||||
// Change the filtering.
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'test_filter' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'test_filter' => [
|
||||
'id' => 'test_filter',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'operator' => '=',
|
||||
'value' => 'Ringo',
|
||||
'group' => 0,
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -169,13 +169,13 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
$this->assertNotEqual($cid1, $cid2, "Results keys are different.");
|
||||
|
||||
// Build the expected result.
|
||||
$dataset = array(array('name' => 'Ringo'));
|
||||
$dataset = [['name' => 'Ringo']];
|
||||
|
||||
// Verify the result.
|
||||
$this->assertEqual(1, count($view->result), 'The number of returned rows match.');
|
||||
$this->assertIdenticalResultSet($view, $dataset, array(
|
||||
$this->assertIdenticalResultSet($view, $dataset, [
|
||||
'views_test_data_name' => 'name',
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -184,13 +184,13 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
public function testTimeResultCachingWithPager() {
|
||||
$view = Views::getView('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'results_lifespan' => '3600',
|
||||
'output_lifespan' => '3600',
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
|
||||
$mapping = ['views_test_data_name' => 'name'];
|
||||
|
||||
|
@ -224,34 +224,34 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @see views_plugin_cache_time
|
||||
*/
|
||||
function testNoneResultCaching() {
|
||||
public function testNoneResultCaching() {
|
||||
// Create a basic result which just 2 results.
|
||||
$view = Views::getView('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'none',
|
||||
'options' => array(),
|
||||
));
|
||||
'options' => [],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
// Verify the result.
|
||||
$this->assertEqual(5, count($view->result), 'The number of returned rows match.');
|
||||
|
||||
// Add another man to the beatles.
|
||||
$record = array(
|
||||
$record = [
|
||||
'name' => 'Rod Davis',
|
||||
'age' => 29,
|
||||
'job' => 'Banjo',
|
||||
);
|
||||
];
|
||||
db_insert('views_test_data')->fields($record)->execute();
|
||||
|
||||
// The Result changes, because the view is not cached.
|
||||
$view = Views::getView('test_cache');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'none',
|
||||
'options' => array(),
|
||||
));
|
||||
'options' => [],
|
||||
]);
|
||||
|
||||
$this->executeView($view);
|
||||
// Verify the result.
|
||||
|
@ -261,19 +261,19 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests css/js storage and restoring mechanism.
|
||||
*/
|
||||
function testHeaderStorage() {
|
||||
public function testHeaderStorage() {
|
||||
// Create a view with output caching enabled.
|
||||
// Some hook_views_pre_render in views_test_data.module adds the test css/js file.
|
||||
// so they should be added to the css/js storage.
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
$view->storage->set('id', 'test_cache_header_storage');
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'output_lifespan' => '3600',
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
|
||||
$output = $view->buildRenderable();
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
|
@ -326,13 +326,13 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
|
||||
$view = Views::getView('test_display');
|
||||
$view->setDisplay();
|
||||
$view->display_handler->overrideOption('cache', array(
|
||||
$view->display_handler->overrideOption('cache', [
|
||||
'type' => 'time',
|
||||
'options' => array(
|
||||
'options' => [
|
||||
'results_lifespan' => '3600',
|
||||
'output_lifespan' => '3600',
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
$this->executeView($view);
|
||||
|
||||
// Get the cache item.
|
||||
|
@ -383,4 +383,30 @@ class CacheTest extends ViewsKernelTestBase {
|
|||
$this->assertIdenticalResultset($view, [['name' => 'Paul']], $map);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that cacheability metadata is carried over from argument defaults.
|
||||
*/
|
||||
public function testArgumentDefaultCache() {
|
||||
$view = Views::getView('test_view');
|
||||
|
||||
// Add a new argument and set the test plugin for the argument_default.
|
||||
$options = [
|
||||
'default_argument_type' => 'argument_default_test',
|
||||
'default_argument_options' => [
|
||||
'value' => 'John'
|
||||
],
|
||||
'default_action' => 'default'
|
||||
];
|
||||
$view->addHandler('default', 'argument', 'views_test_data', 'name', $options);
|
||||
$view->initHandlers();
|
||||
|
||||
$output = $view->preview();
|
||||
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
$renderer->renderPlain($output);
|
||||
$this->assertEquals(['config:views.view.test_view', 'example_tag'], $output['#cache']['tags']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class ViewsMenuLinkTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var \Drupal\Core\Entity\EntityManagerInterface
|
||||
*/
|
||||
protected $entityManger;
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The menu link manager.
|
||||
|
@ -52,7 +52,7 @@ class ViewsMenuLinkTest extends ViewsKernelTestBase {
|
|||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->entityManger = $this->container->get('entity.manager');
|
||||
$this->entityManager = $this->container->get('entity.manager');
|
||||
$this->menuLinkManager = $this->container->get('plugin.manager.menu.link');
|
||||
$this->menuLinkOverrides = $this->container->get('menu_link.static.overrides');
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ class DisplayKernelTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('block', 'node', 'field', 'user');
|
||||
public static $modules = ['block', 'node', 'field', 'user'];
|
||||
|
||||
/**
|
||||
* Views plugin types to test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $pluginTypes = array(
|
||||
protected $pluginTypes = [
|
||||
'access',
|
||||
'cache',
|
||||
'query',
|
||||
|
@ -39,24 +39,24 @@ class DisplayKernelTest extends ViewsKernelTestBase {
|
|||
'pager',
|
||||
'style',
|
||||
'row',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Views handler types to test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $handlerTypes = array(
|
||||
protected $handlerTypes = [
|
||||
'fields',
|
||||
'sorts',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_display_defaults');
|
||||
public static $testViews = ['test_display_defaults'];
|
||||
|
||||
/**
|
||||
* Tests the default display options.
|
||||
|
|
|
@ -22,14 +22,14 @@ class DisplayPageTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_page_display', 'test_page_display_route', 'test_page_display_menu');
|
||||
public static $testViews = ['test_page_display', 'test_page_display_route', 'test_page_display_menu'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'user', 'field');
|
||||
public static $modules = ['system', 'user', 'field'];
|
||||
|
||||
/**
|
||||
* The router dumper to get all routes.
|
||||
|
|
|
@ -21,7 +21,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* A plugin manager which handlers the instances of joins.
|
||||
|
@ -47,12 +47,12 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
$view->initDisplay();
|
||||
$view->initQuery();
|
||||
|
||||
$configuration = array(
|
||||
$configuration = [
|
||||
'left_table' => 'views_test_data',
|
||||
'left_field' => 'uid',
|
||||
'table' => 'users_field_data',
|
||||
'field' => 'uid',
|
||||
);
|
||||
];
|
||||
$join = $this->manager->createInstance('join_test', $configuration);
|
||||
$this->assertTrue($join instanceof JoinTestPlugin, 'The correct join class got loaded.');
|
||||
|
||||
|
@ -60,7 +60,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
$join->setJoinValue($rand_int);
|
||||
|
||||
$query = db_select('views_test_data');
|
||||
$table = array('alias' => 'users_field_data');
|
||||
$table = ['alias' => 'users_field_data'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -80,13 +80,13 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
|
||||
// First define a simple join without an extra condition.
|
||||
// Set the various options on the join object.
|
||||
$configuration = array(
|
||||
$configuration = [
|
||||
'left_table' => 'views_test_data',
|
||||
'left_field' => 'uid',
|
||||
'table' => 'users_field_data',
|
||||
'field' => 'uid',
|
||||
'adjusted' => TRUE,
|
||||
);
|
||||
];
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$this->assertTrue($join instanceof JoinPluginBase, 'The correct join class got loaded.');
|
||||
$this->assertNull($join->extra, 'The field extra was not overridden.');
|
||||
|
@ -95,7 +95,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
// Build the actual join values and read them back from the dbtng query
|
||||
// object.
|
||||
$query = db_select('views_test_data');
|
||||
$table = array('alias' => 'users_field_data');
|
||||
$table = ['alias' => 'users_field_data'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -107,7 +107,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
|
||||
// Set a different alias and make sure table info is as expected.
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$table = array('alias' => 'users1');
|
||||
$table = ['alias' => 'users1'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -117,7 +117,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
// Set a different join type (INNER) and make sure it is used.
|
||||
$configuration['type'] = 'INNER';
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$table = array('alias' => 'users2');
|
||||
$table = ['alias' => 'users2'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -127,19 +127,19 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
// Setup addition conditions and make sure it is used.
|
||||
$random_name_1 = $this->randomMachineName();
|
||||
$random_name_2 = $this->randomMachineName();
|
||||
$configuration['extra'] = array(
|
||||
array(
|
||||
$configuration['extra'] = [
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => $random_name_1
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => $random_name_2,
|
||||
'operator' => '<>'
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$table = array('alias' => 'users3');
|
||||
$table = ['alias' => 'users3'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -147,25 +147,25 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
$this->assertTrue(strpos($join_info['condition'], "views_test_data.uid = users3.uid") !== FALSE, 'Make sure the join condition appears in the query.');
|
||||
$this->assertTrue(strpos($join_info['condition'], "users3.name = :views_join_condition_0") !== FALSE, 'Make sure the first extra join condition appears in the query and uses the first placeholder.');
|
||||
$this->assertTrue(strpos($join_info['condition'], "users3.name <> :views_join_condition_1") !== FALSE, 'Make sure the second extra join condition appears in the query and uses the second placeholder.');
|
||||
$this->assertEqual(array_values($join_info['arguments']), array($random_name_1, $random_name_2), 'Make sure the arguments are in the right order');
|
||||
$this->assertEqual(array_values($join_info['arguments']), [$random_name_1, $random_name_2], 'Make sure the arguments are in the right order');
|
||||
|
||||
// Test that 'IN' conditions are properly built.
|
||||
$random_name_1 = $this->randomMachineName();
|
||||
$random_name_2 = $this->randomMachineName();
|
||||
$random_name_3 = $this->randomMachineName();
|
||||
$random_name_4 = $this->randomMachineName();
|
||||
$configuration['extra'] = array(
|
||||
array(
|
||||
$configuration['extra'] = [
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => $random_name_1
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'field' => 'name',
|
||||
'value' => array($random_name_2, $random_name_3, $random_name_4),
|
||||
),
|
||||
);
|
||||
'value' => [$random_name_2, $random_name_3, $random_name_4],
|
||||
],
|
||||
];
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$table = array('alias' => 'users4');
|
||||
$table = ['alias' => 'users4'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -173,26 +173,26 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
$this->assertTrue(strpos($join_info['condition'], "views_test_data.uid = users4.uid") !== FALSE, 'Make sure the join condition appears in the query.');
|
||||
$this->assertTrue(strpos($join_info['condition'], "users4.name = :views_join_condition_2") !== FALSE, 'Make sure the first extra join condition appears in the query.');
|
||||
$this->assertTrue(strpos($join_info['condition'], "users4.name IN ( :views_join_condition_3[] )") !== FALSE, 'The IN condition for the join is properly formed.');
|
||||
$this->assertEqual($join_info['arguments'][':views_join_condition_3[]'], array($random_name_2, $random_name_3, $random_name_4), 'Make sure the IN arguments are still part of an array.');
|
||||
$this->assertEqual($join_info['arguments'][':views_join_condition_3[]'], [$random_name_2, $random_name_3, $random_name_4], 'Make sure the IN arguments are still part of an array.');
|
||||
|
||||
// Test that all the conditions are properly built.
|
||||
$configuration['extra'] = array(
|
||||
array(
|
||||
$configuration['extra'] = [
|
||||
[
|
||||
'field' => 'langcode',
|
||||
'value' => 'en'
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'left_field' => 'status',
|
||||
'value' => 0,
|
||||
'numeric' => TRUE,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'field' => 'name',
|
||||
'left_field' => 'name'
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$join = $this->manager->createInstance('standard', $configuration);
|
||||
$table = array('alias' => 'users5');
|
||||
$table = ['alias' => 'users5'];
|
||||
$join->buildJoin($query, $table, $view->query);
|
||||
|
||||
$tables = $query->getTables();
|
||||
|
@ -201,7 +201,7 @@ class JoinTest extends RelationshipJoinTestBase {
|
|||
$this->assertTrue(strpos($join_info['condition'], "users5.langcode = :views_join_condition_4") !== FALSE, 'Make sure the first extra join condition appears in the query.');
|
||||
$this->assertTrue(strpos($join_info['condition'], "views_test_data.status = :views_join_condition_5") !== FALSE, 'Make sure the second extra join condition appears in the query.');
|
||||
$this->assertTrue(strpos($join_info['condition'], "users5.name = views_test_data.name") !== FALSE, 'Make sure the third extra join condition appears in the query.');
|
||||
$this->assertEqual(array_values($join_info['arguments']), array('en', 0), 'Make sure the arguments are in the right order');
|
||||
$this->assertEqual(array_values($join_info['arguments']), ['en', 0], 'Make sure the arguments are in the right order');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class QueryTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
|
|
|
@ -18,7 +18,7 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('system', 'user', 'field');
|
||||
public static $modules = ['system', 'user', 'field'];
|
||||
|
||||
/**
|
||||
* @var \Drupal\user\Entity\User
|
||||
|
@ -30,7 +30,7 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
|
|||
*/
|
||||
protected function setUpFixtures() {
|
||||
$this->installEntitySchema('user');
|
||||
$this->installConfig(array('user'));
|
||||
$this->installConfig(['user']);
|
||||
parent::setUpFixtures();
|
||||
|
||||
// Create a record for uid 1.
|
||||
|
@ -48,13 +48,13 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
|
|||
protected function schemaDefinition() {
|
||||
$schema = parent::schemaDefinition();
|
||||
|
||||
$schema['views_test_data']['fields']['uid'] = array(
|
||||
$schema['views_test_data']['fields']['uid'] = [
|
||||
'description' => "The {users_field_data}.uid of the author of the beatle entry.",
|
||||
'type' => 'int',
|
||||
'unsigned' => TRUE,
|
||||
'not null' => TRUE,
|
||||
'default' => 0
|
||||
);
|
||||
];
|
||||
|
||||
return $schema;
|
||||
}
|
||||
|
@ -66,15 +66,15 @@ abstract class RelationshipJoinTestBase extends PluginKernelTestBase {
|
|||
*/
|
||||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['uid'] = array(
|
||||
$data['views_test_data']['uid'] = [
|
||||
'title' => t('UID'),
|
||||
'help' => t('The test data UID'),
|
||||
'relationship' => array(
|
||||
'relationship' => [
|
||||
'id' => 'standard',
|
||||
'base' => 'users_field_data',
|
||||
'base field' => 'uid'
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
|
|
@ -19,17 +19,17 @@ class RelationshipTest extends RelationshipJoinTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Maps between the key in the expected result and the query result.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
protected $columnMap = [
|
||||
'views_test_data_name' => 'name',
|
||||
'users_field_data_views_test_data_uid' => 'uid',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Tests the query result of a view with a relationship.
|
||||
|
@ -42,53 +42,53 @@ class RelationshipTest extends RelationshipJoinTestBase {
|
|||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('relationships', array(
|
||||
'uid' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('relationships', [
|
||||
'uid' => [
|
||||
'id' => 'uid',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'uid',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', array(
|
||||
'uid' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', [
|
||||
'uid' => [
|
||||
'id' => 'uid',
|
||||
'table' => 'users_field_data',
|
||||
'field' => 'uid',
|
||||
'relationship' => 'uid',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$fields = $view->displayHandlers->get('default')->getOption('fields');
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + array(
|
||||
'uid' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('fields', $fields + [
|
||||
'uid' => [
|
||||
'id' => 'uid',
|
||||
'table' => 'users_field_data',
|
||||
'field' => 'uid',
|
||||
'relationship' => 'uid',
|
||||
),
|
||||
));
|
||||
],
|
||||
]);
|
||||
|
||||
$view->initHandlers();
|
||||
|
||||
// Check for all beatles created by admin.
|
||||
$view->filter['uid']->value = array(1);
|
||||
$view->filter['uid']->value = [1];
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array(
|
||||
$expected_result = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'uid' => 1
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
// Check for all beatles created by another user, which so doesn't exist.
|
||||
$view->initHandlers();
|
||||
$view->filter['uid']->value = array(3);
|
||||
$view->filter['uid']->value = [3];
|
||||
$this->executeView($view);
|
||||
$expected_result = array();
|
||||
$expected_result = [];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
|
@ -98,12 +98,12 @@ class RelationshipTest extends RelationshipJoinTestBase {
|
|||
$view->relationship['uid']->options['required'] = TRUE;
|
||||
$this->executeView($view);
|
||||
|
||||
$expected_result = array(
|
||||
array(
|
||||
$expected_result = [
|
||||
[
|
||||
'name' => 'John',
|
||||
'uid' => 1
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$this->assertIdenticalResultset($view, $expected_result, $this->columnMap);
|
||||
$view->destroy();
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ class RowEntityTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_entity_row');
|
||||
public static $testViews = ['test_entity_row'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -37,7 +37,7 @@ class RowEntityTest extends ViewsKernelTestBase {
|
|||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('taxonomy_term');
|
||||
$this->installConfig(array('taxonomy'));
|
||||
$this->installConfig(['taxonomy']);
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ class RowEntityTest extends ViewsKernelTestBase {
|
|||
$this->assertText($term->getName(), 'The rendered entity appears as row in the view.');
|
||||
|
||||
// Tests the available view mode options.
|
||||
$form = array();
|
||||
$form = [];
|
||||
$form_state = new FormState();
|
||||
$form_state->set('view', $view->storage);
|
||||
$view->rowPlugin->buildOptionsForm($form, $form_state);
|
||||
|
|
|
@ -24,14 +24,14 @@ class RowRenderCacheTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('user', 'node');
|
||||
public static $modules = ['user', 'node'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_row_render_cache', 'test_row_render_cache_none');
|
||||
public static $testViews = ['test_row_render_cache', 'test_row_render_cache_none'];
|
||||
|
||||
/**
|
||||
* An editor user account.
|
||||
|
|
|
@ -18,7 +18,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -26,7 +26,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
|
|||
protected function viewsData() {
|
||||
$data = parent::viewsData();
|
||||
$data['views_test_data']['table']['base']['access query tag'] = 'test_tag';
|
||||
$data['views_test_data']['table']['base']['query metadata'] = array('key1' => 'test_metadata', 'key2' => 'test_metadata2');
|
||||
$data['views_test_data']['table']['base']['query metadata'] = ['key1' => 'test_metadata', 'key2' => 'test_metadata2'];
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
|
|||
/** @var \Drupal\Core\Database\Query\Select $count_query */
|
||||
$count_query = $view->build_info['count_query'];
|
||||
|
||||
foreach (array($main_query, $count_query) as $query) {
|
||||
foreach ([$main_query, $count_query] as $query) {
|
||||
// Check query access tags.
|
||||
$this->assertTrue($query->hasTag('test_tag'));
|
||||
|
||||
|
@ -69,7 +69,7 @@ class SqlQueryTest extends ViewsKernelTestBase {
|
|||
/** @var \Drupal\Core\Database\Query\Select $count_query */
|
||||
$count_query = $view->build_info['count_query'];
|
||||
|
||||
foreach (array($main_query, $count_query) as $query) {
|
||||
foreach ([$main_query, $count_query] as $query) {
|
||||
// Check query access tags.
|
||||
$this->assertFalse($query->hasTag('test_tag'));
|
||||
|
||||
|
|
|
@ -18,12 +18,12 @@ class StyleHtmlListTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_style_html_list');
|
||||
public static $testViews = ['test_style_html_list'];
|
||||
|
||||
/**
|
||||
* Make sure that the HTML list style markup is correct.
|
||||
*/
|
||||
function testDefaultRowClasses() {
|
||||
public function testDefaultRowClasses() {
|
||||
$view = Views::getView('test_style_html_list');
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
|
|
|
@ -11,14 +11,14 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class StyleMappingTest extends StyleTestBase {
|
||||
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_style_mapping');
|
||||
public static $testViews = ['test_style_mapping'];
|
||||
|
||||
/**
|
||||
* Verifies that the fields were mapped correctly.
|
||||
|
@ -68,7 +68,7 @@ class StyleMappingTest extends StyleTestBase {
|
|||
// separated by ':'.
|
||||
$expected_result = $name . ':' . $data_set[$count][$field_id];
|
||||
$actual_result = (string) $field;
|
||||
$this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', array('%name' => $name, '%field_id' => $field_id)));
|
||||
$this->assertIdentical($expected_result, $actual_result, format_string('The fields were mapped successfully: %name => %field_id', ['%name' => $name, '%field_id' => $field_id]));
|
||||
}
|
||||
|
||||
$count++;
|
||||
|
|
|
@ -19,7 +19,7 @@ class StyleTableUnitTest extends PluginKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_table');
|
||||
public static $testViews = ['test_table'];
|
||||
|
||||
/**
|
||||
* Tests the table style.
|
||||
|
@ -101,7 +101,7 @@ class StyleTableUnitTest extends PluginKernelTestBase {
|
|||
$view->destroy();
|
||||
|
||||
// Use a existing field, and sort both ascending and descending.
|
||||
foreach (array('asc', 'desc') as $order) {
|
||||
foreach (['asc', 'desc'] as $order) {
|
||||
$this->prepareView($view);
|
||||
$style_plugin = $view->style_plugin;
|
||||
$request->query->set('sort', $order);
|
||||
|
@ -133,7 +133,7 @@ class StyleTableUnitTest extends PluginKernelTestBase {
|
|||
// Render an empty result, and ensure that the area handler is rendered.
|
||||
$view->setDisplay('default');
|
||||
$view->executed = TRUE;
|
||||
$view->result = array();
|
||||
$view->result = [];
|
||||
$output = $view->preview();
|
||||
$output = \Drupal::service('renderer')->renderRoot($output);
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class StyleTestBase extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Stores a view output in the elements.
|
||||
*/
|
||||
function storeViewPreview($output) {
|
||||
public function storeViewPreview($output) {
|
||||
$html5 = new HTML5();
|
||||
$htmlDom = $html5->loadHTML('<html><body>' . $output . '</body></html>');
|
||||
if ($htmlDom) {
|
||||
|
|
|
@ -16,12 +16,12 @@ class StyleUnformattedTest extends StyleTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* Make sure that the default css classes works as expected.
|
||||
*/
|
||||
function testDefaultRowClasses() {
|
||||
public function testDefaultRowClasses() {
|
||||
$view = Views::getView('test_view');
|
||||
$view->setDisplay();
|
||||
$output = $view->preview();
|
||||
|
|
|
@ -19,14 +19,14 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('block', 'block_test_views');
|
||||
public static $modules = ['block', 'block_test_views'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_block');
|
||||
public static $testViews = ['test_view_block'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -34,7 +34,7 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('block_test_views'));
|
||||
ViewTestData::createTestViews(get_class($this), ['block_test_views']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,11 +43,11 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
* @see \Drupal\views\Plugin\Block::getmachineNameSuggestion()
|
||||
*/
|
||||
public function testMachineNameSuggestion() {
|
||||
$plugin_definition = array(
|
||||
$plugin_definition = [
|
||||
'provider' => 'views',
|
||||
);
|
||||
];
|
||||
$plugin_id = 'views_block:test_view_block-block_1';
|
||||
$views_block = ViewsBlock::create($this->container, array(), $plugin_id, $plugin_definition);
|
||||
$views_block = ViewsBlock::create($this->container, [], $plugin_id, $plugin_definition);
|
||||
|
||||
$this->assertEqual($views_block->getMachineNameSuggestion(), 'views_block__test_view_block_block_1');
|
||||
}
|
||||
|
@ -96,8 +96,8 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
$view->setDisplay();
|
||||
|
||||
// Add a fixed argument that sets a title and save the view.
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', array(
|
||||
'name' => array(
|
||||
$view->displayHandlers->get('default')->overrideOption('arguments', [
|
||||
'name' => [
|
||||
'default_action' => 'default',
|
||||
'title_enable' => TRUE,
|
||||
'title' => 'Overridden title',
|
||||
|
@ -105,16 +105,16 @@ class ViewsBlockTest extends ViewsKernelTestBase {
|
|||
'default_argument_options' => [
|
||||
'argument' => 'fixed'
|
||||
],
|
||||
'validate' => array(
|
||||
'validate' => [
|
||||
'type' => 'none',
|
||||
'fail' => 'not found',
|
||||
),
|
||||
],
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'plugin_id' => 'string',
|
||||
)
|
||||
));
|
||||
]
|
||||
]);
|
||||
$view->save();
|
||||
|
||||
$plugin_definition = [
|
||||
|
|
|
@ -16,7 +16,7 @@ class PluginInstanceTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $pluginTypes = array(
|
||||
protected $pluginTypes = [
|
||||
'access',
|
||||
'area',
|
||||
'argument',
|
||||
|
@ -36,7 +36,7 @@ class PluginInstanceTest extends ViewsKernelTestBase {
|
|||
'sort',
|
||||
'style',
|
||||
'wizard',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* An array of plugin definitions, keyed by plugin type.
|
||||
|
@ -60,8 +60,8 @@ class PluginInstanceTest extends ViewsKernelTestBase {
|
|||
|
||||
// Check all plugin types.
|
||||
foreach ($this->pluginTypes as $type) {
|
||||
$this->assertTrue(array_key_exists($type, $this->definitions), format_string('Key for plugin type @type found.', array('@type' => $type)));
|
||||
$this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), format_string('Plugin type @type has an array of plugins.', array('@type' => $type)));
|
||||
$this->assertTrue(array_key_exists($type, $this->definitions), format_string('Key for plugin type @type found.', ['@type' => $type]));
|
||||
$this->assertTrue(is_array($this->definitions[$type]) && !empty($this->definitions[$type]), format_string('Plugin type @type has an array of plugins.', ['@type' => $type]));
|
||||
}
|
||||
|
||||
// Tests that the plugin list has not missed any types.
|
||||
|
@ -87,7 +87,7 @@ class PluginInstanceTest extends ViewsKernelTestBase {
|
|||
// good to check they can be created but for throwing any notices for
|
||||
// method signatures etc. too.
|
||||
$instance = $manager->createInstance($id);
|
||||
$this->assertTrue($instance instanceof $definition['class'], format_string('Instance of @type:@id created', array('@type' => $type, '@id' => $id)));
|
||||
$this->assertTrue($instance instanceof $definition['class'], format_string('Instance of @type:@id created', ['@type' => $type, '@id' => $id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,14 +20,14 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle');
|
||||
public static $testViews = ['test_group_by_in_filters', 'test_aggregate_count', 'test_group_by_count', 'test_group_by_count_multicardinality', 'test_group_by_field_not_within_bundle'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('entity_test', 'system', 'field', 'user', 'language');
|
||||
public static $modules = ['entity_test', 'system', 'field', 'user', 'language'];
|
||||
|
||||
/**
|
||||
* The storage for the test entity type.
|
||||
|
@ -63,7 +63,7 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
|
||||
|
||||
$types = array();
|
||||
$types = [];
|
||||
foreach ($view->result as $item) {
|
||||
// num_records is a alias for id.
|
||||
$types[$item->entity_test_name] = $item->num_records;
|
||||
|
@ -101,12 +101,12 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
|
||||
$this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
|
||||
// Group by name to identify the right count.
|
||||
$results = array();
|
||||
$results = [];
|
||||
foreach ($view->result as $item) {
|
||||
$results[$item->entity_test_name] = $item->id;
|
||||
}
|
||||
$this->assertEqual($results['name1'], $values[0], format_string('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
|
||||
$this->assertEqual($results['name2'], $values[1], format_string('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', array('@aggregation_function' => $aggregation_function)));
|
||||
$this->assertEqual($results['name1'], $values[0], format_string('Aggregation with @aggregation_function and groupby name: name1 returned the expected amount of results', ['@aggregation_function' => $aggregation_function]));
|
||||
$this->assertEqual($results['name2'], $values[1], format_string('Aggregation with @aggregation_function and groupby name: name2 returned the expected amount of results', ['@aggregation_function' => $aggregation_function]));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,18 +114,18 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
protected function setupTestEntities() {
|
||||
// Create 4 entities with name1 and 3 entities with name2.
|
||||
$entity_1 = array(
|
||||
$entity_1 = [
|
||||
'name' => 'name1',
|
||||
);
|
||||
];
|
||||
|
||||
$this->storage->create($entity_1)->save();
|
||||
$this->storage->create($entity_1)->save();
|
||||
$this->storage->create($entity_1)->save();
|
||||
$this->storage->create($entity_1)->save();
|
||||
|
||||
$entity_2 = array(
|
||||
$entity_2 = [
|
||||
'name' => 'name2',
|
||||
);
|
||||
];
|
||||
$this->storage->create($entity_2)->save();
|
||||
$this->storage->create($entity_2)->save();
|
||||
$this->storage->create($entity_2)->save();
|
||||
|
@ -135,42 +135,42 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
* Tests the count aggregation function.
|
||||
*/
|
||||
public function testGroupByCount() {
|
||||
$this->groupByTestHelper('count', array(4, 3));
|
||||
$this->groupByTestHelper('count', [4, 3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the sum aggregation function.
|
||||
*/
|
||||
public function testGroupBySum() {
|
||||
$this->groupByTestHelper('sum', array(10, 18));
|
||||
$this->groupByTestHelper('sum', [10, 18]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the average aggregation function.
|
||||
*/
|
||||
public function testGroupByAverage() {
|
||||
$this->groupByTestHelper('avg', array(2.5, 6));
|
||||
$this->groupByTestHelper('avg', [2.5, 6]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the min aggregation function.
|
||||
*/
|
||||
public function testGroupByMin() {
|
||||
$this->groupByTestHelper('min', array(1, 5));
|
||||
$this->groupByTestHelper('min', [1, 5]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the max aggregation function.
|
||||
*/
|
||||
public function testGroupByMax() {
|
||||
$this->groupByTestHelper('max', array(4, 7));
|
||||
$this->groupByTestHelper('max', [4, 7]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests aggregation with no specific function.
|
||||
*/
|
||||
public function testGroupByNone() {
|
||||
$this->groupByTestHelper(NULL, array(1, 5));
|
||||
$this->groupByTestHelper(NULL, [1, 5]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,7 +181,7 @@ class QueryGroupByTest extends ViewsKernelTestBase {
|
|||
// doesn't display SUM, COUNT, MAX, etc. functions in SELECT statement.
|
||||
|
||||
for ($x = 0; $x < 10; $x++) {
|
||||
$this->storage->create(array('name' => 'name1'))->save();
|
||||
$this->storage->create(['name' => 'name1'])->save();
|
||||
}
|
||||
|
||||
$view = Views::getView('test_group_by_in_filters');
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\views\Kernel;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\config_test\TestInstallStorage;
|
||||
use Drupal\Core\Config\InstallStorage;
|
||||
use Drupal\Core\Config\TypedConfigManager;
|
||||
|
@ -22,7 +22,7 @@ class TestViewsTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views_test_data');
|
||||
public static $modules = ['views_test_data'];
|
||||
|
||||
/**
|
||||
* Tests default configuration data type.
|
||||
|
|
|
@ -12,14 +12,14 @@ use Drupal\views\Views;
|
|||
*/
|
||||
class TokenReplaceTest extends ViewsKernelTestBase {
|
||||
|
||||
public static $modules = array('system');
|
||||
public static $modules = ['system'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_tokens', 'test_invalid_tokens');
|
||||
public static $testViews = ['test_tokens', 'test_invalid_tokens'];
|
||||
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
@ -29,25 +29,27 @@ class TokenReplaceTest extends ViewsKernelTestBase {
|
|||
/**
|
||||
* Tests core token replacements generated from a view.
|
||||
*/
|
||||
function testTokenReplacement() {
|
||||
public function testTokenReplacement() {
|
||||
$token_handler = \Drupal::token();
|
||||
$view = Views::getView('test_tokens');
|
||||
$view->setDisplay('page_1');
|
||||
// Force the view to span more than one page to better test page_count.
|
||||
$view->display_handler->getPlugin('pager')->setItemsPerPage(4);
|
||||
$this->executeView($view);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'[view:label]' => 'Test tokens',
|
||||
'[view:description]' => 'Test view to token replacement tests.',
|
||||
'[view:id]' => 'test_tokens',
|
||||
'[view:title]' => 'Test token page',
|
||||
'[view:url]' => $view->getUrl(NULL, 'page_1')->setAbsolute(TRUE)->toString(),
|
||||
'[view:total-rows]' => (string) $view->total_rows,
|
||||
'[view:total-rows]' => '5',
|
||||
'[view:base-table]' => 'views_test_data',
|
||||
'[view:base-field]' => 'id',
|
||||
'[view:items-per-page]' => '10',
|
||||
'[view:items-per-page]' => '4',
|
||||
'[view:current-page]' => '1',
|
||||
'[view:page-count]' => '1',
|
||||
);
|
||||
'[view:page-count]' => '2',
|
||||
];
|
||||
|
||||
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($view->storage);
|
||||
$metadata_tests = [];
|
||||
|
@ -65,47 +67,84 @@ class TokenReplaceTest extends ViewsKernelTestBase {
|
|||
|
||||
foreach ($expected as $token => $expected_output) {
|
||||
$bubbleable_metadata = new BubbleableMetadata();
|
||||
$output = $token_handler->replace($token, array('view' => $view), [], $bubbleable_metadata);
|
||||
$this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
|
||||
$output = $token_handler->replace($token, ['view' => $view], [], $bubbleable_metadata);
|
||||
$this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', ['%token' => $token]));
|
||||
$this->assertEqual($bubbleable_metadata, $metadata_tests[$token]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests core token replacements generated from a view.
|
||||
*/
|
||||
public function testTokenReplacementWithMiniPager() {
|
||||
$token_handler = \Drupal::token();
|
||||
$view = Views::getView('test_tokens');
|
||||
$view->setDisplay('page_3');
|
||||
$this->executeView($view);
|
||||
|
||||
$this->assertSame(TRUE, $view->get_total_rows, 'The query was set to calculate the total number of rows.');
|
||||
|
||||
$expected = [
|
||||
'[view:label]' => 'Test tokens',
|
||||
'[view:description]' => 'Test view to token replacement tests.',
|
||||
'[view:id]' => 'test_tokens',
|
||||
'[view:title]' => 'Test token page with minipager',
|
||||
'[view:url]' => $view->getUrl(NULL, 'page_3')
|
||||
->setAbsolute(TRUE)
|
||||
->toString(),
|
||||
'[view:total-rows]' => '5',
|
||||
'[view:base-table]' => 'views_test_data',
|
||||
'[view:base-field]' => 'id',
|
||||
'[view:items-per-page]' => '2',
|
||||
'[view:current-page]' => '1',
|
||||
'[view:page-count]' => '3',
|
||||
];
|
||||
|
||||
$base_bubbleable_metadata = BubbleableMetadata::createFromObject($view->storage);
|
||||
|
||||
foreach ($expected as $token => $expected_output) {
|
||||
$bubbleable_metadata = new BubbleableMetadata();
|
||||
$output = $token_handler->replace($token, ['view' => $view], [], $bubbleable_metadata);
|
||||
$this->assertSame($expected_output, $output, sprintf('Token %s replaced correctly.', $token));
|
||||
$this->assertEquals($base_bubbleable_metadata, $bubbleable_metadata);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests core token replacements generated from a view without results.
|
||||
*/
|
||||
function testTokenReplacementNoResults() {
|
||||
public function testTokenReplacementNoResults() {
|
||||
$token_handler = \Drupal::token();
|
||||
$view = Views::getView('test_tokens');
|
||||
$view->setDisplay('page_2');
|
||||
$this->executeView($view);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'[view:page-count]' => '1',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($expected as $token => $expected_output) {
|
||||
$output = $token_handler->replace($token, array('view' => $view));
|
||||
$this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
|
||||
$output = $token_handler->replace($token, ['view' => $view]);
|
||||
$this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', ['%token' => $token]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests path token replacements generated from a view without a path.
|
||||
*/
|
||||
function testTokenReplacementNoPath() {
|
||||
public function testTokenReplacementNoPath() {
|
||||
$token_handler = \Drupal::token();
|
||||
$view = Views::getView('test_invalid_tokens');
|
||||
$view->setDisplay('block_1');
|
||||
$this->executeView($view);
|
||||
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'[view:url]' => '',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($expected as $token => $expected_output) {
|
||||
$output = $token_handler->replace($token, array('view' => $view));
|
||||
$this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', array('%token' => $token)));
|
||||
$output = $token_handler->replace($token, ['view' => $view]);
|
||||
$this->assertIdentical($output, $expected_output, format_string('Token %token replaced correctly.', ['%token' => $token]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,14 +38,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_destroy', 'test_executable_displays');
|
||||
public static $testViews = ['test_destroy', 'test_executable_displays'];
|
||||
|
||||
/**
|
||||
* Properties that should be stored in the configuration.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $configProperties = array(
|
||||
protected $configProperties = [
|
||||
'disabled',
|
||||
'name',
|
||||
'description',
|
||||
|
@ -54,14 +54,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
'label',
|
||||
'core',
|
||||
'display',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Properties that should be stored in the executable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $executableProperties = array(
|
||||
protected $executableProperties = [
|
||||
'storage',
|
||||
'built',
|
||||
'executed',
|
||||
|
@ -74,14 +74,14 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
'exposed_raw_input',
|
||||
'old_view',
|
||||
'parent_views',
|
||||
);
|
||||
];
|
||||
|
||||
protected function setUpFixtures() {
|
||||
$this->installEntitySchema('user');
|
||||
$this->installEntitySchema('node');
|
||||
$this->installEntitySchema('comment');
|
||||
$this->installSchema('comment', array('comment_entity_statistics'));
|
||||
$this->installConfig(array('system', 'field', 'node', 'comment'));
|
||||
$this->installSchema('comment', ['comment_entity_statistics']);
|
||||
$this->installConfig(['system', 'field', 'node', 'comment']);
|
||||
|
||||
NodeType::create([
|
||||
'type' => 'page',
|
||||
|
@ -90,7 +90,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$this->addDefaultCommentField('node', 'page');
|
||||
parent::setUpFixtures();
|
||||
|
||||
$this->installConfig(array('filter'));
|
||||
$this->installConfig(['filter']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
if ($type == 'relationship') {
|
||||
continue;
|
||||
}
|
||||
$this->assertTrue(count($view->$type), format_string('Make sure a %type instance got instantiated.', array('%type' => $type)));
|
||||
$this->assertTrue(count($view->$type), format_string('Make sure a %type instance got instantiated.', ['%type' => $type]));
|
||||
}
|
||||
|
||||
// initHandlers() should create display handlers automatically as well.
|
||||
|
@ -256,7 +256,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$this->assertTrue($view->rowPlugin instanceof Fields);
|
||||
|
||||
// Test the newDisplay() method.
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->create(array('id' => 'test_executable_displays'));
|
||||
$view = $this->container->get('entity.manager')->getStorage('view')->create(['id' => 'test_executable_displays']);
|
||||
$executable = $view->getExecutable();
|
||||
|
||||
$executable->newDisplay('page');
|
||||
|
@ -289,10 +289,10 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$this->assertNull($view->usePager());
|
||||
|
||||
// Add a pager, initialize, and test.
|
||||
$view->displayHandlers->get('default')->overrideOption('pager', array(
|
||||
$view->displayHandlers->get('default')->overrideOption('pager', [
|
||||
'type' => 'full',
|
||||
'options' => array('items_per_page' => 10),
|
||||
));
|
||||
'options' => ['items_per_page' => 10],
|
||||
]);
|
||||
$view->initPager();
|
||||
$this->assertTrue($view->usePager());
|
||||
|
||||
|
@ -302,10 +302,10 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$this->assertEqual($view->getOffset(), $rand);
|
||||
|
||||
// Test the getBaseTable() method.
|
||||
$expected = array(
|
||||
$expected = [
|
||||
'views_test_data' => TRUE,
|
||||
'#global' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->assertIdentical($view->getBaseTables(), $expected);
|
||||
|
||||
// Test response methods.
|
||||
|
@ -386,7 +386,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
public function testGetHandlerTypes() {
|
||||
$types = ViewExecutable::getHandlerTypes();
|
||||
foreach (array('field', 'filter', 'argument', 'sort', 'header', 'footer', 'empty') as $type) {
|
||||
foreach (['field', 'filter', 'argument', 'sort', 'header', 'footer', 'empty'] as $type) {
|
||||
$this->assertTrue(isset($types[$type]));
|
||||
// @todo The key on the display should be footers, headers and empties
|
||||
// or something similar instead of the singular, but so long check for
|
||||
|
@ -430,7 +430,7 @@ class ViewExecutableTest extends ViewsKernelTestBase {
|
|||
$match = function($value) use ($display) {
|
||||
return strpos($value, $display->display['display_title']) !== FALSE;
|
||||
};
|
||||
$this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', array('@id' => $id)));
|
||||
$this->assertTrue(array_filter($validate[$id], $match), format_string('Error message found for @id display', ['@id' => $id]));
|
||||
$count++;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $configProperties = array(
|
||||
protected $configProperties = [
|
||||
'status',
|
||||
'module',
|
||||
'id',
|
||||
|
@ -31,7 +31,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
'label',
|
||||
'core',
|
||||
'display',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The entity type definition.
|
||||
|
@ -52,12 +52,12 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view_storage');
|
||||
public static $testViews = ['test_view_storage'];
|
||||
|
||||
/**
|
||||
* Tests CRUD operations.
|
||||
*/
|
||||
function testConfigurationEntityCRUD() {
|
||||
public function testConfigurationEntityCRUD() {
|
||||
// Get the configuration entity type and controller.
|
||||
$this->entityType = \Drupal::entityManager()->getDefinition('view');
|
||||
$this->controller = $this->container->get('entity.manager')->getStorage('view');
|
||||
|
@ -85,11 +85,11 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
// expected properties.
|
||||
$this->assertTrue($view instanceof View, 'Single View instance loaded.');
|
||||
foreach ($this->configProperties as $property) {
|
||||
$this->assertTrue($view->get($property) !== NULL, format_string('Property: @property loaded onto View.', array('@property' => $property)));
|
||||
$this->assertTrue($view->get($property) !== NULL, format_string('Property: @property loaded onto View.', ['@property' => $property]));
|
||||
}
|
||||
|
||||
// Check the displays have been loaded correctly from config display data.
|
||||
$expected_displays = array('default', 'block_1', 'page_1');
|
||||
$expected_displays = ['default', 'block_1', 'page_1'];
|
||||
$this->assertEqual(array_keys($view->get('display')), $expected_displays, 'The correct display names are present.');
|
||||
|
||||
// Check each ViewDisplay object and confirm that it has the correct key and
|
||||
|
@ -101,7 +101,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
// exists.
|
||||
$original_options = $data['display'][$key];
|
||||
foreach ($original_options as $orig_key => $value) {
|
||||
$this->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', array('@key' => $key)));
|
||||
$this->assertIdentical($display[$orig_key], $value, format_string('@key is identical to saved data', ['@key' => $key]));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,12 +115,12 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
*/
|
||||
protected function createTests() {
|
||||
// Create a new View instance with empty values.
|
||||
$created = $this->controller->create(array());
|
||||
$created = $this->controller->create([]);
|
||||
|
||||
$this->assertTrue($created instanceof View, 'Created object is a View.');
|
||||
// Check that the View contains all of the properties.
|
||||
foreach ($this->configProperties as $property) {
|
||||
$this->assertTrue(property_exists($created, $property), format_string('Property: @property created on View.', array('@property' => $property)));
|
||||
$this->assertTrue(property_exists($created, $property), format_string('Property: @property created on View.', ['@property' => $property]));
|
||||
}
|
||||
|
||||
// Create a new View instance with config values.
|
||||
|
@ -137,8 +137,8 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test all properties except displays.
|
||||
foreach ($properties as $property) {
|
||||
$this->assertTrue($created->get($property) !== NULL, format_string('Property: @property created on View.', array('@property' => $property)));
|
||||
$this->assertIdentical($values[$property], $created->get($property), format_string('Property value: @property matches configuration value.', array('@property' => $property)));
|
||||
$this->assertTrue($created->get($property) !== NULL, format_string('Property: @property created on View.', ['@property' => $property]));
|
||||
$this->assertIdentical($values[$property], $created->get($property), format_string('Property value: @property matches configuration value.', ['@property' => $property]));
|
||||
}
|
||||
|
||||
// Check the UUID of the loaded View.
|
||||
|
@ -177,44 +177,44 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
* Tests the display related functions like getDisplaysList().
|
||||
*/
|
||||
protected function displayMethodTests() {
|
||||
$config['display'] = array(
|
||||
'page_1' => array(
|
||||
'display_options' => array('path' => 'test'),
|
||||
$config['display'] = [
|
||||
'page_1' => [
|
||||
'display_options' => ['path' => 'test'],
|
||||
'display_plugin' => 'page',
|
||||
'id' => 'page_2',
|
||||
'display_title' => 'Page 1',
|
||||
'position' => 1
|
||||
),
|
||||
'feed_1' => array(
|
||||
'display_options' => array('path' => 'test.xml'),
|
||||
],
|
||||
'feed_1' => [
|
||||
'display_options' => ['path' => 'test.xml'],
|
||||
'display_plugin' => 'feed',
|
||||
'id' => 'feed',
|
||||
'display_title' => 'Feed',
|
||||
'position' => 2
|
||||
),
|
||||
'page_2' => array(
|
||||
'display_options' => array('path' => 'test/%/extra'),
|
||||
],
|
||||
'page_2' => [
|
||||
'display_options' => ['path' => 'test/%/extra'],
|
||||
'display_plugin' => 'page',
|
||||
'id' => 'page_2',
|
||||
'display_title' => 'Page 2',
|
||||
'position' => 3
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$view = $this->controller->create($config);
|
||||
|
||||
// Tests Drupal\views\Entity\View::addDisplay()
|
||||
$view = $this->controller->create(array());
|
||||
$view = $this->controller->create([]);
|
||||
$random_title = $this->randomMachineName();
|
||||
|
||||
$id = $view->addDisplay('page', $random_title);
|
||||
$this->assertEqual($id, 'page_1', format_string('Make sure the first display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_1')));
|
||||
$this->assertEqual($id, 'page_1', format_string('Make sure the first display (%id_new) has the expected ID (%id)', ['%id_new' => $id, '%id' => 'page_1']));
|
||||
$display = $view->get('display');
|
||||
$this->assertEqual($display[$id]['display_title'], $random_title);
|
||||
|
||||
$random_title = $this->randomMachineName();
|
||||
$id = $view->addDisplay('page', $random_title);
|
||||
$display = $view->get('display');
|
||||
$this->assertEqual($id, 'page_2', format_string('Make sure the second display (%id_new) has the expected ID (%id)', array('%id_new' => $id, '%id' => 'page_2')));
|
||||
$this->assertEqual($id, 'page_2', format_string('Make sure the second display (%id_new) has the expected ID (%id)', ['%id_new' => $id, '%id' => 'page_2']));
|
||||
$this->assertEqual($display[$id]['display_title'], $random_title);
|
||||
|
||||
$id = $view->addDisplay('page');
|
||||
|
@ -233,7 +233,7 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
// Tests Drupal\views\Entity\View::generateDisplayId(). Since
|
||||
// generateDisplayId() is protected, we have to use reflection to unit-test
|
||||
// it.
|
||||
$view = $this->controller->create(array());
|
||||
$view = $this->controller->create([]);
|
||||
$ref_generate_display_id = new \ReflectionMethod($view, 'generateDisplayId');
|
||||
$ref_generate_display_id->setAccessible(TRUE);
|
||||
$this->assertEqual(
|
||||
|
@ -254,38 +254,38 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
);
|
||||
|
||||
// Tests item related methods().
|
||||
$view = $this->controller->create(array('base_table' => 'views_test_data'));
|
||||
$view = $this->controller->create(['base_table' => 'views_test_data']);
|
||||
$view->addDisplay('default');
|
||||
$view = $view->getExecutable();
|
||||
|
||||
$display_id = 'default';
|
||||
$expected_items = array();
|
||||
$expected_items = [];
|
||||
// Tests addHandler with getItem.
|
||||
// Therefore add one item without any options and one item with some
|
||||
// options.
|
||||
$id1 = $view->addHandler($display_id, 'field', 'views_test_data', 'id');
|
||||
$item1 = $view->getHandler($display_id, 'field', 'id');
|
||||
$expected_items[$id1] = $expected_item = array(
|
||||
$expected_items[$id1] = $expected_item = [
|
||||
'id' => 'id',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'id',
|
||||
'plugin_id' => 'numeric',
|
||||
);
|
||||
];
|
||||
$this->assertEqual($item1, $expected_item);
|
||||
|
||||
$options = array(
|
||||
'alter' => array(
|
||||
$options = [
|
||||
'alter' => [
|
||||
'text' => $this->randomMachineName()
|
||||
)
|
||||
);
|
||||
]
|
||||
];
|
||||
$id2 = $view->addHandler($display_id, 'field', 'views_test_data', 'name', $options);
|
||||
$item2 = $view->getHandler($display_id, 'field', 'name');
|
||||
$expected_items[$id2] = $expected_item = array(
|
||||
$expected_items[$id2] = $expected_item = [
|
||||
'id' => 'name',
|
||||
'table' => 'views_test_data',
|
||||
'field' => 'name',
|
||||
'plugin_id' => 'standard',
|
||||
) + $options;
|
||||
] + $options;
|
||||
$this->assertEqual($item2, $expected_item);
|
||||
|
||||
// Tests the expected fields from the previous additions.
|
||||
|
@ -293,11 +293,11 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
|
||||
// Alter an existing item via setItem and check the result via getItem
|
||||
// and getItems.
|
||||
$item = array(
|
||||
'alter' => array(
|
||||
$item = [
|
||||
'alter' => [
|
||||
'text' => $this->randomMachineName(),
|
||||
)
|
||||
) + $item1;
|
||||
]
|
||||
] + $item1;
|
||||
$expected_items[$id1] = $item;
|
||||
$view->setHandler($display_id, 'field', $id1, $item);
|
||||
$this->assertEqual($view->getHandler($display_id, 'field', 'id'), $item);
|
||||
|
@ -327,24 +327,24 @@ class ViewStorageTest extends ViewsKernelTestBase {
|
|||
|
||||
// Check the other properties.
|
||||
// @todo Create a reusable property on the base test class for these?
|
||||
$config_properties = array(
|
||||
$config_properties = [
|
||||
'disabled',
|
||||
'description',
|
||||
'tag',
|
||||
'base_table',
|
||||
'label',
|
||||
'core',
|
||||
);
|
||||
];
|
||||
|
||||
foreach ($config_properties as $property) {
|
||||
$this->assertIdentical($view->storage->get($property), $copy->get($property), format_string('@property property is identical.', array('@property' => $property)));
|
||||
$this->assertIdentical($view->storage->get($property), $copy->get($property), format_string('@property property is identical.', ['@property' => $property]));
|
||||
}
|
||||
|
||||
// Check the displays are the same.
|
||||
$copy_display = $copy->get('display');
|
||||
foreach ($view->storage->get('display') as $id => $display) {
|
||||
// assertIdentical will not work here.
|
||||
$this->assertEqual($display, $copy_display[$id], format_string('The @display display has been copied correctly.', array('@display' => $id)));
|
||||
$this->assertEqual($display, $copy_display[$id], format_string('The @display display has been copied correctly.', ['@display' => $id]));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,14 +19,14 @@ class ViewsHooksTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_view');
|
||||
public static $testViews = ['test_view'];
|
||||
|
||||
/**
|
||||
* An array of available views hooks to test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $hooks = array (
|
||||
protected static $hooks = [
|
||||
'views_data' => 'all',
|
||||
'views_data_alter' => 'alter',
|
||||
'views_query_substitutions' => 'view',
|
||||
|
@ -41,7 +41,7 @@ class ViewsHooksTest extends ViewsKernelTestBase {
|
|||
'views_post_render' => 'view',
|
||||
'views_query_alter' => 'view',
|
||||
'views_invalidate_cache' => 'all',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The module handler to use for invoking hooks.
|
||||
|
@ -65,28 +65,28 @@ class ViewsHooksTest extends ViewsKernelTestBase {
|
|||
|
||||
// Test each hook is found in the implementations array and is invoked.
|
||||
foreach (static::$hooks as $hook => $type) {
|
||||
$this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', array('@hook' => $hook)));
|
||||
$this->assertTrue($this->moduleHandler->implementsHook('views_test_data', $hook), format_string('The hook @hook was registered.', ['@hook' => $hook]));
|
||||
|
||||
if ($hook == 'views_post_render') {
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, array($view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')));
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, [$view, &$view->display_handler->output, $view->display_handler->getPlugin('cache')]);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch ($type) {
|
||||
case 'view':
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, array($view));
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, [$view]);
|
||||
break;
|
||||
|
||||
case 'alter':
|
||||
$data = array();
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, array($data));
|
||||
$data = [];
|
||||
$this->moduleHandler->invoke('views_test_data', $hook, [$data]);
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->moduleHandler->invoke('views_test_data', $hook);
|
||||
}
|
||||
|
||||
$this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', array('%hook' => $hook)));
|
||||
$this->assertTrue($this->container->get('state')->get('views_hook_test_' . $hook), format_string('The %hook hook was invoked.', ['%hook' => $hook]));
|
||||
// Reset the module implementations cache, so we ensure that the
|
||||
// .views.inc file is loaded actively.
|
||||
$this->moduleHandler->resetImplementations();
|
||||
|
|
|
@ -20,7 +20,7 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('language', 'system', 'user', 'views_ui');
|
||||
public static $modules = ['language', 'system', 'user', 'views_ui'];
|
||||
|
||||
/**
|
||||
* Contains thw wizard plugin manager.
|
||||
|
@ -32,9 +32,9 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
|
|||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(array('language'));
|
||||
$this->installConfig(['language']);
|
||||
|
||||
$this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', array());
|
||||
$this->wizard = $this->container->get('plugin.manager.views.wizard')->createInstance('standard:views_test_data', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,7 @@ class WizardPluginBaseKernelTest extends ViewsKernelTestBase {
|
|||
* @see \Drupal\views\Plugin\views\wizard\WizardPluginBase
|
||||
*/
|
||||
public function testCreateView() {
|
||||
$form = array();
|
||||
$form = [];
|
||||
$form_state = new FormState();
|
||||
$form = $this->wizard->buildForm($form, $form_state);
|
||||
$random_id = strtolower($this->randomMachineName());
|
||||
|
|
|
@ -9,6 +9,8 @@ use Drupal\views\Controller\ViewAjaxController;
|
|||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\views\Controller\ViewAjaxController
|
||||
|
@ -113,18 +115,15 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
|
||||
/**
|
||||
* Tests missing view_name and view_display_id
|
||||
*
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function testMissingViewName() {
|
||||
$request = new Request();
|
||||
$this->setExpectedException(NotFoundHttpException::class);
|
||||
$this->viewAjaxController->ajaxView($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests with view_name and view_display_id but not existing view.
|
||||
*
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public function testMissingView() {
|
||||
$request = new Request();
|
||||
|
@ -136,13 +135,12 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->with('test_view')
|
||||
->will($this->returnValue(FALSE));
|
||||
|
||||
$this->setExpectedException(NotFoundHttpException::class);
|
||||
$this->viewAjaxController->ajaxView($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a view without having access to it.
|
||||
*
|
||||
* @expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException
|
||||
*/
|
||||
public function testAccessDeniedView() {
|
||||
$request = new Request();
|
||||
|
@ -170,6 +168,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->with($view)
|
||||
->will($this->returnValue($executable));
|
||||
|
||||
$this->setExpectedException(AccessDeniedHttpException::class);
|
||||
$this->viewAjaxController->ajaxView($request);
|
||||
}
|
||||
|
||||
|
@ -228,7 +227,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
list($view, $executable) = $this->setupValidMocks();
|
||||
$executable->expects($this->once())
|
||||
->method('preview')
|
||||
->with('page_1', array('arg1', 'arg2'));
|
||||
->with('page_1', ['arg1', 'arg2']);
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
|
@ -249,7 +248,7 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
list($view, $executable) = $this->setupValidMocks();
|
||||
$executable->expects($this->once())
|
||||
->method('preview')
|
||||
->with('page_1', $this->identicalTo(array('arg1', NULL)));
|
||||
->with('page_1', $this->identicalTo(['arg1', NULL]));
|
||||
|
||||
$response = $this->viewAjaxController->ajaxView($request);
|
||||
$this->assertTrue($response instanceof ViewAjaxResponse);
|
||||
|
@ -317,14 +316,14 @@ class ViewAjaxControllerTest extends UnitTestCase {
|
|||
->will($this->returnValue(TRUE));
|
||||
$executable->expects($this->once())
|
||||
->method('preview')
|
||||
->will($this->returnValue(array('#markup' => 'View result')));
|
||||
->will($this->returnValue(['#markup' => 'View result']));
|
||||
|
||||
$this->executableFactory->expects($this->once())
|
||||
->method('get')
|
||||
->with($view)
|
||||
->will($this->returnValue($executable));
|
||||
|
||||
return array($view, $executable);
|
||||
return [$view, $executable];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,8 +87,14 @@ class EntityViewsDataTest extends UnitTestCase {
|
|||
|
||||
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$typed_data_manager->expects($this->any())
|
||||
->method('createDataDefinition')
|
||||
->willReturn($this->getMock('Drupal\Core\TypedData\DataDefinitionInterface'));
|
||||
->method('createDataDefinition')
|
||||
->willReturn($this->getMock('Drupal\Core\TypedData\DataDefinitionInterface'));
|
||||
|
||||
$typed_data_manager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with($this->equalTo('field_item:string_long'))
|
||||
->willReturn(['class' => '\Drupal\Core\Field\Plugin\Field\FieldType\StringLongItem']);
|
||||
|
||||
$this->baseEntityType = new TestEntityType([
|
||||
'base_table' => 'entity_test',
|
||||
'id' => 'entity_test',
|
||||
|
@ -142,16 +148,16 @@ class EntityViewsDataTest extends UnitTestCase {
|
|||
->setLabel('Description')
|
||||
->setDescription('A description of the term.')
|
||||
->setTranslatable(TRUE)
|
||||
->setDisplayOptions('view', array(
|
||||
->setDisplayOptions('view', [
|
||||
'label' => 'hidden',
|
||||
'type' => 'text_default',
|
||||
'weight' => 0,
|
||||
))
|
||||
])
|
||||
->setDisplayConfigurable('view', TRUE)
|
||||
->setDisplayOptions('form', array(
|
||||
->setDisplayOptions('form', [
|
||||
'type' => 'text_textfield',
|
||||
'weight' => 0,
|
||||
))
|
||||
])
|
||||
->setDisplayConfigurable('form', TRUE);
|
||||
|
||||
// Add a URL field; this example is from the Comment entity.
|
||||
|
@ -1107,3 +1113,12 @@ if (!function_exists('t')) {
|
|||
return strtr($string, $args);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
namespace Drupal\Core\Entity;
|
||||
|
||||
if (!function_exists('t')) {
|
||||
function t($string, array $args = []) {
|
||||
return strtr($string, $args);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,16 +68,16 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
|
||||
$display_1->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
->will($this->returnValue(array('test_id.page_1' => 'views.test_id.page_1')));
|
||||
->will($this->returnValue(['test_id.page_1' => 'views.test_id.page_1']));
|
||||
$display_2->expects($this->once())
|
||||
->method('collectRoutes')
|
||||
->will($this->returnValue(array('test_id.page_2' => 'views.test_id.page_2')));
|
||||
->will($this->returnValue(['test_id.page_2' => 'views.test_id.page_2']));
|
||||
|
||||
$this->routeSubscriber->routes();
|
||||
|
||||
$this->state->expects($this->once())
|
||||
->method('set')
|
||||
->with('views.view_route_names', array('test_id.page_1' => 'views.test_id.page_1', 'test_id.page_2' => 'views.test_id.page_2'));
|
||||
->with('views.view_route_names', ['test_id.page_1' => 'views.test_id.page_1', 'test_id.page_2' => 'views.test_id.page_2']);
|
||||
$this->routeSubscriber->routeRebuildFinished();
|
||||
}
|
||||
|
||||
|
@ -89,8 +89,8 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
public function testOnAlterRoutes() {
|
||||
$collection = new RouteCollection();
|
||||
// The first route will be overridden later.
|
||||
$collection->add('test_route', new Route('test_route', array('_controller' => 'Drupal\Tests\Core\Controller\TestController')));
|
||||
$route_2 = new Route('test_route/example', array('_controller' => 'Drupal\Tests\Core\Controller\TestController'));
|
||||
$collection->add('test_route', new Route('test_route', ['_controller' => 'Drupal\Tests\Core\Controller\TestController']));
|
||||
$route_2 = new Route('test_route/example', ['_controller' => 'Drupal\Tests\Core\Controller\TestController']);
|
||||
$collection->add('test_route_2', $route_2);
|
||||
|
||||
$route_event = new RouteBuildEvent($collection, 'views');
|
||||
|
@ -128,7 +128,7 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
|
||||
$this->state->expects($this->once())
|
||||
->method('set')
|
||||
->with('views.view_route_names', array('test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2'));
|
||||
->with('views.view_route_names', ['test_id.page_1' => 'test_route', 'test_id.page_2' => 'views.test_id.page_2']);
|
||||
|
||||
$collection = $route_event->getRouteCollection();
|
||||
$this->assertEquals(['test_route', 'test_route_2', 'views.test_id.page_2'], array_keys($collection->all()));
|
||||
|
@ -163,11 +163,11 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
|
||||
$executable->expects($this->any())
|
||||
->method('setDisplay')
|
||||
->will($this->returnValueMap(array(
|
||||
array('page_1', TRUE),
|
||||
array('page_2', TRUE),
|
||||
array('page_3', FALSE),
|
||||
)));
|
||||
->will($this->returnValueMap([
|
||||
['page_1', TRUE],
|
||||
['page_2', TRUE],
|
||||
['page_3', FALSE],
|
||||
]));
|
||||
|
||||
// Ensure that only the first two displays are actually called.
|
||||
$display_1 = $this->getMock('Drupal\views\Plugin\views\display\DisplayRouterInterface');
|
||||
|
@ -178,18 +178,18 @@ class RouteSubscriberTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$display_collection->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnValueMap(array(
|
||||
array('page_1', $display_1),
|
||||
array('page_2', $display_2),
|
||||
)));
|
||||
->will($this->returnValueMap([
|
||||
['page_1', $display_1],
|
||||
['page_2', $display_2],
|
||||
]));
|
||||
$executable->displayHandlers = $display_collection;
|
||||
|
||||
$this->routeSubscriber->applicableViews = array();
|
||||
$this->routeSubscriber->applicableViews[] = array('test_id', 'page_1');
|
||||
$this->routeSubscriber->applicableViews[] = array('test_id', 'page_2');
|
||||
$this->routeSubscriber->applicableViews[] = array('test_id', 'page_3');
|
||||
$this->routeSubscriber->applicableViews = [];
|
||||
$this->routeSubscriber->applicableViews[] = ['test_id', 'page_1'];
|
||||
$this->routeSubscriber->applicableViews[] = ['test_id', 'page_2'];
|
||||
$this->routeSubscriber->applicableViews[] = ['test_id', 'page_3'];
|
||||
|
||||
return array($display_1, $display_2);
|
||||
return [$display_1, $display_2];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,11 +6,6 @@ use Drupal\Core\DependencyInjection\ContainerBuilder;
|
|||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\views\Plugin\Block\ViewsBlock;
|
||||
|
||||
// @todo Remove this once the constant got converted.
|
||||
if (!defined('BLOCK_LABEL_VISIBLE')) {
|
||||
define('BLOCK_LABEL_VISIBLE', 'visible');
|
||||
}
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\views\Plugin\block\ViewsBlock
|
||||
* @group views
|
||||
|
@ -67,7 +62,7 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
$condition_plugin_manager = $this->getMock('Drupal\Core\Executable\ExecutableManagerInterface');
|
||||
$condition_plugin_manager->expects($this->any())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue(array()));
|
||||
->will($this->returnValue([]));
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('plugin.manager.condition', $condition_plugin_manager);
|
||||
\Drupal::setContainer($container);
|
||||
|
@ -116,6 +111,11 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
$this->displayHandler->expects($this->any())
|
||||
->method('getPluginId')
|
||||
->willReturn('block');
|
||||
|
||||
$this->displayHandler->expects($this->any())
|
||||
->method('getHandlers')
|
||||
->willReturn([]);
|
||||
|
||||
$this->executable->display_handler = $this->displayHandler;
|
||||
|
||||
$this->storage = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigEntityStorage')
|
||||
|
@ -136,15 +136,15 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
*/
|
||||
public function testBuild() {
|
||||
$output = $this->randomMachineName(100);
|
||||
$build = array('view_build' => $output, '#view_id' => 'test_view', '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', '#view_display_show_admin_links' => FALSE, '#view_display_plugin_id' => 'block', '#pre_rendered' => TRUE);
|
||||
$build = ['view_build' => $output, '#view_id' => 'test_view', '#view_display_plugin_class' => '\Drupal\views\Plugin\views\display\Block', '#view_display_show_admin_links' => FALSE, '#view_display_plugin_id' => 'block', '#pre_rendered' => TRUE];
|
||||
$this->executable->expects($this->once())
|
||||
->method('buildRenderable')
|
||||
->with('block_1', [])
|
||||
->willReturn($build);
|
||||
|
||||
$block_id = 'views_block:test_view-block_1';
|
||||
$config = array();
|
||||
$definition = array();
|
||||
$config = [];
|
||||
$definition = [];
|
||||
|
||||
$definition['provider'] = 'views';
|
||||
$plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
|
||||
|
@ -187,13 +187,13 @@ class ViewsBlockTest extends UnitTestCase {
|
|||
->willReturn($output);
|
||||
|
||||
$block_id = 'views_block:test_view-block_1';
|
||||
$config = array();
|
||||
$definition = array();
|
||||
$config = [];
|
||||
$definition = [];
|
||||
|
||||
$definition['provider'] = 'views';
|
||||
$plugin = new ViewsBlock($config, $block_id, $definition, $this->executableFactory, $this->storage, $this->account);
|
||||
|
||||
$this->assertEquals(array(), $plugin->build());
|
||||
$this->assertEquals([], $plugin->build());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
*/
|
||||
protected $viewStorage;
|
||||
|
||||
protected $baseDefinition = array(
|
||||
protected $baseDefinition = [
|
||||
'class' => '\Drupal\views\Plugin\Menu\LocalTask\ViewsLocalTask',
|
||||
'deriver' => '\Drupal\views\Plugin\Derivative\ViewsLocalTask'
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* The tested local task derivative class.
|
||||
|
@ -63,11 +63,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
* @see \Drupal\views\Plugin\Derivative\ViewsLocalTask::getDerivativeDefinitions()
|
||||
*/
|
||||
public function testGetDerivativeDefinitionsWithoutHookMenuViews() {
|
||||
$result = array();
|
||||
$result = [];
|
||||
$this->localTaskDerivative->setApplicableMenuViews($result);
|
||||
|
||||
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
|
||||
$this->assertEquals(array(), $definitions);
|
||||
$this->assertEquals([], $definitions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -78,13 +78,13 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
|
||||
->setMethods(array('getOption'))
|
||||
->setMethods(['getOption'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$display_plugin->expects($this->once())
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(array('type' => 'normal')));
|
||||
->will($this->returnValue(['type' => 'normal']));
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$storage = $this->getMockBuilder('Drupal\views\Entity\View')
|
||||
|
@ -106,7 +106,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->localTaskDerivative->setApplicableMenuViews($result);
|
||||
|
||||
$definitions = $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
|
||||
$this->assertEquals(array(), $definitions);
|
||||
$this->assertEquals([], $definitions);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -133,20 +133,20 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->willReturn($storage);
|
||||
|
||||
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
|
||||
->setMethods(array('getOption'))
|
||||
->setMethods(['getOption'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$display_plugin->expects($this->once())
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(array('type' => 'tab', 'weight' => 12, 'title' => 'Example title')));
|
||||
->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
$this->localTaskDerivative->setApplicableMenuViews($result);
|
||||
|
||||
// Mock the view route names state.
|
||||
$view_route_names = array();
|
||||
$view_route_names = [];
|
||||
$view_route_names['example_view.page_1'] = 'view.example_view.page_1';
|
||||
$this->state->expects($this->once())
|
||||
->method('get')
|
||||
|
@ -186,20 +186,20 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->willReturn($storage);
|
||||
|
||||
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
|
||||
->setMethods(array('getOption'))
|
||||
->setMethods(['getOption'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$display_plugin->expects($this->once())
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(array('type' => 'tab', 'weight' => 12)));
|
||||
->will($this->returnValue(['type' => 'tab', 'weight' => 12]));
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
$this->localTaskDerivative->setApplicableMenuViews($result);
|
||||
|
||||
// Mock the view route names state.
|
||||
$view_route_names = array();
|
||||
$view_route_names = [];
|
||||
// Setup a view which overrides an existing route.
|
||||
$view_route_names['example_view.page_1'] = 'example_overridden_route';
|
||||
$this->state->expects($this->once())
|
||||
|
@ -235,20 +235,20 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->willReturn($storage);
|
||||
|
||||
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
|
||||
->setMethods(array('getOption'))
|
||||
->setMethods(['getOption'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$display_plugin->expects($this->exactly(2))
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(array('type' => 'default tab', 'weight' => 12, 'title' => 'Example title')));
|
||||
->will($this->returnValue(['type' => 'default tab', 'weight' => 12, 'title' => 'Example title']));
|
||||
$executable->display_handler = $display_plugin;
|
||||
|
||||
$result = [['example_view', 'page_1']];
|
||||
$this->localTaskDerivative->setApplicableMenuViews($result);
|
||||
|
||||
// Mock the view route names state.
|
||||
$view_route_names = array();
|
||||
$view_route_names = [];
|
||||
$view_route_names['example_view.page_1'] = 'view.example_view.page_1';
|
||||
$this->state->expects($this->exactly(2))
|
||||
->method('get')
|
||||
|
@ -304,13 +304,13 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->willReturn($storage);
|
||||
|
||||
$display_plugin = $this->getMockBuilder('Drupal\views\Plugin\views\display\PathPluginBase')
|
||||
->setMethods(array('getOption', 'getPath'))
|
||||
->setMethods(['getOption', 'getPath'])
|
||||
->disableOriginalConstructor()
|
||||
->getMockForAbstractClass();
|
||||
$display_plugin->expects($this->exactly(2))
|
||||
->method('getOption')
|
||||
->with('menu')
|
||||
->will($this->returnValue(array('type' => 'tab', 'weight' => 12, 'title' => 'Example title')));
|
||||
->will($this->returnValue(['type' => 'tab', 'weight' => 12, 'title' => 'Example title']));
|
||||
$display_plugin->expects($this->once())
|
||||
->method('getPath')
|
||||
->will($this->returnValue('path/example'));
|
||||
|
@ -320,7 +320,7 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
$this->localTaskDerivative->setApplicableMenuViews($result);
|
||||
|
||||
// Mock the view route names state.
|
||||
$view_route_names = array();
|
||||
$view_route_names = [];
|
||||
$view_route_names['example_view.page_1'] = 'view.example_view.page_1';
|
||||
$this->state->expects($this->exactly(2))
|
||||
->method('get')
|
||||
|
@ -336,11 +336,11 @@ class ViewsLocalTaskTest extends UnitTestCase {
|
|||
->will($this->returnValue($route_collection));
|
||||
|
||||
// Setup the existing local task of the test_route.
|
||||
$definitions['test_route_tab'] = $other_tab = array(
|
||||
$definitions['test_route_tab'] = $other_tab = [
|
||||
'route_name' => 'test_route',
|
||||
'title' => 'Test route',
|
||||
'base_route' => 'test_route',
|
||||
);
|
||||
];
|
||||
|
||||
$definitions += $this->localTaskDerivative->getDerivativeDefinitions($this->baseDefinition);
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ class EntityTest extends UnitTestCase {
|
|||
->getMock();
|
||||
$this->executable->style_plugin = $this->stylePlugin;
|
||||
|
||||
$this->entityHandler = new Entity(array(), 'entity', array('entity_type' => 'entity_test'), $this->entityManager);
|
||||
$this->entityHandler = new Entity([], 'entity', ['entity_type' => 'entity_test'], $this->entityManager);
|
||||
|
||||
$this->display->expects($this->any())
|
||||
->method('getPlugin')
|
||||
|
|
|
@ -31,7 +31,7 @@ class MessagesTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->messagesHandler = new Messages(array(), 'result', array());
|
||||
$this->messagesHandler = new Messages([], 'result', []);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,15 +43,15 @@ class MessagesTest extends UnitTestCase {
|
|||
public function testRender() {
|
||||
// The handler is configured to show with empty views by default, so should
|
||||
// appear.
|
||||
$this->assertSame(array('#type' => 'status_messages'), $this->messagesHandler->render());
|
||||
$this->assertSame(['#type' => 'status_messages'], $this->messagesHandler->render());
|
||||
|
||||
// Turn empty off, and make sure it isn't rendered.
|
||||
$this->messagesHandler->options['empty'] = FALSE;
|
||||
// $empty parameter passed to render will still be FALSE, so should still
|
||||
// appear.
|
||||
$this->assertSame(array('#type' => 'status_messages'), $this->messagesHandler->render());
|
||||
$this->assertSame(['#type' => 'status_messages'], $this->messagesHandler->render());
|
||||
// Should now be empty as both the empty option and parameter are empty.
|
||||
$this->assertSame(array(), $this->messagesHandler->render(TRUE));
|
||||
$this->assertSame([], $this->messagesHandler->render(TRUE));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ class ResultTest extends UnitTestCase {
|
|||
public function testResultArea($content, $expected, $items_per_page = 0) {
|
||||
$this->setupViewPager($items_per_page);
|
||||
$this->resultHandler->options['content'] = $content;
|
||||
$this->assertEquals(array('#markup' => $expected), $this->resultHandler->render());
|
||||
$this->assertEquals(['#markup' => $expected], $this->resultHandler->render());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -88,25 +88,25 @@ class ResultTest extends UnitTestCase {
|
|||
* @return array
|
||||
*/
|
||||
public function providerTestResultArea() {
|
||||
return array(
|
||||
array('@label', 'ResultTest'),
|
||||
array('@start', '1'),
|
||||
array('@start', '1', 1),
|
||||
array('@end', '100'),
|
||||
array('@end', '1', 1),
|
||||
array('@total', '100'),
|
||||
array('@total', '100', 1),
|
||||
array('@per_page', '0'),
|
||||
array('@per_page', '1', 1),
|
||||
array('@current_page', '1'),
|
||||
array('@current_page', '1', 1),
|
||||
array('@current_record_count', '100'),
|
||||
array('@current_record_count', '1', 1),
|
||||
array('@page_count', '1'),
|
||||
array('@page_count', '100', 1),
|
||||
array('@start | @end | @total', '1 | 100 | 100'),
|
||||
array('@start | @end | @total', '1 | 1 | 100', 1),
|
||||
);
|
||||
return [
|
||||
['@label', 'ResultTest'],
|
||||
['@start', '1'],
|
||||
['@start', '1', 1],
|
||||
['@end', '100'],
|
||||
['@end', '1', 1],
|
||||
['@total', '100'],
|
||||
['@total', '100', 1],
|
||||
['@per_page', '0'],
|
||||
['@per_page', '1', 1],
|
||||
['@current_page', '1'],
|
||||
['@current_page', '1', 1],
|
||||
['@current_record_count', '100'],
|
||||
['@current_record_count', '1', 1],
|
||||
['@page_count', '1'],
|
||||
['@page_count', '100', 1],
|
||||
['@start | @end | @total', '1 | 100 | 100'],
|
||||
['@start | @end | @total', '1 | 1 | 100', 1],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -127,7 +127,7 @@ class ResultTest extends UnitTestCase {
|
|||
$this->view->pager = $pager->reveal();
|
||||
$this->view->style_plugin = new \stdClass();
|
||||
$this->view->total_rows = 100;
|
||||
$this->view->result = array(1, 2, 3, 4, 5);
|
||||
$this->view->result = [1, 2, 3, 4, 5];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ class ViewTest extends UnitTestCase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->entityStorage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface');
|
||||
$this->viewHandler = new ViewAreaPlugin(array(), 'view', array(), $this->entityStorage);
|
||||
$this->viewHandler = new ViewAreaPlugin([], 'view', [], $this->entityStorage);
|
||||
$this->viewHandler->view = $this->getMockBuilder('Drupal\views\ViewExecutable')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
@ -60,10 +60,10 @@ class ViewTest extends UnitTestCase {
|
|||
|
||||
|
||||
$this->viewHandler->options['view_to_insert'] = 'other:default';
|
||||
$this->assertArrayEquals(array('config' => array('view.other')), $this->viewHandler->calculateDependencies());
|
||||
$this->assertArrayEquals(['config' => ['view.other']], $this->viewHandler->calculateDependencies());
|
||||
|
||||
$this->viewHandler->options['view_to_insert'] = 'this:default';
|
||||
$this->assertArrayEquals(array(), $this->viewHandler->calculateDependencies());
|
||||
$this->assertArrayEquals([], $this->viewHandler->calculateDependencies());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ class QueryParameterTest extends UnitTestCase {
|
|||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
|
||||
$raw = new QueryParameter(array(), 'query_parameter', array());
|
||||
$raw = new QueryParameter([], 'query_parameter', []);
|
||||
$raw->init($view, $display_plugin, $options);
|
||||
$this->assertEquals($expected, $raw->getArgument());
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue