Commit dedaf33c authored by alexpott's avatar alexpott

Issue #2385805 by Gábor Hojtsy: Views tests don't pass strict schema checking

parent 502c78a6
......@@ -100,6 +100,7 @@ display:
empty: ''
hide_alter_empty: true
link_to_entity: false
plugin_id: comment
filters:
subject:
id: subject
......
......@@ -73,7 +73,7 @@ display:
html: false
hide_empty: false
empty_zero: false
link_to_node: 1
link_to_node: true
relationship: none
group_type: group
admin_label: ''
......@@ -88,6 +88,7 @@ display:
element_default_classes: true
empty: ''
hide_alter_empty: true
plugin_id: node
filters:
status:
value: true
......@@ -97,6 +98,7 @@ display:
expose:
operator: ''
group: 1
plugin_id: boolean
title:
id: title
table: node_field_data
......@@ -179,6 +181,7 @@ display:
expose:
operator: ''
group: 1
plugin_id: boolean
body_value:
id: body_value
table: node__body
......@@ -243,6 +246,7 @@ display:
expose:
operator: ''
group: 1
plugin_id: boolean
body_value:
id: body_value
table: node__body
......@@ -307,6 +311,7 @@ display:
expose:
operator: ''
group: 1
plugin_id: boolean
title:
id: title
table: node_field_data
......
# Schema for the views access plugins.
views.access.none:
type: sequence
type: mapping
label: 'None'
sequence:
- type: string
......@@ -115,7 +115,7 @@ views.view.*:
display_options:
type: views.display.[%parent.display_plugin]
block.settings.views_block:*:
views_block:
type: block_settings
label: 'View block'
mapping:
......@@ -125,3 +125,9 @@ block.settings.views_block:*:
items_per_page:
type: string
label: 'Items per block'
block.settings.views_block:*:
type: views_block
block.settings.views_exposed_filter_block:*:
type: views_block
......@@ -166,6 +166,7 @@ public function testTitleArea() {
'admin_label' => '',
'empty' => '0',
'title' => 'Overridden title',
'plugin_id' => 'title',
),
));
......
......@@ -100,13 +100,14 @@ protected function createBlock($plugin_id, array $settings = array()) {
'max_age' => 0,
),
);
foreach (array('region', 'id', 'theme', 'plugin', 'weight') as $key) {
$values = [];
foreach (array('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]);
}
foreach ($settings['visibility'] as $id => $visibility) {
$settings['visibility'][$id]['id'] = $id;
foreach ($values['visibility'] as $id => $visibility) {
$values['visibility'][$id]['id'] = $id;
}
$values['settings'] = $settings;
$block = entity_create('block', $values);
......
......@@ -89,11 +89,12 @@ public function testViewElement() {
'type' => 'none',
'fail' => 'not found',
),
'break_phrase' => 0,
'not' => 0,
'break_phrase' => FALSE,
'not' => FALSE,
'id' => 'age',
'table' => 'views_test_data',
'field' => 'age',
'plugin_id' => 'numeric',
)
));
$view->save();
......
......@@ -233,14 +233,12 @@ protected function displayMethodTests() {
$this->assertEqual($display[$id]['display_title'], 'Page 3');
// Ensure the 'default' display always has position zero, regardless of when
// it was created relative to other displays.
$displays = $view->get('display');
$displays['default']['deleted'] = TRUE;
$view->set('display', $displays);
$view->set('id', $this->randomMachineName());
$view->save();
// it was set relative to other displays. Even if the 'default' display
// exists, adding it again will overwrite it, which is asserted with the new
// title.
$view->addDisplay('default', $random_title);
$displays = $view->get('display');
$this->assertEqual($displays['default']['display_title'], $random_title, 'Default display is defined with the new title');
$this->assertEqual($displays['default']['position'], 0, 'Default displays are always in position zero');
// Tests Drupal\views\Entity\View::generateDisplayId().
......
......@@ -23,6 +23,15 @@
*/
abstract class ViewTestBase extends WebTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......
......@@ -24,6 +24,15 @@
*/
abstract class ViewUnitTestBase extends KernelTestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @var bool
*/
protected $strictConfigSchema = TRUE;
/**
* Modules to enable.
*
......
......@@ -48,5 +48,6 @@ display:
table: views_test_data
field: created
order: DESC
plugin_id: date
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
......@@ -29,7 +29,7 @@ display:
field: id
table: views_test_data
id: id
plugin_id: id
plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default
......
......@@ -26,3 +26,62 @@ views.style.mapping_test:
toggle_title_field:
type: boolean
label: 'Toggle title field'
views_test_data.tests:
type: mapping
label: 'Views test data tests'
mapping:
handler_access_callback:
type: boolean
label: 'Access callback handler toggle'
handler_access_callback_argument:
type: boolean
label: 'Access callback argument handler toggle'
views.access.test_static:
type: mapping
label: 'Static test'
mapping:
access:
type: boolean
label: 'Allow access'
views.display.display_test:
type: views_display
label: 'Test display options'
mapping:
test_option:
label: 'Test option'
type: string
views.display.invalid:
type: views.display.page
label: 'Invalid display'
views.display.display_no_area_test:
type: views.display.display_test
label: 'Test display options without areas'
views.query.query_test:
type: views_query
label: 'Views query test options'
mapping:
test_setting:
type: string
label: 'Test setting'
views.row.test_row:
type: views_entity_row
label: 'Row test options'
mapping:
test_option:
type: string
label: 'Test option'
views.style.test_style:
type: views_style
label: 'Test style options'
mapping:
test_option:
type: string
label: 'Test option'
......@@ -57,8 +57,10 @@ public function testCustomOption() {
'table' => 'views_test_data',
'field' => 'age',
'relationship' => 'none',
'plugin_id' => 'boolean',
),
));
$view->save();
$this->executeView($view);
......
......@@ -16,6 +16,17 @@
*/
class DisplayCRUDTest extends UITestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @todo https://www.drupal.org/node/2387157
*
* @var bool
*/
protected $strictConfigSchema = FALSE;
/**
* Views used by this test.
*
......
......@@ -16,6 +16,17 @@
*/
class DisplayExtenderUITest extends UITestBase {
/**
* Set to TRUE to strict check all configuration saved.
*
* @see \Drupal\Core\Config\Testing\ConfigSchemaChecker
*
* @todo https://www.drupal.org/node/2387149
*
* @var bool
*/
protected $strictConfigSchema = FALSE;
/**
* Views used by this test.
*
......
......@@ -8,6 +8,7 @@
namespace Drupal\views_ui\Tests;
use Drupal\views\Views;
use Drupal\views\Entity\View;
use Drupal\views\Tests\ViewTestBase;
use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin;
......@@ -39,6 +40,11 @@ protected function viewsData() {
* Tests query plugins settings.
*/
public function testQueryUI() {
$view = View::load('test_view');
$display = &$view->getDisplay('default');
$display['display_options']['query'] = ['type' => 'query_test'];
$view->save();
// Save some query settings.
$query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
$random_value = $this->randomMachineName();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment