Commit aa991be0 authored by webchick's avatar webchick
Browse files

Issue #2474471 by geertvd, pjbaert, StryKaizer, koence, dawehner, pjonckiere:...

Issue #2474471 by geertvd, pjbaert, StryKaizer, koence, dawehner, pjonckiere: Views page displays do not accept an integer as path
parent d52fc748
......@@ -50,54 +50,25 @@ display:
items_per_page: 10
offset: 0
style:
type: table
type: html_list
options:
grouping: { }
row_class: ''
default_row_class: true
override: true
sticky: false
caption: ''
summary: ''
description: ''
columns:
type: ul
wrapper_class: item-list
class: ''
row:
type: fields
options:
default_field_elements: true
inline:
title: title
name: title
name: name
edit_node: edit_node
delete_node: delete_node
info:
title:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
name:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: false
responsive: ''
edit_node:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: true
responsive: ''
delete_node:
sortable: false
default_sort_order: asc
align: ''
separator: ''
empty_column: true
responsive: ''
default: '-1'
empty_table: false
row:
type: fields
separator: ' '
hide_empty: false
fields:
title:
id: title
......@@ -144,7 +115,7 @@ display:
relationship: uid
group_type: group
admin_label: ''
label: ''
label: 'by '
exclude: false
alter:
alter_text: false
......@@ -173,13 +144,13 @@ display:
trim: false
preserve_tags: ''
html: false
element_type: div
element_class: ''
element_type: ''
element_class: byline
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_wrapper_class: author
element_default_classes: true
empty: ''
hide_empty: false
......@@ -188,57 +159,6 @@ display:
entity_type: user
entity_field: name
plugin_id: field
type: user_name
edit_node:
id: edit_node
table: node
field: edit_node
relationship: none
group_type: group
admin_label: ''
label: ''
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: false
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
text: Edit
entity_type: node
plugin_id: entity_link_edit
delete_node:
id: delete_node
......
......@@ -100,7 +100,7 @@ public function testRecentNodeBlock() {
$this->assertText($node3->label(), 'Node found in block.');
// Check to make sure nodes are in the right order.
$this->assertTrue($this->xpath('//div[@id="block-test-block"]//table/tbody/tr[position() = 1]/td/a[text() = "' . $node3->label() . '"]'), 'Nodes were ordered correctly in block.');
$this->assertTrue($this->xpath('//div[@id="block-test-block"]//div[@class="item-list"]/ul/li[1]/span[1]/span/a[text() = "' . $node3->label() . '"]'), 'Nodes were ordered correctly in block.');
$this->drupalLogout();
$this->drupalLogin($this->adminUser);
......
......@@ -24,14 +24,14 @@ class DisplayPageWebTest extends PluginTestBase {
*
* @var array
*/
public static $testViews = array('test_page_display', 'test_page_display_arguments', 'test_page_display_menu');
public static $testViews = array('test_page_display', 'test_page_display_arguments', 'test_page_display_menu', 'test_page_display_path');
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['menu_ui', 'block'];
public static $modules = ['menu_ui', 'block', 'views_ui'];
protected function setUp() {
parent::setUp();
......@@ -138,4 +138,36 @@ public function testTitleOutput() {
$this->assertFalse($xpath, 'The view title was not displayed in the view markup.');
}
/**
* Tests the views page path functionality.
*/
public function testPagePaths() {
$this->drupalLogin($this->rootUser);
$this->assertPagePath('0');
$this->assertPagePath('9999');
}
/**
* Tests that we can successfully change a view page display path.
*
* @param string $path
* Path that will be set as the view page display path.
*
* @return boolean
* Assertion result.
*/
public function assertPagePath($path) {
$view = Views::getView('test_page_display_path');
$view->initDisplay('page_1');
$view->displayHandlers->get('page_1')->overrideOption('path', $path);
$view->save();
$this->container->get('router.builder')->rebuild();
// Check if we successfully changed the path.
$this->drupalGet($path);
$success = $this->assertResponse(200);
// Check if we don't get any error on the view edit page.
$this->drupalGet('admin/structure/views/view/test_page_display_path');
return $success && $this->assertResponse(200);
}
}
langcode: en
status: true
dependencies: { }
id: test_page_display_path
label: ''
module: views
description: ''
tag: ''
base_table: views_test_data
base_field: nid
core: '8'
display:
default:
display_options:
title: 'Test page display path'
defaults:
fields: false
pager: false
sorts: false
fields:
age:
field: age
id: age
relationship: none
table: views_test_data
plugin_id: numeric
display_plugin: default
display_title: Master
id: default
position: 0
page_1:
display_options:
path: test_page_display_path
display_plugin: page
display_title: Page
id: page_1
......@@ -414,13 +414,20 @@ public function getDisplayDetails($view, $display) {
elseif ($view->status() && $view->getExecutable()->displayHandlers->get($display['id'])->hasPath()) {
$path = $view->getExecutable()->displayHandlers->get($display['id'])->getPath();
if ($path && (strpos($path, '%') === FALSE)) {
$uri = "base:$path";
if (!parse_url($path, PHP_URL_SCHEME)) {
// @todo Views should expect and store a leading /. See:
// https://www.drupal.org/node/2423913
$url = Url::fromUserInput('/' . ltrim($uri, '/'));
}
else {
$url = Url::fromUri($uri);
}
$build['top']['actions']['path'] = array(
'#type' => 'link',
'#title' => $this->t('View !display_title', array('!display_title' => $display_title)),
'#options' => array('alt' => array($this->t("Go to the real page for this display"))),
// @todo Use Url::fromPath() once
// https://www.drupal.org/node/2351379 is resolved.
'#url' => Url::fromUri("base:$path"),
'#url' => $url,
'#prefix' => '<li class="view">',
"#suffix" => '</li>',
);
......
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