function FieldConfigEntityUnitTest::testCalculateDependenciesIncorrectBundle
Same name in other branches
- 9 core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testCalculateDependenciesIncorrectBundle()
- 8.9.x core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testCalculateDependenciesIncorrectBundle()
- 10 core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php \Drupal\Tests\field\Unit\FieldConfigEntityUnitTest::testCalculateDependenciesIncorrectBundle()
Tests that invalid bundles are handled.
File
-
core/
modules/ field/ tests/ src/ Unit/ FieldConfigEntityUnitTest.php, line 154
Class
- FieldConfigEntityUnitTest
- @coversDefaultClass \Drupal\field\Entity\FieldConfig @group field
Namespace
Drupal\Tests\field\UnitCode
public function testCalculateDependenciesIncorrectBundle() : void {
$storage = $this->createMock('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
$storage->expects($this->any())
->method('load')
->with('test_bundle_not_exists')
->willReturn(NULL);
$this->entityTypeManager
->expects($this->any())
->method('getStorage')
->with('bundle_entity_type')
->willReturn($storage);
$target_entity_type = new EntityType([
'id' => 'test_entity_type',
'bundle_entity_type' => 'bundle_entity_type',
]);
$this->entityTypeManager
->expects($this->any())
->method('getDefinition')
->willReturnMap([
[
$this->entityTypeId,
TRUE,
$this->entityType,
],
[
'test_entity_type',
TRUE,
$target_entity_type,
],
]);
$this->fieldTypePluginManager
->expects($this->any())
->method('getDefinition')
->with('test_field')
->willReturn([
'provider' => 'test_module',
'config_dependencies' => [
'module' => [
'test_module2',
],
],
'class' => '\\Drupal\\Tests\\field\\Unit\\DependencyFieldItem',
]);
$field = new FieldConfig([
'field_name' => $this->fieldStorage
->getName(),
'entity_type' => 'test_entity_type',
'bundle' => 'test_bundle_not_exists',
'field_type' => 'test_field',
], $this->entityTypeId);
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Missing bundle entity, entity type bundle_entity_type, entity id test_bundle_not_exists.');
$field->calculateDependencies();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.