TestViewListBuilder example

->disableOriginalConstructor()
      ->getMock();
    $route_provider = $this->createMock('Drupal\Core\Routing\RouteProviderInterface');
    $executable_factory = new ViewExecutableFactory($user$request_stack$views_data$route_provider);
    $container->set('views.executable', $executable_factory);
    $container->set('plugin.manager.views.display', $display_manager);
    \Drupal::setContainer($container);

    // Setup a view list builder with a mocked buildOperations method,     // because t() is called on there.     $entity_type = $this->createMock('Drupal\Core\Entity\EntityTypeInterface');
    $view_list_builder = new TestViewListBuilder($entity_type$storage$display_manager);
    $view_list_builder->setStringTranslation($this->getStringTranslationStub());

    // Create new view with test values.     $view = new View($values, 'view');

    // Get the row object created by ViewListBuilder for this test view.     $row = $view_list_builder->buildRow($view);

    // Expected output array for view's displays.     $expected_displays = [
      '0' => [
        
Home | Imprint | This part of the site doesn't use cookies.