function ViewAjaxControllerTest::testAjaxViewViewPathNoSlash

Same name in other branches
  1. 9 core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::testAjaxViewViewPathNoSlash()
  2. 11.x core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::testAjaxViewViewPathNoSlash()

Tests a valid view with a view_path with no slash.

File

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

Class

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

Namespace

Drupal\Tests\views\Unit\Controller

Code

public function testAjaxViewViewPathNoSlash() : void {
    $request = new Request();
    $request->query
        ->set('view_name', 'test_view');
    $request->query
        ->set('view_display_id', 'page_1');
    $request->query
        ->set('view_path', 'test-page');
    $request->query
        ->set('_wrapper_format', 'ajax');
    $request->query
        ->set('ajax_page_state', 'drupal.settings[]');
    $request->query
        ->set('type', 'article');
    [
        $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);
}

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