X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Ffield%2Ftests%2Fsrc%2FUnit%2FFieldStorageConfigEntityUnitTest.php;h=970532a3e802d73637230932ae5bbe9e3443e57c;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hp=89b73963baa664b29dcad0ad40a2fc675ec2f949;hpb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;p=yaffs-website diff --git a/web/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php b/web/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php index 89b73963b..970532a3e 100644 --- a/web/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php +++ b/web/core/modules/field/tests/src/Unit/FieldStorageConfigEntityUnitTest.php @@ -8,6 +8,8 @@ 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; @@ -22,11 +24,11 @@ use Drupal\Tests\UnitTestCase; 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. @@ -53,14 +55,19 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase { * {@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); } @@ -85,7 +92,7 @@ class FieldStorageConfigEntityUnitTest extends UnitTestCase { // 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],