You are here

protected function ViewExecutableTest::setUp in Drupal 8

Same name and namespace in other branches
  1. 9 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()

Overrides UnitTestCase::setUp

File

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

Class

ViewExecutableTest
@coversDefaultClass \Drupal\views\ViewExecutable @group views

Namespace

Drupal\Tests\views\Unit

Code

protected function setUp() {
  parent::setUp();
  $this->view = $this
    ->createMock('Drupal\\views\\ViewEntityInterface');
  $this->user = $this
    ->createMock('Drupal\\Core\\Session\\AccountInterface');
  $this->viewsData = $this
    ->getMockBuilder('Drupal\\views\\ViewsData')
    ->disableOriginalConstructor()
    ->getMock();
  $this->displayHandler = $this
    ->getMockBuilder('Drupal\\views\\Plugin\\views\\display\\DisplayRouterInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $this->routeProvider = $this
    ->createMock('Drupal\\Core\\Routing\\RouteProviderInterface');
  $this->displayHandlers = $this
    ->getMockBuilder('Drupal\\views\\DisplayPluginCollection')
    ->disableOriginalConstructor()
    ->getMock();
  $this->executable = new ViewExecutable($this->view, $this->user, $this->viewsData, $this->routeProvider);
  $this->executable->display_handler = $this->displayHandler;
  $this->executable->displayHandlers = $this->displayHandlers;
  $this->viewExecutableFactory = $this
    ->getMockBuilder('Drupal\\views\\ViewExecutableFactory')
    ->disableOriginalConstructor()
    ->getMock();
  $module_handler = $this
    ->getMockBuilder(ModuleHandlerInterface::class)
    ->getMock();
  $this->noneCache = $this
    ->getMockBuilder(NoneCache::class)
    ->disableOriginalConstructor()
    ->getMock();
  $success_cache = $this
    ->prophesize(CachePluginBase::class);
  $success_cache
    ->cacheGet('results')
    ->willReturn(TRUE);
  $this->successCache = $success_cache
    ->reveal();
  $cache_manager = $this
    ->prophesize(PluginManagerInterface::class);
  $cache_manager
    ->createInstance('none')
    ->willReturn($this->noneCache);
  $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', $cache_manager
    ->reveal());
  \Drupal::setContainer($container);
}