You are here

public function ViewAjaxControllerTest::testAjaxView in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest::testAjaxView()

Tests a valid view without arguments pagers etc.

File

core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php, line 184
Contains \Drupal\Tests\views\Unit\Controller\ViewAjaxControllerTest.

Class

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

Namespace

Drupal\Tests\views\Unit\Controller

Code

public function testAjaxView() {
  $request = new Request();
  $request->request
    ->set('view_name', 'test_view');
  $request->request
    ->set('view_display_id', 'page_1');
  list($view, $executable) = $this
    ->setupValidMocks();
  $display_handler = $this
    ->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayPluginBase')
    ->disableOriginalConstructor()
    ->getMock();

  // Ensure that the pager element is not set.
  $display_handler
    ->expects($this
    ->never())
    ->method('setOption');
  $display_collection = $this
    ->getMockBuilder('Drupal\\views\\DisplayPluginCollection')
    ->disableOriginalConstructor()
    ->getMock();
  $display_collection
    ->expects($this
    ->any())
    ->method('get')
    ->with('page_1')
    ->will($this
    ->returnValue($display_handler));
  $executable->displayHandlers = $display_collection;
  $response = $this->viewAjaxController
    ->ajaxView($request);
  $this
    ->assertTrue($response instanceof ViewAjaxResponse);
  $this
    ->assertSame($response
    ->getView(), $executable);
  $this
    ->assertViewResultCommand($response);
}