You are here

protected function EntityUnitTest::setUp in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php \Drupal\Tests\Core\Entity\EntityUnitTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php, line 91
Contains \Drupal\Tests\Core\Entity\EntityUnitTest.

Class

EntityUnitTest
@coversDefaultClass \Drupal\Core\Entity\Entity @group Entity @group Access

Namespace

Drupal\Tests\Core\Entity

Code

protected function setUp() {
  $this->values = array(
    'id' => 1,
    'langcode' => 'en',
    'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
  );
  $this->entityTypeId = $this
    ->randomMachineName();
  $this->entityType = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
  $this->entityType
    ->expects($this
    ->any())
    ->method('getListCacheTags')
    ->willReturn(array(
    $this->entityTypeId . '_list',
  ));
  $this->entityManager = $this
    ->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
  $this->entityManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->with($this->entityTypeId)
    ->will($this
    ->returnValue($this->entityType));
  $this->uuid = $this
    ->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
  $this->languageManager = $this
    ->getMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getLanguage')
    ->with('en')
    ->will($this
    ->returnValue(new Language(array(
    'id' => 'en',
  ))));
  $this->cacheTagsInvalidator = $this
    ->getMock('Drupal\\Core\\Cache\\CacheTagsInvalidator');
  $container = new ContainerBuilder();
  $container
    ->set('entity.manager', $this->entityManager);
  $container
    ->set('uuid', $this->uuid);
  $container
    ->set('language_manager', $this->languageManager);
  $container
    ->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
  \Drupal::setContainer($container);
  $this->entity = $this
    ->getMockForAbstractClass('\\Drupal\\Core\\Entity\\Entity', array(
    $this->values,
    $this->entityTypeId,
  ));
}