function DisplayTest::testReadMoreNoDisplay

Same name in other branches
  1. 9 core/modules/views/tests/src/Functional/Plugin/DisplayTest.php \Drupal\Tests\views\Functional\Plugin\DisplayTest::testReadMoreNoDisplay()
  2. 10 core/modules/views/tests/src/Functional/Plugin/DisplayTest.php \Drupal\Tests\views\Functional\Plugin\DisplayTest::testReadMoreNoDisplay()
  3. 11.x core/modules/views/tests/src/Functional/Plugin/DisplayTest.php \Drupal\Tests\views\Functional\Plugin\DisplayTest::testReadMoreNoDisplay()

Tests the readmore validation.

File

core/modules/views/tests/src/Functional/Plugin/DisplayTest.php, line 178

Class

DisplayTest
Tests the basic display plugin.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

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.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.