php Drupal-Core-Cache-CacheBackendInterface类(方法)实例源码

下面列出了php Drupal-Core-Cache-CacheBackendInterface 类(方法)源码代码实例,从而了解它的用法。

作者:aWEBoLab    项目:tax   
/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->keyValueFactory = $this->prophesize(KeyValueFactoryInterface::class);
     $this->entityTypeManager = $this->prophesize(EntityTypeManagerInterface::class);
     $this->entityFieldManager = $this->prophesize(EntityFieldManagerInterface::class);
     $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
     $this->fieldDefinitionListener = new FieldDefinitionListener($this->entityTypeManager->reveal(), $this->entityFieldManager->reveal(), $this->keyValueFactory->reveal(), $this->cacheBackend->reveal());
 }

作者:aWEBoLab    项目:tax   
/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     parent::setUp();
     $this->moduleHandler = $this->prophesize(ModuleHandlerInterface::class);
     $this->moduleHandler->getImplementations('entity_type_build')->willReturn([]);
     $this->moduleHandler->alter('entity_type', Argument::type('array'))->willReturn(NULL);
     $this->cacheBackend = $this->prophesize(CacheBackendInterface::class);
     $this->translationManager = $this->prophesize(TranslationInterface::class);
     $this->entityTypeManager = new TestEntityTypeManager(new \ArrayObject(), $this->moduleHandler->reveal(), $this->cacheBackend->reveal(), $this->translationManager->reveal(), $this->getClassResolverStub());
     $this->discovery = $this->prophesize(DiscoveryInterface::class);
     $this->entityTypeManager->setDiscovery($this->discovery->reveal());
 }

作者:r-daneeloliva    项目:chal   
/**
  * Loads the base country definitions.
  *
  * @return array
  */
 protected function loadBaseDefinitions()
 {
     if (!empty($this->baseDefinitions)) {
         return $this->baseDefinitions;
     }
     $cache_key = 'address.countries.base';
     if ($cached = $this->cache->get($cache_key)) {
         $this->baseDefinitions = $cached->data;
     } else {
         $this->baseDefinitions = json_decode(file_get_contents($this->definitionPath . 'base.json'), TRUE);
         $this->cache->set($cache_key, $this->baseDefinitions, CacheBackendInterface::CACHE_PERMANENT, ['countries']);
     }
     return $this->baseDefinitions;
 }

作者:bonrit    项目:moodl   
/**
  * User object.
  *
  * @return \Drupal\moodle\Sql\User
  */
 public function user()
 {
     // Static cache of already retrieved user data.
     $data =& drupal_static(__METHOD__, array());
     $user_cid = "moodle-user:{$this->user->id()}";
     // If we do not have this user id in the static cache, check {cache_data}.
     if (!isset($data[$user_cid])) {
         $cache = $this->cacheBackend->get($user_cid);
         if ($cache && $cache->data && isset($cache->data[$user_cid])) {
             $data[$user_cid] = $cache->data[$user_cid];
         }
     }
     // If nothing in the cache then retrieve it from the database.
     if (!isset($data[$user_cid])) {
         $user = new User();
         $this->query();
         $this->addFields();
         $statement = $this->query->execute();
         $statement->setFetchMode(\PDO::FETCH_INTO, $user);
         $data[$user_cid] = $statement->fetch();
         // Store the results for a day.
         $this->cacheBackend->set($user_cid, $data, REQUEST_TIME + 86400);
     }
     return $data[$user_cid];
 }

作者:aWEBoLab    项目:tax   
/**
  * {@inheritdoc}
  *
  * Cached by role, invalidated whenever permissions change.
  */
 public function generate(AccountInterface $account)
 {
     // User 1 is the super user, and can always access all permissions. Use a
     // different, unique identifier for the hash.
     if ($account->id() == 1) {
         return $this->hash('is-super-user');
     }
     $sorted_roles = $account->getRoles();
     sort($sorted_roles);
     $role_list = implode(',', $sorted_roles);
     $cid = "user_permissions_hash:{$role_list}";
     if ($static_cache = $this->static->get($cid)) {
         return $static_cache->data;
     } else {
         $tags = Cache::buildTags('config:user.role', $sorted_roles, '.');
         if ($cache = $this->cache->get($cid)) {
             $permissions_hash = $cache->data;
         } else {
             $permissions_hash = $this->doGenerate($sorted_roles);
             $this->cache->set($cid, $permissions_hash, Cache::PERMANENT, $tags);
         }
         $this->static->set($cid, $permissions_hash, Cache::PERMANENT, $tags);
     }
     return $permissions_hash;
 }

作者:davidsoloma    项目:drupalconsole.co   
/**
  * Tests the destruct method.
  *
  * @covers ::destruct
  */
 public function testDestruct()
 {
     $this->libraryDiscoveryParser->expects($this->once())->method('buildByExtension')->with('test')->will($this->returnValue($this->libraryData));
     $lock_key = 'library_info:Drupal\\Core\\Cache\\CacheCollector';
     $this->lock->expects($this->once())->method('acquire')->with($lock_key)->will($this->returnValue(TRUE));
     $this->cache->expects($this->exactly(2))->method('get')->with('library_info')->will($this->returnValue(FALSE));
     $this->cache->expects($this->once())->method('set')->with('library_info', array('test' => $this->libraryData), Cache::PERMANENT, array('library_info'));
     $this->lock->expects($this->once())->method('release')->with($lock_key);
     // This should get data and persist the key.
     $this->libraryDiscoveryCollector->get('test');
     $this->libraryDiscoveryCollector->destruct();
 }

作者:anatalsce    项目:en-class   
/**
  * {@inheritdoc}
  *
  * Cached by role, invalidated whenever permissions change.
  */
 public function generate(AccountInterface $account)
 {
     $sorted_roles = $account->getRoles();
     sort($sorted_roles);
     $role_list = implode(',', $sorted_roles);
     if ($cache = $this->cache->get("user_permissions_hash:{$role_list}")) {
         $permissions_hash = $cache->data;
     } else {
         $permissions_hash = $this->doGenerate($sorted_roles);
         $this->cache->set("user_permissions_hash:{$role_list}", $permissions_hash, Cache::PERMANENT, array('user_role' => $sorted_roles));
     }
     return $permissions_hash;
 }

作者:nstiela    项目:drops-   
/**
  * {@inheritdoc}
  *
  * Cached by role, invalidated whenever permissions change.
  */
 public function generate(AccountInterface $account)
 {
     $sorted_roles = $account->getRoles();
     sort($sorted_roles);
     $role_list = implode(',', $sorted_roles);
     if ($cache = $this->cache->get("user_permissions_hash:{$role_list}")) {
         $permissions_hash = $cache->data;
     } else {
         $permissions_hash = $this->doGenerate($sorted_roles);
         $tags = Cache::buildTags('config:user.role', $sorted_roles, '.');
         $this->cache->set("user_permissions_hash:{$role_list}", $permissions_hash, Cache::PERMANENT, $tags);
     }
     return $permissions_hash;
 }

作者:ddrozdi    项目:dmap   
/**
  * {@inheritdoc}
  */
 public function onFieldDefinitionDelete(FieldDefinitionInterface $field_definition)
 {
     $entity_type_id = $field_definition->getTargetEntityTypeId();
     $bundle = $field_definition->getTargetBundle();
     $field_name = $field_definition->getName();
     // Notify the storage about the field deletion.
     $this->entityTypeManager->getStorage($entity_type_id)->onFieldDefinitionDelete($field_definition);
     // Unset the bundle from the bundle field map key value collection.
     $bundle_field_map = $this->keyValueFactory->get('entity.definitions.bundle_field_map')->get($entity_type_id);
     unset($bundle_field_map[$field_name]['bundles'][$bundle]);
     if (empty($bundle_field_map[$field_name]['bundles'])) {
         // If there are no bundles left, remove the field from the map.
         unset($bundle_field_map[$field_name]);
     }
     $this->keyValueFactory->get('entity.definitions.bundle_field_map')->set($entity_type_id, $bundle_field_map);
     // Delete the cache entry.
     $this->cacheBackend->delete('entity_field_map');
     // If the field map is initialized, update it as well, so that calls to it
     // do not have to rebuild it again.
     if ($field_map = $this->entityFieldManager->getFieldMap()) {
         unset($field_map[$entity_type_id][$field_name]['bundles'][$bundle]);
         if (empty($field_map[$entity_type_id][$field_name]['bundles'])) {
             unset($field_map[$entity_type_id][$field_name]);
         }
         $this->entityFieldManager->setFieldMap($field_map);
     }
 }

作者:davidsoloma    项目:drupalconsole.co   
/**
  * @covers ::disable
  * @depends testSetStatus
  */
 public function testDisable()
 {
     $this->cacheBackend->expects($this->once())->method('invalidateTags')->with(array($this->entityTypeId . ':' . $this->id));
     $this->entity->setStatus(TRUE);
     $this->assertSame($this->entity, $this->entity->disable());
     $this->assertFalse($this->entity->status());
 }

作者:Nikola-xii    项目:d8intrane   
/**
  * Tests the getInfo method.
  *
  * @covers ::getInfo
  * @covers ::buildInfo
  *
  * @dataProvider providerTestGetInfo
  */
 public function testGetInfo($type, $expected_info, $element_info, callable $alter_callback = NULL)
 {
     $this->moduleHandler->expects($this->once())->method('invokeAll')->with('element_info')->will($this->returnValue($element_info));
     $this->moduleHandler->expects($this->once())->method('alter')->with('element_info', $this->anything())->will($this->returnCallback($alter_callback ?: function ($info) {
         return $info;
     }));
     $this->themeManager->expects($this->once())->method('getActiveTheme')->willReturn(new ActiveTheme(['name' => 'test']));
     $this->themeManager->expects($this->once())->method('alter')->with('element_info', $this->anything())->will($this->returnCallback($alter_callback ?: function ($info) {
         return $info;
     }));
     $this->cache->expects($this->at(0))->method('get')->with('element_info_build:test')->will($this->returnValue(FALSE));
     $this->cache->expects($this->at(1))->method('get')->with('element_info')->will($this->returnValue(FALSE));
     $this->cache->expects($this->at(2))->method('set')->with('element_info');
     $this->cache->expects($this->at(3))->method('set')->with('element_info_build:test');
     $this->assertEquals($expected_info, $this->elementInfo->getInfo($type));
 }

作者:ddrozdi    项目:dmap   
/**
  * Test that the delete tags operation is propagated to all backends
  * in the chain.
  */
 public function testDeleteTagsPropagation()
 {
     // Create two cache entries with the same tag and tag value.
     $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:2'));
     $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:2'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two cache items were created in all backends.');
     // Invalidate test_tag of value 1. This should invalidate both entries.
     $this->chain->invalidateTags(array('test_tag:2'));
     $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two caches removed from all backends after clearing a cache tag.');
     // Create two cache entries with the same tag and an array tag value.
     $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:1'));
     $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:1'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two cache items were created in all backends.');
     // Invalidate test_tag of value 1. This should invalidate both entries.
     $this->chain->invalidateTags(array('test_tag:1'));
     $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Two caches removed from all backends after clearing a cache tag.');
     // Create three cache entries with a mix of tags and tag values.
     $this->chain->set('test_cid_clear1', 'foo', Cache::PERMANENT, array('test_tag:1'));
     $this->chain->set('test_cid_clear2', 'foo', Cache::PERMANENT, array('test_tag:2'));
     $this->chain->set('test_cid_clear3', 'foo', Cache::PERMANENT, array('test_tag_foo:3'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->firstBackend->get('test_cid_clear3') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear3') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear3'), 'Three cached items were created in all backends.');
     $this->chain->invalidateTags(array('test_tag_foo:3'));
     $this->assertNotSame(FALSE, $this->firstBackend->get('test_cid_clear1') && $this->firstBackend->get('test_cid_clear2') && $this->secondBackend->get('test_cid_clear1') && $this->secondBackend->get('test_cid_clear2') && $this->thirdBackend->get('test_cid_clear1') && $this->thirdBackend->get('test_cid_clear2'), 'Cached items not matching the tag were not cleared from any of the backends.');
     $this->assertSame(FALSE, $this->firstBackend->get('test_cid_clear3') && $this->secondBackend->get('test_cid_clear3') && $this->thirdBackend->get('test_cid_clear3'), 'Cached item matching the tag was removed from all backends.');
 }

作者:alnutil    项目:drunatr   
/**
  * Responds after a request has finished, but before it is sent to the client.
  *
  * @param \Guzzle\Common\Event $event
  *   The Guzzle event object.
  */
 public function onRequestSent(Event $event)
 {
     $request = $event['request'];
     $response = $event['response'];
     // Handle permanent redirects by setting the redirected URL so that the
     // client can grab it quickly.
     $redirect = FALSE;
     $url = $old_url = $request->getUrl();
     if ($previous_response = $response->getPreviousResponse()) {
         if ($previous_response->getStatusCode() == 301 && ($location = $previous_response->getLocation())) {
             $response->getParams()->set('feeds.redirect', $location);
             $redirect = TRUE;
             $url = $request->getUrl();
         }
     }
     $cache_hit = $response->getStatusCode() == 304;
     if ($redirect) {
         // Delete the old cache entry.
         $this->cacheBackend->delete($this->getCacheKey($old_url));
         // Not sure if the repeated requests are smart enough to find the
         // redirect, so cache the old URL with the new response.
         static::$downloadCache[$old_url] = $response;
     }
     if ($redirect || !$cache_hit) {
         $cache = new \stdClass();
         $cache->headers = array_change_key_case($response->getHeaders()->toArray());
         // @todo We should only cache for certain status codes.
         $cache->code = $response->getStatusCode();
         $this->cacheBackend->set($this->getCacheKey($url), $cache);
     }
     // Set in-page download cache.
     static::$downloadCache[$url] = $response;
 }

作者:anatalsce    项目:en-class   
/**
  * Sets a cache of plugin definitions for the decorated discovery class.
  *
  * @param array $definitions
  *   List of definitions to store in cache.
  */
 protected function setCachedDefinitions($definitions)
 {
     if ($this->cacheBackend) {
         $this->cacheBackend->set($this->cacheKey, $definitions, Cache::PERMANENT, $this->cacheTags);
     }
     $this->definitions = $definitions;
 }

作者:ravibarnwa    项目:laraitassociate.i   
/**
  * Tests the getAliasByPath cache with an unpreloaded path with alias.
  *
  * @covers ::getAliasByPath
  * @covers ::writeCache
  */
 public function testGetAliasByPathUncachedMissWithAlias()
 {
     $path_part1 = $this->randomMachineName();
     $path_part2 = $this->randomMachineName();
     $path = '/' . $path_part1 . '/' . $path_part2;
     $cached_path = $this->randomMachineName();
     $cached_no_alias_path = $this->randomMachineName();
     $cached_alias = $this->randomMachineName();
     $new_alias = $this->randomMachineName();
     $language = $this->setUpCurrentLanguage();
     $cached_paths = array($language->getId() => array($cached_path, $cached_no_alias_path));
     $this->cache->expects($this->once())->method('get')->with($this->cacheKey)->will($this->returnValue((object) array('data' => $cached_paths)));
     // Simulate a request so that the preloaded paths are fetched.
     $this->aliasManager->setCacheKey($this->path);
     $this->aliasWhitelist->expects($this->any())->method('get')->with($path_part1)->will($this->returnValue(TRUE));
     $this->aliasStorage->expects($this->once())->method('preloadPathAlias')->with($cached_paths[$language->getId()], $language->getId())->will($this->returnValue(array($cached_path => $cached_alias)));
     $this->aliasStorage->expects($this->once())->method('lookupPathAlias')->with($path, $language->getId())->will($this->returnValue($new_alias));
     $this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
     // Call it twice to test the static cache.
     $this->assertEquals($new_alias, $this->aliasManager->getAliasByPath($path));
     // There is already a cache entry, so this should not write out to the
     // cache.
     $this->cache->expects($this->never())->method('set');
     $this->aliasManager->writeCache();
 }

作者:aWEBoLab    项目:tax   
/**
  * Provides information about modules' implementations of a hook.
  *
  * @param string $hook
  *   The name of the hook (e.g. "help" or "menu").
  *
  * @return mixed[]
  *   An array whose keys are the names of the modules which are implementing
  *   this hook and whose values are either a string identifying a file in
  *   which the implementation is to be found, or FALSE, if the implementation
  *   is in the module file.
  */
 protected function getImplementationInfo($hook)
 {
     if (!isset($this->implementations)) {
         $this->implementations = array();
         $this->verified = array();
         if ($cache = $this->cacheBackend->get('module_implements')) {
             $this->implementations = $cache->data;
         }
     }
     if (!isset($this->implementations[$hook])) {
         // The hook is not cached, so ensure that whether or not it has
         // implementations, the cache is updated at the end of the request.
         $this->cacheNeedsWriting = TRUE;
         // Discover implementations.
         $this->implementations[$hook] = $this->buildImplementationInfo($hook);
         // Implementations are always "verified" as part of the discovery.
         $this->verified[$hook] = TRUE;
     } elseif (!isset($this->verified[$hook])) {
         if (!$this->verifyImplementations($this->implementations[$hook], $hook)) {
             // One or more of the implementations did not exist and need to be
             // removed in the cache.
             $this->cacheNeedsWriting = TRUE;
         }
         $this->verified[$hook] = TRUE;
     }
     return $this->implementations[$hook];
 }

作者:alnutil    项目:drunatr   
/**
  * Tests buildTree with simple menu_name and no parameters.
  */
 public function testBuildTreeWithoutParameters()
 {
     $language = new Language(array('id' => 'en'));
     $this->languageManager->expects($this->any())->method('getCurrentLanguage')->will($this->returnValue($language));
     // Setup query and the query result.
     $query = $this->getMock('Drupal\\Core\\Entity\\Query\\QueryInterface');
     $this->entityQueryFactory->expects($this->once())->method('get')->with('menu_link')->will($this->returnValue($query));
     $query->expects($this->once())->method('condition')->with('menu_name', 'test_menu');
     $query->expects($this->once())->method('execute')->will($this->returnValue(array(1, 2, 3)));
     $storage = $this->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
     $base = array('access' => TRUE, 'weight' => 0, 'title' => 'title');
     $menu_link = $base + array('mlid' => 1, 'p1' => 3, 'p2' => 2, 'p3' => 1);
     $links[1] = $menu_link;
     $menu_link = $base + array('mlid' => 3, 'p1' => 3, 'depth' => 1);
     $links[3] = $menu_link;
     $menu_link = $base + array('mlid' => 2, 'p1' => 3, 'p2' => 2, 'depth' => 2);
     $links[2] = $menu_link;
     $storage->expects($this->once())->method('loadMultiple')->with(array(1, 2, 3))->will($this->returnValue($links));
     $this->menuTree->setStorage($storage);
     // Ensure that static/non static caching works.
     // First setup no working caching.
     $this->cacheBackend->expects($this->at(0))->method('get')->with('links:test_menu:tree-data:en:35786c7117b4e38d0f169239752ce71158266ae2f6e4aa230fbbb87bd699c0e3')->will($this->returnValue(FALSE));
     $this->cacheBackend->expects($this->at(1))->method('set')->with('links:test_menu:tree-data:en:35786c7117b4e38d0f169239752ce71158266ae2f6e4aa230fbbb87bd699c0e3', $this->anything(), Cache::PERMANENT, array('menu' => 'test_menu'));
     // Ensure that the static caching triggered.
     $this->cacheBackend->expects($this->exactly(1))->method('get');
     $this->menuTree->buildTree('test_menu');
     $this->menuTree->buildTree('test_menu');
 }

作者:davidsoloma    项目:drupalconsole.co   
/**
  * @covers ::delete()
  * @covers ::doDelete()
  */
 public function testDeleteNothing()
 {
     $this->moduleHandler->expects($this->never())->method($this->anything());
     $this->configFactory->expects($this->never())->method('get');
     $this->cacheBackend->expects($this->never())->method('invalidateTags');
     $this->entityStorage->delete(array());
 }

作者:ddrozdi    项目:dmap   
/**
  * {@inheritdoc}
  */
 public function loadTreeData($menu_name, MenuTreeParameters $parameters)
 {
     // Build the cache ID; sort 'expanded' and 'conditions' to prevent duplicate
     // cache items.
     sort($parameters->expandedParents);
     asort($parameters->conditions);
     $tree_cid = "tree-data:{$menu_name}:" . serialize($parameters);
     $cache = $this->menuCacheBackend->get($tree_cid);
     if ($cache && isset($cache->data)) {
         $data = $cache->data;
         // Cache the definitions in memory so they don't need to be loaded again.
         $this->definitions += $data['definitions'];
         unset($data['definitions']);
     } else {
         $links = $this->loadLinks($menu_name, $parameters);
         $data['tree'] = $this->doBuildTreeData($links, $parameters->activeTrail, $parameters->minDepth);
         $data['definitions'] = array();
         $data['route_names'] = $this->collectRoutesAndDefinitions($data['tree'], $data['definitions']);
         $this->menuCacheBackend->set($tree_cid, $data, Cache::PERMANENT, ['config:system.menu.' . $menu_name]);
         // The definitions were already added to $this->definitions in
         // $this->doBuildTreeData()
         unset($data['definitions']);
     }
     return $data;
 }

作者:vinodpanicke    项目:drupal-under-the-hoo   
/**
  * Tests the getAllBundleInfo() method.
  *
  * @covers ::getAllBundleInfo
  */
 public function testGetAllBundleInfo()
 {
     $this->moduleHandler->invokeAll('entity_bundle_info')->willReturn([]);
     $this->moduleHandler->alter('entity_bundle_info', Argument::type('array'))->willReturn(NULL);
     $apple = $this->prophesize(EntityTypeInterface::class);
     $apple->getLabel()->willReturn('Apple');
     $apple->getBundleOf()->willReturn(NULL);
     $banana = $this->prophesize(EntityTypeInterface::class);
     $banana->getLabel()->willReturn('Banana');
     $banana->getBundleOf()->willReturn(NULL);
     $this->setUpEntityTypeDefinitions(['apple' => $apple, 'banana' => $banana]);
     $this->cacheBackend->get('entity_bundle_info:en')->willReturn(FALSE);
     $this->cacheBackend->set('entity_bundle_info:en', Argument::any(), Cache::PERMANENT, ['entity_types', 'entity_bundles'])->will(function () {
         $this->get('entity_bundle_info:en')->willReturn((object) ['data' => 'cached data'])->shouldBeCalled();
     })->shouldBeCalled();
     $this->cacheTagsInvalidator->invalidateTags(['entity_bundles'])->shouldBeCalled();
     $this->typedDataManager->clearCachedDefinitions()->shouldBeCalled();
     $expected = ['apple' => ['apple' => ['label' => 'Apple']], 'banana' => ['banana' => ['label' => 'Banana']]];
     $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
     $this->assertSame($expected, $bundle_info);
     $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
     $this->assertSame($expected, $bundle_info);
     $this->entityTypeBundleInfo->clearCachedBundles();
     $bundle_info = $this->entityTypeBundleInfo->getAllBundleInfo();
     $this->assertSame('cached data', $bundle_info);
 }


问题


面经


文章

微信
公众号

扫码关注公众号