namespace Drupal\Tests\field\Unit;
use Drupal\Core\DependencyInjection\ContainerBuilder;
+use Drupal\Core\Entity\EntityManager;
+use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Field\FieldException;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface;
class FieldStorageConfigEntityUnitTest extends UnitTestCase {
/**
- * The entity manager used for testing.
+ * The entity type manager used for testing.
*
- * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $entityManager;
+ protected $entityTypeManager;
/**
* The ID of the type of the entity under test.
* {@inheritdoc}
*/
protected function setUp() {
- $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
+ $entity_manager = new EntityManager();
+ $this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
$this->fieldTypeManager = $this->getMock(FieldTypePluginManagerInterface::class);
$container = new ContainerBuilder();
- $container->set('entity.manager', $this->entityManager);
+ $container->set('entity.manager', $entity_manager);
+ $container->set('entity_type.manager', $this->entityTypeManager);
$container->set('uuid', $this->uuid);
$container->set('plugin.manager.field.field_type', $this->fieldTypeManager);
+ // Inject the container into entity.manager so it can defer to
+ // entity_type.manager.
+ $entity_manager->setContainer($container);
\Drupal::setContainer($container);
}
// ConfigEntityBase::addDependency() to get the provider of the field config
// entity type and once in FieldStorageConfig::calculateDependencies() to
// get the provider of the entity type that field is attached to.
- $this->entityManager->expects($this->any())
+ $this->entityTypeManager->expects($this->any())
->method('getDefinition')
->willReturnMap([
['field_storage_config', TRUE, $fieldStorageConfigentityType],