/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
     $this->moduleHandler->getImplementations('entity_type_build')->willReturn([]);
     $this->moduleHandler->alter('entity_type', Argument::type('array'))->willReturn(NULL);
     $this->moduleHandler->alter('entity_base_field_info', Argument::type('array'), Argument::any())->willReturn(NULL);
     $this->moduleHandler->alter('entity_bundle_field_info', Argument::type('array'), Argument::any(), Argument::type('string'))->willReturn(NULL);
     $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
     $this->cacheTagsInvalidator = $this->prophesize(CacheTagsInvalidatorInterface::class);
     $language = new Language(['id' => 'en']);
     $this->languageManager = $this->prophesize(LanguageManagerInterface::class);
     $this->languageManager->getCurrentLanguage()->willReturn($language);
     $this->languageManager->getLanguages()->willReturn(['en' => (object) ['id' => 'en']]);
     $this->typedDataManager = $this->prophesize(TypedDataManager::class);
     $this->typedDataManager->getDefinition('field_item:boolean')->willReturn(['class' => BooleanItem::class]);
     $this->eventDispatcher = $this->prophesize(EventDispatcherInterface::class);
     $this->keyValueFactory = $this->prophesize(KeyValueFactoryInterface::class);
     $this->container = $this->prophesize(ContainerInterface::class);
     $this->container->get('cache_tags.invalidator')->willReturn($this->cacheTagsInvalidator->reveal());
     $this->container->get('typed_data_manager')->willReturn($this->typedDataManager->reveal());
     \Drupal::setContainer($this->container->reveal());
     $this->discovery = $this->prophesize(DiscoveryInterface::class);
     $translation_manager = $this->prophesize(TranslationInterface::class);
     $this->entityManager = new TestEntityManager(new \ArrayObject(), $this->moduleHandler->reveal(), $this->cacheBackend->reveal(), $this->languageManager->reveal(), $translation_manager->reveal(), $this->getClassResolverStub(), $this->typedDataManager->reveal(), $this->keyValueFactory->reveal(), $this->eventDispatcher->reveal());
     $this->entityManager->setContainer($this->container->reveal());
     $this->entityManager->setDiscovery($this->discovery->reveal());
 }
 /**
  * Sets up the entity manager to be tested.
  *
  * @param \Drupal\Core\Entity\EntityTypeInterface[]|\PHPUnit_Framework_MockObject_MockObject[] $definitions
  *   (optional) An array of entity type definitions.
  */
 protected function setUpEntityManager($definitions = array())
 {
     $class = $this->getMockClass('Drupal\\Core\\Entity\\EntityInterface');
     foreach ($definitions as $entity_type) {
         $entity_type->expects($this->any())->method('getClass')->will($this->returnValue($class));
     }
     $this->discovery->expects($this->any())->method('getDefinition')->will($this->returnCallback(function ($entity_type_id, $exception_on_invalid = FALSE) use($definitions) {
         if (isset($definitions[$entity_type_id])) {
             return $definitions[$entity_type_id];
         } elseif (!$exception_on_invalid) {
             return NULL;
         } else {
             throw new PluginNotFoundException($entity_type_id);
         }
     }));
     $this->discovery->expects($this->any())->method('getDefinitions')->will($this->returnValue($definitions));
     $this->entityManager = new TestEntityManager(new \ArrayObject(), $this->moduleHandler, $this->cacheBackend, $this->languageManager, $this->translationManager, $this->getClassResolverStub(), $this->typedDataManager, $this->installedDefinitions, $this->eventDispatcher);
     $this->entityManager->setContainer($this->container);
     $this->entityManager->setDiscovery($this->discovery);
 }