function EntityUnitTest::setUp
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php \Drupal\Tests\Core\Entity\EntityUnitTest::setUp()
- 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityUnitTest.php \Drupal\Tests\Core\Entity\EntityUnitTest::setUp()
- 10 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
Class
- EntityUnitTest
- @coversDefaultClass \Drupal\Core\Entity\EntityBase @group Entity @group Access
Namespace
Drupal\Tests\Core\EntityCode
protected function setUp() : void {
parent::setUp();
$this->values = [
'id' => 1,
'langcode' => 'en',
'uuid' => '3bb9ee60-bea5-4622-b89b-a63319d10b3a',
];
$this->entityTypeId = $this->randomMachineName();
$this->entityType = $this->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType
->expects($this->any())
->method('getListCacheTags')
->willReturn([
$this->entityTypeId . '_list',
]);
$this->entityTypeManager = $this->createMock(EntityTypeManagerInterface::class);
$this->entityTypeManager
->expects($this->any())
->method('getDefinition')
->with($this->entityTypeId)
->willReturn($this->entityType);
$this->uuid = $this->createMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$this->languageManager = $this->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
$this->languageManager
->expects($this->any())
->method('getLanguage')
->with('en')
->willReturn(new Language([
'id' => 'en',
]));
$this->cacheTagsInvalidator = $this->prophesize('Drupal\\Core\\Cache\\CacheTagsInvalidator');
$container = new ContainerBuilder();
$container->set('entity_type.manager', $this->entityTypeManager);
$container->set('uuid', $this->uuid);
$container->set('language_manager', $this->languageManager);
$container->set('cache_tags.invalidator', $this->cacheTagsInvalidator
->reveal());
\Drupal::setContainer($container);
$this->entity = new StubEntityBase($this->values, $this->entityTypeId);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.