You are here

public function DisplayPageWebTest::assertPagePath in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/views/tests/src/Functional/Plugin/DisplayPageWebTest.php \Drupal\Tests\views\Functional\Plugin\DisplayPageWebTest::assertPagePath()
  2. 9 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.

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