You are here

class EntityManagerTest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php \Drupal\Tests\Core\Entity\EntityManagerTest

@coversDefaultClass \Drupal\Core\Entity\EntityManager @group Entity

Hierarchy

Expanded class hierarchy of EntityManagerTest

File

core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php, line 23
Contains \Drupal\Tests\Core\Entity\EntityManagerTest.

Namespace

Drupal\Tests\Core\Entity
View source
class EntityManagerTest extends UnitTestCase {

  /**
   * The entity manager.
   *
   * @var \Drupal\Core\Entity\EntityManager
   */
  protected $entityManager;

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $entityTypeManager;

  /**
   * The entity type repository.
   *
   * @var \Drupal\Core\Entity\EntityTypeRepositoryInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $entityTypeRepository;

  /**
   * The entity type bundle info.
   *
   * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $entityTypeBundleInfo;

  /**
   * The entity field manager.
   *
   * @var \Drupal\Core\Entity\EntityFieldManagerInterface|\Prophecy\Prophecy\ProphecyInterface
   */
  protected $entityFieldManager;

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    parent::setUp();
    $this->entityTypeManager = $this
      ->prophesize(EntityTypeManagerInterface::class);
    $this->entityTypeRepository = $this
      ->prophesize(EntityTypeRepositoryInterface::class);
    $this->entityTypeBundleInfo = $this
      ->prophesize(EntityTypeBundleInfoInterface::class);
    $this->entityFieldManager = $this
      ->prophesize(EntityFieldManagerInterface::class);
    $container = new ContainerBuilder();
    $container
      ->set('entity_type.manager', $this->entityTypeManager
      ->reveal());
    $container
      ->set('entity_type.repository', $this->entityTypeRepository
      ->reveal());
    $container
      ->set('entity_type.bundle.info', $this->entityTypeBundleInfo
      ->reveal());
    $container
      ->set('entity_field.manager', $this->entityFieldManager
      ->reveal());
    $this->entityManager = new EntityManager();
    $this->entityManager
      ->setContainer($container);
  }

  /**
   * Tests the clearCachedDefinitions() method.
   *
   * @covers ::clearCachedDefinitions
   */
  public function testClearCachedDefinitions() {
    $this->entityTypeManager
      ->clearCachedDefinitions()
      ->shouldBeCalled();
    $this->entityTypeRepository
      ->clearCachedDefinitions()
      ->shouldBeCalled();
    $this->entityTypeBundleInfo
      ->clearCachedBundles()
      ->shouldBeCalled();
    $this->entityFieldManager
      ->clearCachedFieldDefinitions()
      ->shouldBeCalled();
    $this->entityManager
      ->clearCachedDefinitions();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityManagerTest::$entityFieldManager protected property The entity field manager.
EntityManagerTest::$entityManager protected property The entity manager.
EntityManagerTest::$entityTypeBundleInfo protected property The entity type bundle info.
EntityManagerTest::$entityTypeManager protected property The entity type manager.
EntityManagerTest::$entityTypeRepository protected property The entity type repository.
EntityManagerTest::setUp protected function Overrides UnitTestCase::setUp
EntityManagerTest::testClearCachedDefinitions public function Tests the clearCachedDefinitions() method.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root.
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName protected function Mocks a block with a block plugin.
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed in array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.