protected function ConfigEntityStorageTest::setUp in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityStorageTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest::setUp()
@covers ::__construct
Overrides UnitTestCase::setUp
File
- core/
tests/ Drupal/ Tests/ Core/ Config/ Entity/ ConfigEntityStorageTest.php, line 119 - Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityStorageTest.
Class
- ConfigEntityStorageTest
- @coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityStorage @group Config
Namespace
Drupal\Tests\Core\Config\EntityCode
protected function setUp() {
parent::setUp();
$this->entityType = $this
->getMock('Drupal\\Core\\Config\\Entity\\ConfigEntityTypeInterface');
$this->entityTypeId = 'test_entity_type';
$this->entityType
->expects($this
->any())
->method('getKey')
->will($this
->returnValueMap(array(
array(
'id',
'id',
),
array(
'uuid',
'uuid',
),
array(
'langcode',
'langcode',
),
)));
$this->entityType
->expects($this
->any())
->method('id')
->will($this
->returnValue($this->entityTypeId));
$this->entityType
->expects($this
->any())
->method('getConfigPrefix')
->will($this
->returnValue('the_config_prefix'));
$this->entityType
->expects($this
->any())
->method('getClass')
->will($this
->returnValue(get_class($this
->getMockEntity())));
$this->entityType
->expects($this
->any())
->method('getListCacheTags')
->willReturn(array(
'test_entity_type_list',
));
$this->moduleHandler = $this
->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
$this->uuidService = $this
->getMock('Drupal\\Component\\Uuid\\UuidInterface');
$this->languageManager = $this
->getMock('Drupal\\Core\\Language\\LanguageManagerInterface');
$this->languageManager
->expects($this
->any())
->method('getCurrentLanguage')
->willReturn(new Language(array(
'id' => 'hu',
)));
$this->configFactory = $this
->getMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$this->entityQuery = $this
->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
$this->entityStorage = $this
->getMockBuilder('Drupal\\Core\\Config\\Entity\\ConfigEntityStorage')
->setConstructorArgs(array(
$this->entityType,
$this->configFactory,
$this->uuidService,
$this->languageManager,
))
->setMethods(array(
'getQuery',
))
->getMock();
$this->entityStorage
->expects($this
->any())
->method('getQuery')
->will($this
->returnValue($this->entityQuery));
$this->entityStorage
->setModuleHandler($this->moduleHandler);
$this->entityManager = $this
->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager
->expects($this
->any())
->method('getDefinition')
->with('test_entity_type')
->will($this
->returnValue($this->entityType));
$this->cacheTagsInvalidator = $this
->getMock('Drupal\\Core\\Cache\\CacheTagsInvalidatorInterface');
$this->typedConfigManager = $this
->getMock('Drupal\\Core\\Config\\TypedConfigManagerInterface');
$this->typedConfigManager
->expects($this
->any())
->method('getDefinition')
->will($this
->returnValue(array(
'mapping' => array(
'id' => '',
'uuid' => '',
'dependencies' => '',
),
)));
$this->configManager = $this
->getMock('Drupal\\Core\\Config\\ConfigManagerInterface');
$this->cacheContextsManager = $this
->getMockBuilder('Drupal\\Core\\Cache\\Context\\CacheContextsManager')
->disableOriginalConstructor()
->getMock();
$container = new ContainerBuilder();
$container
->set('entity.manager', $this->entityManager);
$container
->set('config.typed', $this->typedConfigManager);
$container
->set('cache_tags.invalidator', $this->cacheTagsInvalidator);
$container
->set('config.manager', $this->configManager);
$container
->set('language_manager', $this->languageManager);
$container
->set('cache_contexts_manager', $this->cacheContextsManager);
\Drupal::setContainer($container);
}