Skip to content
Snippets Groups Projects
Commit dedaf33c authored by Alex Pott's avatar Alex Pott
Browse files

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

parent 502c78a6
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 136 additions and 17 deletions
...@@ -100,6 +100,7 @@ display: ...@@ -100,6 +100,7 @@ display:
empty: '' empty: ''
hide_alter_empty: true hide_alter_empty: true
link_to_entity: false link_to_entity: false
plugin_id: comment
filters: filters:
subject: subject:
id: subject id: subject
......
...@@ -73,7 +73,7 @@ display: ...@@ -73,7 +73,7 @@ display:
html: false html: false
hide_empty: false hide_empty: false
empty_zero: false empty_zero: false
link_to_node: 1 link_to_node: true
relationship: none relationship: none
group_type: group group_type: group
admin_label: '' admin_label: ''
...@@ -88,6 +88,7 @@ display: ...@@ -88,6 +88,7 @@ display:
element_default_classes: true element_default_classes: true
empty: '' empty: ''
hide_alter_empty: true hide_alter_empty: true
plugin_id: node
filters: filters:
status: status:
value: true value: true
...@@ -97,6 +98,7 @@ display: ...@@ -97,6 +98,7 @@ display:
expose: expose:
operator: '' operator: ''
group: 1 group: 1
plugin_id: boolean
title: title:
id: title id: title
table: node_field_data table: node_field_data
...@@ -179,6 +181,7 @@ display: ...@@ -179,6 +181,7 @@ display:
expose: expose:
operator: '' operator: ''
group: 1 group: 1
plugin_id: boolean
body_value: body_value:
id: body_value id: body_value
table: node__body table: node__body
...@@ -243,6 +246,7 @@ display: ...@@ -243,6 +246,7 @@ display:
expose: expose:
operator: '' operator: ''
group: 1 group: 1
plugin_id: boolean
body_value: body_value:
id: body_value id: body_value
table: node__body table: node__body
...@@ -307,6 +311,7 @@ display: ...@@ -307,6 +311,7 @@ display:
expose: expose:
operator: '' operator: ''
group: 1 group: 1
plugin_id: boolean
title: title:
id: title id: title
table: node_field_data table: node_field_data
......
# Schema for the views access plugins. # Schema for the views access plugins.
views.access.none: views.access.none:
type: sequence type: mapping
label: 'None' label: 'None'
sequence:
- type: string
...@@ -115,7 +115,7 @@ views.view.*: ...@@ -115,7 +115,7 @@ views.view.*:
display_options: display_options:
type: views.display.[%parent.display_plugin] type: views.display.[%parent.display_plugin]
block.settings.views_block:*: views_block:
type: block_settings type: block_settings
label: 'View block' label: 'View block'
mapping: mapping:
...@@ -125,3 +125,9 @@ block.settings.views_block:*: ...@@ -125,3 +125,9 @@ block.settings.views_block:*:
items_per_page: items_per_page:
type: string type: string
label: 'Items per block' 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() { ...@@ -166,6 +166,7 @@ public function testTitleArea() {
'admin_label' => '', 'admin_label' => '',
'empty' => '0', 'empty' => '0',
'title' => 'Overridden title', 'title' => 'Overridden title',
'plugin_id' => 'title',
), ),
)); ));
......
...@@ -100,13 +100,14 @@ protected function createBlock($plugin_id, array $settings = array()) { ...@@ -100,13 +100,14 @@ protected function createBlock($plugin_id, array $settings = array()) {
'max_age' => 0, '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]; $values[$key] = $settings[$key];
// Remove extra values that do not belong in the settings array. // Remove extra values that do not belong in the settings array.
unset($settings[$key]); unset($settings[$key]);
} }
foreach ($settings['visibility'] as $id => $visibility) { foreach ($values['visibility'] as $id => $visibility) {
$settings['visibility'][$id]['id'] = $id; $values['visibility'][$id]['id'] = $id;
} }
$values['settings'] = $settings; $values['settings'] = $settings;
$block = entity_create('block', $values); $block = entity_create('block', $values);
......
...@@ -89,11 +89,12 @@ public function testViewElement() { ...@@ -89,11 +89,12 @@ public function testViewElement() {
'type' => 'none', 'type' => 'none',
'fail' => 'not found', 'fail' => 'not found',
), ),
'break_phrase' => 0, 'break_phrase' => FALSE,
'not' => 0, 'not' => FALSE,
'id' => 'age', 'id' => 'age',
'table' => 'views_test_data', 'table' => 'views_test_data',
'field' => 'age', 'field' => 'age',
'plugin_id' => 'numeric',
) )
)); ));
$view->save(); $view->save();
......
...@@ -233,14 +233,12 @@ protected function displayMethodTests() { ...@@ -233,14 +233,12 @@ protected function displayMethodTests() {
$this->assertEqual($display[$id]['display_title'], 'Page 3'); $this->assertEqual($display[$id]['display_title'], 'Page 3');
// Ensure the 'default' display always has position zero, regardless of when // Ensure the 'default' display always has position zero, regardless of when
// it was created relative to other displays. // it was set relative to other displays. Even if the 'default' display
$displays = $view->get('display'); // exists, adding it again will overwrite it, which is asserted with the new
$displays['default']['deleted'] = TRUE; // title.
$view->set('display', $displays);
$view->set('id', $this->randomMachineName());
$view->save();
$view->addDisplay('default', $random_title); $view->addDisplay('default', $random_title);
$displays = $view->get('display'); $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'); $this->assertEqual($displays['default']['position'], 0, 'Default displays are always in position zero');
// Tests Drupal\views\Entity\View::generateDisplayId(). // Tests Drupal\views\Entity\View::generateDisplayId().
......
...@@ -23,6 +23,15 @@ ...@@ -23,6 +23,15 @@
*/ */
abstract class ViewTestBase extends WebTestBase { 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. * Modules to enable.
* *
......
...@@ -24,6 +24,15 @@ ...@@ -24,6 +24,15 @@
*/ */
abstract class ViewUnitTestBase extends KernelTestBase { 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. * Modules to enable.
* *
......
...@@ -48,5 +48,6 @@ display: ...@@ -48,5 +48,6 @@ display:
table: views_test_data table: views_test_data
field: created field: created
order: DESC order: DESC
plugin_id: date
field_langcode: '***LANGUAGE_language_content***' field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null field_langcode_add_to_query: null
...@@ -29,7 +29,7 @@ display: ...@@ -29,7 +29,7 @@ display:
field: id field: id
table: views_test_data table: views_test_data
id: id id: id
plugin_id: id plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***' field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null field_langcode_add_to_query: null
display_plugin: default display_plugin: default
......
...@@ -26,3 +26,62 @@ views.style.mapping_test: ...@@ -26,3 +26,62 @@ views.style.mapping_test:
toggle_title_field: toggle_title_field:
type: boolean type: boolean
label: 'Toggle title field' 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() { ...@@ -57,8 +57,10 @@ public function testCustomOption() {
'table' => 'views_test_data', 'table' => 'views_test_data',
'field' => 'age', 'field' => 'age',
'relationship' => 'none', 'relationship' => 'none',
'plugin_id' => 'boolean',
), ),
)); ));
$view->save();
$this->executeView($view); $this->executeView($view);
......
...@@ -16,6 +16,17 @@ ...@@ -16,6 +16,17 @@
*/ */
class DisplayCRUDTest extends UITestBase { 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. * Views used by this test.
* *
......
...@@ -16,6 +16,17 @@ ...@@ -16,6 +16,17 @@
*/ */
class DisplayExtenderUITest extends UITestBase { 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. * Views used by this test.
* *
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
namespace Drupal\views_ui\Tests; namespace Drupal\views_ui\Tests;
use Drupal\views\Views; use Drupal\views\Views;
use Drupal\views\Entity\View;
use Drupal\views\Tests\ViewTestBase; use Drupal\views\Tests\ViewTestBase;
use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin; use Drupal\views_test_data\Plugin\views\query\QueryTest as QueryTestPlugin;
...@@ -39,6 +40,11 @@ protected function viewsData() { ...@@ -39,6 +40,11 @@ protected function viewsData() {
* Tests query plugins settings. * Tests query plugins settings.
*/ */
public function testQueryUI() { 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. // Save some query settings.
$query_settings_path = "admin/structure/views/nojs/display/test_view/default/query"; $query_settings_path = "admin/structure/views/nojs/display/test_view/default/query";
$random_value = $this->randomMachineName(); $random_value = $this->randomMachineName();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment