You are here

public function ViewAjaxControllerTest::testAccessDeniedView 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::testAccessDeniedView()

Tests a view without having access to it.

@expectedException \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException

File

core/modules/views/tests/src/Unit/Controller/ViewAjaxControllerTest.php, line 152
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 testAccessDeniedView() {
  $request = new Request();
  $request->request
    ->set('view_name', 'test_view');
  $request->request
    ->set('view_display_id', 'page_1');
  $view = $this
    ->getMockBuilder('Drupal\\views\\Entity\\View')
    ->disableOriginalConstructor()
    ->getMock();
  $this->viewStorage
    ->expects($this
    ->once())
    ->method('load')
    ->with('test_view')
    ->will($this
    ->returnValue($view));
  $executable = $this
    ->getMockBuilder('Drupal\\views\\ViewExecutable')
    ->disableOriginalConstructor()
    ->getMock();
  $executable
    ->expects($this
    ->once())
    ->method('access')
    ->will($this
    ->returnValue(FALSE));
  $this->executableFactory
    ->expects($this
    ->once())
    ->method('get')
    ->with($view)
    ->will($this
    ->returnValue($executable));
  $this->viewAjaxController
    ->ajaxView($request);
}