function ViewExecutableTest::testSetDisplayWithInvalidDisplay

Same name in other branches
  1. 9 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testSetDisplayWithInvalidDisplay()
  2. 10 core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testSetDisplayWithInvalidDisplay()
  3. 11.x core/modules/views/tests/src/Kernel/ViewExecutableTest.php \Drupal\Tests\views\Kernel\ViewExecutableTest::testSetDisplayWithInvalidDisplay()

File

core/modules/views/tests/src/Kernel/ViewExecutableTest.php, line 204

Class

ViewExecutableTest
Tests the ViewExecutable class.

Namespace

Drupal\Tests\views\Kernel

Code

public function testSetDisplayWithInvalidDisplay() {
    $view = Views::getView('test_executable_displays');
    $view->initDisplay();
    // Error is triggered while calling the wrong display.
    try {
        $view->setDisplay('invalid');
        $this->fail('Expected error, when setDisplay() called with invalid display ID');
    } catch (Warning $e) {
        $this->assertEquals('setDisplay() called with invalid display ID "invalid".', $e->getMessage());
    }
    $this->assertEqual($view->current_display, 'default', 'If setDisplay is called with an invalid display id the default display should be used.');
    $this->assertEqual(spl_object_hash($view->display_handler), spl_object_hash($view->displayHandlers
        ->get('default')));
}

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