Commit 4fc22ade authored by alexpott's avatar alexpott

Issue #2623568 by yanniboi, claudiu.cristea, himanshugautam, anil280988,...

Issue #2623568 by yanniboi, claudiu.cristea, himanshugautam, anil280988, sidharthap, Sagar Ramgade: Config schema of argument_default plugins is incorrect
parent 72bc1949
......@@ -66,13 +66,6 @@ views.argument.node_vid:
type: boolean
label: 'Exclude'
views.argument_default.node:
type: sequence
label: 'Content ID from URL'
sequence:
type: string
label: 'Nid'
views.field.node:
type: views_field
label: 'Node'
......
......@@ -49,10 +49,6 @@ views.argument_default.user:
type: boolean
label: 'Also look for a node and use the node author'
views.argument_default.current_user:
type: boolean
label: 'User ID from logged in user'
views_field_user:
type: views_field
mapping:
......
# Schema for the views default arguments.
views.argument_default.*:
type: mapping
label: 'Base default argument'
views.argument_default.fixed:
type: mapping
label: 'Fixed'
......@@ -18,3 +22,17 @@ views.argument_default.raw:
use_alias:
type: boolean
label: 'Use path alias'
views.argument_default.query_parameter:
type: mapping
label: 'Query parameter'
mapping:
query_param:
type: string
label: 'Parameter'
fallback:
type: string
label: 'Fallback value'
multiple:
type: string
label: 'Multiple values'
......@@ -2,10 +2,12 @@
namespace Drupal\views\Tests\Plugin;
use Drupal\Core\Url;
use Drupal\node\Entity\Node;
use Drupal\node\Entity\NodeType;
use Drupal\views\Views;
use Drupal\views_test_data\Plugin\views\argument_default\ArgumentDefaultTest as ArgumentDefaultTestPlugin;
use Symfony\Component\HttpFoundation\Request;
/**
......@@ -25,6 +27,7 @@ class ArgumentDefaultTest extends PluginTestBase {
'test_argument_default_fixed',
'test_argument_default_current_user',
'test_argument_default_node',
'test_argument_default_query_param',
);
/**
......@@ -163,4 +166,24 @@ public function testArgumentDefaultNode() {
$this->assertTrue(strpos($this->xpath($xpath)[0]->asXml(), $node2->getTitle()));
}
/**
* Tests the query parameter default argument.
*/
public function testArgumentDefaultQueryParameter() {
$view = Views::getView('test_argument_default_query_param');
$request = Request::create(Url::fromUri('internal:/whatever', ['absolute' => TRUE])->toString());
// Check the query parameter default argument fallback value.
$view->setRequest($request);
$view->initHandlers();
$this->assertEqual($view->argument['type']->getDefaultArgument(), 'all');
// Check the query parameter default argument with a value.
$request->query->add(['the_node_type' => 'page']);
$view->setRequest($request);
$view->initHandlers();
$this->assertEqual($view->argument['type']->getDefaultArgument(), 'page');
}
}
langcode: en
status: true
dependencies:
module:
- node
id: test_argument_default_query_param
label: ''
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: '8'
display:
default:
display_options:
arguments:
type:
id: type
table: node_field_data
field: type
default_action: default
default_argument_type: query_parameter
default_argument_options:
query_param: the_node_type
fallback: all
multiple: and
entity_type: node
entity_field: type
plugin_id: node_type
fields:
title:
alter:
alter_text: false
ellipsis: true
html: false
make_link: false
strip_tags: false
trim: false
word_boundary: true
empty_zero: false
field: title
hide_empty: false
id: title
table: node_field_data
plugin_id: field
entity_type: node
entity_field: title
pager:
options:
id: 0
items_per_page: 10
offset: 0
type: full
style:
type: default
row:
type: fields
display_plugin: default
display_title: Master
id: default
position: 0
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