Commit 0fd920cb authored by alexpott's avatar alexpott

Issue #2428643 by Upchuk: Always display the more link causes exception:...

Issue #2428643 by Upchuk: Always display the more link causes exception: cannot create a URL to a display without routes
parent 0fe1e7da
......@@ -2362,6 +2362,14 @@ public function validate() {
}
}
// Validate the more link.
if ($this->isMoreEnabled() && $this->getOption('link_display') !== 'custom_url') {
$routed_display = $this->getRoutedDisplay();
if (!$routed_display || !$routed_display->isEnabled()) {
$errors[] = $this->t('Display "@display" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', array('@display' => $this->display['display_title']));
}
}
if ($this->hasPath() && !$this->getOption('path')) {
$errors[] = $this->t('Display "@display" uses a path but the path is undefined.', array('@display' => $this->display['display_title']));
}
......
......@@ -228,6 +228,32 @@ public function testReadMore() {
$this->assertTrue($view->getDisplay()->getOption('use_more_always'), 'Always display the more link by default.');
}
/**
* Tests the readmore validation.
*/
public function testReadMoreNoDisplay() {
$view = Views::getView('test_display_more');
// Confirm that the view validates when there is a page display.
$errors = $view->validate();
$this->assertTrue(empty($errors), 'More link validation has no errors.');
// Confirm that the view does not validate when the page display is disabled.
$view->setDisplay('page_1');
$view->display_handler->setOption('enabled', FALSE);
$view->setDisplay('default');
$errors = $view->validate();
$this->assertTrue(!empty($errors), 'More link validation has some errors.');
$this->assertEqual($errors['default'][0], 'Display "Master" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', 'More link validation has the right error.');
// Confirm that the view does not validate when the page display does not exist.
$view = Views::getView('test_view');
$view->setDisplay('default');
$view->display_handler->setOption('use_more', 1);
$errors = $view->validate();
$this->assertTrue(!empty($errors), 'More link validation has some errors.');
$this->assertEqual($errors['default'][0], 'Display "Master" uses a "more" link but there are no displays it can link to. You need to specify a custom URL.', 'More link validation has the right error.');
}
/**
* Tests invalid display plugins.
*/
......
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