Пример #1
0
 /**
  * Tests handle with a non existing view.
  *
  * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function testHandleWithNotExistingView()
 {
     // Pass in a non existent view.
     $random_view_id = $this->randomName();
     $request = new Request();
     $request->attributes->set('view_id', $random_view_id);
     $request->attributes->set('display_id', 'default');
     $this->pageController->handle($request);
 }
Пример #2
0
 /**
  * Tests handle with a non existing view.
  *
  * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
  */
 public function testHandleWithNotExistingView()
 {
     // Pass in a non existent view.
     $random_view_id = $this->randomMachineName();
     $request = new Request();
     $request->attributes->set('view_id', $random_view_id);
     $request->attributes->set('display_id', 'default');
     $route_match = RouteMatch::createFromRequest($request);
     $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $request, $route_match);
 }
Пример #3
0
 /**
  * Tests the page controller with arguments of a overridden page view.
  *
  * This test care about upcasted values and ensures that the raw variables
  * are pulled in.
  */
 public function testHandleWithArgumentsOnOverriddenRouteWithUpcasting()
 {
     $request = new Request();
     $request->attributes->set('view_id', 'test_page_view');
     $request->attributes->set('display_id', 'page_1');
     // Add the argument to the request.
     $request->attributes->set('test_entity', $this->getMock('Drupal\\Core\\Entity\\EntityInterface'));
     $raw_variables = new ParameterBag(array('test_entity' => 'example_id'));
     $request->attributes->set('_raw_variables', $raw_variables);
     $options = ['_view_argument_map' => ['arg_0' => 'test_entity'], '_view_display_plugin_class' => '\\Drupal\\views\\Plugin\\views\\display\\Page'];
     $request->attributes->set(RouteObjectInterface::ROUTE_OBJECT, new Route('/test/{test_entity}', ['view_id' => 'test_page_view', 'display_id' => 'default'], [], $options));
     $route_match = RouteMatch::createFromRequest($request);
     $result = $this->pageController->handle($route_match->getParameter('view_id'), $route_match->getParameter('display_id'), $route_match);
     $build = ['#type' => 'view', '#name' => 'test_page_view', '#display_id' => 'page_1', '#embed' => FALSE, '#arguments' => ['example_id'], '#cache' => ['keys' => ['view', 'test_page_view', 'display', 'page_1', 'args', 'example_id']]] + $this->defaultRenderArray;
     $this->assertEquals($build, $result);
 }