function TopBarItemManagerTest::setUp
Overrides UnitTestCase::setUp
File
-
core/
modules/ navigation/ tests/ src/ Unit/ TopBarItemManagerTest.php, line 36
Class
- TopBarItemManagerTest
- @coversDefaultClass \Drupal\navigation\TopBarItemManager
Namespace
Drupal\Tests\navigation\UnitCode
protected function setUp() : void {
parent::setUp();
$container = new ContainerBuilder();
$container->set('string_translation', $this->getStringTranslationStub());
\Drupal::setContainer($container);
$cache_backend = $this->prophesize(CacheBackendInterface::class);
$module_handler = $this->prophesize(ModuleHandlerInterface::class);
$this->manager = new TopBarItemManager(new \ArrayObject(), $cache_backend->reveal(), $module_handler->reveal());
$discovery = $this->prophesize(DiscoveryInterface::class);
// Specify the 'broken' block, as well as 3 other blocks with admin labels
// that are purposefully not in alphabetical order.
$discovery->getDefinitions()
->willReturn([
'tools' => [
'label' => $this->t('Tools'),
'region' => TopBarRegion::Tools,
],
'context' => [
'admin_label' => $this->t('Context'),
'region' => TopBarRegion::Context,
],
'actions' => [
'label' => $this->t('Actions'),
'region' => TopBarRegion::Actions,
],
'more_actions' => [
'label' => $this->t('More Actions'),
'region' => TopBarRegion::Actions,
],
]);
// Force the discovery object onto the block manager.
$property = new \ReflectionProperty(TopBarItemManager::class, 'discovery');
$property->setValue($this->manager, $discovery->reveal());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.