protected function ViewExecutableTest::setUp in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setUp()
- 9 core/modules/views/tests/src/Unit/ViewExecutableTest.php \Drupal\Tests\views\Unit\ViewExecutableTest::setUp()
File
- core/
modules/ views/ tests/ src/ Unit/ ViewExecutableTest.php, line 117
Class
- ViewExecutableTest
- @coversDefaultClass \Drupal\views\ViewExecutable @group views
Namespace
Drupal\Tests\views\UnitCode
protected function setUp() : void {
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);
}