You are here

protected function SectionStorageManagerTest::setUp in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php \Drupal\Tests\layout_builder\Unit\SectionStorageManagerTest::setUp()

Overrides UnitTestCase::setUp

File

core/modules/layout_builder/tests/src/Unit/SectionStorageManagerTest.php, line 66

Class

SectionStorageManagerTest
@coversDefaultClass \Drupal\layout_builder\SectionStorage\SectionStorageManager

Namespace

Drupal\Tests\layout_builder\Unit

Code

protected function setUp() : void {
  parent::setUp();
  $cache = $this
    ->prophesize(CacheBackendInterface::class);
  $module_handler = $this
    ->prophesize(ModuleHandlerInterface::class);
  $this->contextHandler = $this
    ->prophesize(ContextHandlerInterface::class);
  $this->manager = new SectionStorageManager(new \ArrayObject(), $cache
    ->reveal(), $module_handler
    ->reveal(), $this->contextHandler
    ->reveal());
  $this->discovery = $this
    ->prophesize(DiscoveryInterface::class);
  $reflection_property = new \ReflectionProperty($this->manager, 'discovery');
  $reflection_property
    ->setAccessible(TRUE);
  $reflection_property
    ->setValue($this->manager, $this->discovery
    ->reveal());
  $this->plugin = $this
    ->prophesize(SectionStorageInterface::class);
  $this->factory = $this
    ->prophesize(FactoryInterface::class);
  $this->factory
    ->createInstance('the_plugin_id', [])
    ->willReturn($this->plugin
    ->reveal());
  $reflection_property = new \ReflectionProperty($this->manager, 'factory');
  $reflection_property
    ->setAccessible(TRUE);
  $reflection_property
    ->setValue($this->manager, $this->factory
    ->reveal());
}