function DisplayPageWebTest::assertPagePath

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

Tests that we can successfully change a view page display path.

@internal

Parameters

string $path: Path that will be set as the view page display path.

1 call to DisplayPageWebTest::assertPagePath()
DisplayPageWebTest::testPagePaths in core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php
Tests the views page path functionality.

File

core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php, line 158

Class

DisplayPageWebTest
Tests the views page display plugin as webtest.

Namespace

Drupal\Tests\views\Functional\Plugin

Code

public function assertPagePath(string $path) : void {
    $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);
    $this->assertSession()
        ->statusCodeEquals(200);
    // Check if we don't get any error on the view edit page.
    $this->drupalGet('admin/structure/views/view/test_page_display_path');
    $this->assertSession()
        ->statusCodeEquals(200);
}

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