diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 54f4216..cd19151 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -482,13 +482,13 @@ public function getFieldStorageDefinitions($entity_type_id) { } // Not prepared, try to load from cache. $cid = 'entity_field_storage_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->id; - if ($cache = $this->cache->get($cid)) { + if ($cache = $this->cacheBackend->get($cid)) { $field_storage_definitions = $cache->data; } else { // Rebuild the definitions and put it into the cache. $field_storage_definitions = $this->buildFieldStorageDefinitions($entity_type_id); - $this->cache->set($cid, $field_storage_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); + $this->cacheBackend->set($cid, $field_storage_definitions, Cache::PERMANENT, array('entity_types' => TRUE, 'entity_field_info' => TRUE)); } $this->fieldStorageDefinitions[$entity_type_id] += $field_storage_definitions; } @@ -588,7 +588,7 @@ public function getExtraFields($entity_type_id, $bundle) { // hook_entity_extra_field_info_alter() might contain t() calls, we cache // per language. $cache_id = 'entity_bundle_extra_fields:' . $entity_type_id . ':' . $bundle . ':' . $this->languageManager->getCurrentLanguage()->id; - $cached = $this->cache->get($cache_id); + $cached = $this->cacheBackend->get($cache_id); if ($cached) { $this->extraFields[$entity_type_id][$bundle] = $cached->data; return $this->extraFields[$entity_type_id][$bundle]; @@ -604,7 +604,7 @@ public function getExtraFields($entity_type_id, $bundle) { // Store in the 'static' and persistent caches. $this->extraFields[$entity_type_id][$bundle] = $info; - $this->cache->set($cache_id, $info, Cache::PERMANENT, array( + $this->cacheBackend->set($cache_id, $info, Cache::PERMANENT, array( 'entity_field_info' => TRUE, )); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 2ab5e83..3b2cc05 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -141,7 +141,7 @@ protected function setUpEntityManager($definitions = array()) { ->method('getDefinitions') ->will($this->returnValue($definitions)); - $this->entityManager = new TestEntityManager(new \ArrayObject(), $this->container, $this->moduleHandler, $this->cache, $this->languageManager, $this->translationManager); + $this->entityManager = new TestEntityManager(new \ArrayObject(), $this->moduleHandler, $this->cache, $this->languageManager, $this->translationManager); $this->entityManager->setContainer($this->container); $this->entityManager->setDiscovery($this->discovery); } @@ -481,15 +481,13 @@ public function testGetFieldStorageDefinitions() { ->method('getName') ->will($this->returnValue('field_storage')); - $this->moduleHandler->expects($this->at(0)) + $this->moduleHandler->expects($this->any()) ->method('getImplementations') - ->with('entity_base_field_info') - ->will($this->returnValue(array())); - - $this->moduleHandler->expects($this->at(2)) - ->method('getImplementations') - ->with('entity_field_storage_info') - ->will($this->returnValue(array('example_module'))); + ->will($this->returnValueMap(array( + array('entity_type_build', array()), + array('entity_base_field_info', array()), + array('entity_field_storage_info', array('example_module')), + ))); $this->moduleHandler->expects($this->any()) ->method('invoke') @@ -589,8 +587,10 @@ public function testGetFieldStorageDefinitionsWithCaching() { $this->moduleHandler->expects($this->any()) ->method('getImplementations') - ->with('entity_field_storage_info') - ->will($this->returnValue(array('example_module'))); + ->will($this->returnValueMap(array( + array('entity_field_storage_info', array('example_module')), + array('entity_type_build', array()) + ))); $this->moduleHandler->expects($this->once()) ->method('invoke') @@ -611,12 +611,18 @@ public function testGetFieldStorageDefinitionsWithCaching() { ->with('entity_field_storage_definitions:test_entity_type:en', FALSE) ->will($this->returnValue(FALSE)); $this->cache->expects($this->at(2)) - ->method('set'); + ->method('get') + ->with('entity_type::en', FALSE) + ->will($this->returnValue(FALSE)); $this->cache->expects($this->at(3)) + ->method('set'); + $this->cache->expects($this->at(4)) + ->method('set'); + $this->cache->expects($this->at(5)) ->method('get') ->with('entity_base_field_definitions:test_entity_type:en', FALSE) ->will($this->returnValue((object) array('data' => array('id' => $expected['id'])))); - $this->cache->expects($this->at(4)) + $this->cache->expects($this->at(6)) ->method('get') ->with('entity_field_storage_definitions:test_entity_type:en', FALSE) ->will($this->returnValue((object) array('data' => $expected)));