function ViewExecutableTest::setUp

Same name and namespace in other branches
  1. 11.x core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setUp()
  2. 10 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setUp()
  3. 9 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setUp()
  4. 8.9.x core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/views/tests/src/Unit/ViewExecutableTest.php, line 139

Class

ViewExecutableTest
Tests Drupal\views\ViewExecutable.

Namespace

Drupal\Tests\views\Unit

Code

protected function setUp() : void {
  parent::setUp();
  $this->view = $this->createStub(ViewEntityInterface::class);
  $this->user = $this->createStub(AccountInterface::class);
  $this->viewsData = $this->createStub(ViewsData::class);
  $this->displayHandler = $this->createStub(DisplayRouterInterface::class);
  $this->routeProvider = $this->createStub(RouteProviderInterface::class);
  $this->displayHandlers = $this->createStub(DisplayPluginCollection::class);
  $this->displayPluginManager = $this->createStub(ViewsPluginManager::class);
  $this->executable = new ViewExecutable($this->view, $this->user, $this->viewsData, $this->routeProvider, $this->displayPluginManager);
  $this->executable->display_handler = $this->displayHandler;
  $this->executable->displayHandlers = $this->displayHandlers;
  $this->viewExecutableFactory = $this->createStub(ViewExecutableFactory::class);
  $module_handler = $this->createStub(ModuleHandlerInterface::class);
  $success_cache = $this->prophesize(CachePluginBase::class);
  $success_cache->cacheGet('results')
    ->willReturn(TRUE);
  $this->successCache = $success_cache->reveal();
  $this->cacheManager = $this->createStub(PluginManagerInterface::class);
  $translation = $this->getStringTranslationStub();
  $container = new ContainerBuilder();
  $container->set('string_translation', $translation);
  $container->set('views.executable', $this->viewExecutableFactory);
  $container->set('module_handler', $module_handler);
  $container->set('plugin.manager.views.cache', $this->cacheManager);
  \Drupal::setContainer($container);
}

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