function FieldStorageConfigAccessControlHandlerTest::setUp
Same name in other branches
- 9 core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php \Drupal\Tests\field\Unit\FieldStorageConfigAccessControlHandlerTest::setUp()
- 8.9.x core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php \Drupal\Tests\field\Unit\FieldStorageConfigAccessControlHandlerTest::setUp()
- 11.x core/modules/field/tests/src/Unit/FieldStorageConfigAccessControlHandlerTest.php \Drupal\Tests\field\Unit\FieldStorageConfigAccessControlHandlerTest::setUp()
Overrides UnitTestCase::setUp
1 call to FieldStorageConfigAccessControlHandlerTest::setUp()
- FieldConfigAccessControlHandlerTest::setUp in core/
modules/ field/ tests/ src/ Unit/ FieldConfigAccessControlHandlerTest.php
1 method overrides FieldStorageConfigAccessControlHandlerTest::setUp()
- FieldConfigAccessControlHandlerTest::setUp in core/
modules/ field/ tests/ src/ Unit/ FieldConfigAccessControlHandlerTest.php
File
-
core/
modules/ field/ tests/ src/ Unit/ FieldStorageConfigAccessControlHandlerTest.php, line 66
Class
- FieldStorageConfigAccessControlHandlerTest
- Tests the field storage config access controller.
Namespace
Drupal\Tests\field\UnitCode
protected function setUp() : void {
parent::setUp();
$this->anon = $this->createMock(AccountInterface::class);
$this->anon
->expects($this->any())
->method('hasPermission')
->willReturn(FALSE);
$this->anon
->expects($this->any())
->method('id')
->willReturn(0);
$this->member = $this->createMock(AccountInterface::class);
$this->member
->expects($this->any())
->method('hasPermission')
->willReturnMap([
[
'administer node fields',
TRUE,
],
]);
$this->member
->expects($this->any())
->method('id')
->willReturn(2);
$storageType = $this->createMock(ConfigEntityTypeInterface::class);
$storageType->expects($this->any())
->method('getProvider')
->willReturn('field');
$storageType->expects($this->any())
->method('getConfigPrefix')
->willReturn('field.storage');
$entityType = $this->createMock(ConfigEntityTypeInterface::class);
$entityType->expects($this->any())
->method('getProvider')
->willReturn('node');
$entityType->expects($this->any())
->method('getConfigPrefix')
->willReturn('node');
$this->moduleHandler = $this->createMock(ModuleHandlerInterface::class);
$this->moduleHandler
->expects($this->any())
->method('invokeAll')
->willReturn([]);
$storage_access_control_handler = new FieldStorageConfigAccessControlHandler($storageType);
$storage_access_control_handler->setModuleHandler($this->moduleHandler);
$entity_type_manager = $this->createMock(EntityTypeManagerInterface::class);
$entity_type_manager->expects($this->any())
->method('getDefinition')
->willReturnMap([
[
'field_storage_config',
TRUE,
$storageType,
],
[
'node',
TRUE,
$entityType,
],
]);
$entity_type_manager->expects($this->any())
->method('getStorage')
->willReturnMap([
[
'field_storage_config',
$this->createMock(EntityStorageInterface::class),
],
]);
$entity_type_manager->expects($this->any())
->method('getAccessControlHandler')
->willReturnMap([
[
'field_storage_config',
$storage_access_control_handler,
],
]);
$container = new Container();
$container->set('entity_type.manager', $entity_type_manager);
$container->set('uuid', $this->createMock(UuidInterface::class));
$container->set('cache_contexts_manager', $this->prophesize(CacheContextsManager::class));
\Drupal::setContainer($container);
$this->entity = new FieldStorageConfig([
'field_name' => 'test_field',
'entity_type' => 'node',
'type' => 'boolean',
'id' => 'node.test_field',
'uuid' => '6f2f259a-f3c7-42ea-bdd5-111ad1f85ed1',
]);
$this->accessControlHandler = $storage_access_control_handler;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.