You are here

public function ViewAjaxControllerTest::testAjaxViewViewPathNoSlash in Drupal 9

Tests a valid view with a view_path with no slash.

File

core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php, line 211

Class

ViewAjaxControllerTest
@coversDefaultClass \Drupal\views\Controller\ViewAjaxController @group views

Namespace

Drupal\Tests\views\Unit\Controller

Code

public function testAjaxViewViewPathNoSlash() {
  $request = new Request();
  $request->request
    ->set('view_name', 'test_view');
  $request->request
    ->set('view_display_id', 'page_1');
  $request->request
    ->set('view_path', 'test-page');
  $request->request
    ->set('_wrapper_format', 'ajax');
  $request->request
    ->set('ajax_page_state', 'drupal.settings[]');
  $request->request
    ->set('type', 'article');
  list($view, $executable) = $this
    ->setupValidMocks();
  $this->redirectDestination
    ->expects($this
    ->atLeastOnce())
    ->method('set')
    ->with('test-page?type=article');
  $this->currentPath
    ->expects($this
    ->once())
    ->method('setPath')
    ->with('/test-page');
  $response = $this->viewAjaxController
    ->ajaxView($request);
  $this
    ->assertInstanceOf(ViewAjaxResponse::class, $response);
  $this
    ->assertSame($response
    ->getView(), $executable);
  $this
    ->assertViewResultCommand($response);
}