Drupal 8  8.0.2
EntityCacheTagsTestBase Class Reference
Inheritance diagram for EntityCacheTagsTestBase:

Public Member Functions

 testReferencedEntity ()
 
- Public Member Functions inherited from WebTestBase
 __construct ($test_id=NULL)
 
 drupalGetNodeByTitle ($title, $reset=FALSE)
 
- Public Member Functions inherited from TestBase
 __construct ($test_id=NULL)
 
 run (array $methods=array())
 
 errorHandler ($severity, $message, $file=NULL, $line=NULL)
 
 configImporter ()
 
 copyConfig (StorageInterface $source_storage, StorageInterface $target_storage)
 
 getDatabasePrefix ()
 
 getTempFilesDirectory ()
 

Static Public Attributes

static $modules = ['entity_test', 'field_test']
 

Protected Member Functions

 setUp ()
 
 createEntity ()
 
 getAccessCacheContextsForEntity (EntityInterface $entity)
 
 getAdditionalCacheContextsForEntity (EntityInterface $entity)
 
 getAdditionalCacheTagsForEntity (EntityInterface $entity)
 
 getAdditionalCacheContextsForEntityListing ()
 
 getAdditionalCacheTagsForEntityListing ()
 
 selectViewMode ($entity_type)
 
 createReferenceTestEntities ($referenced_entity)
 
 createCacheId (array $keys, array $contexts)
 
 verifyRenderCache ($cid, array $tags, $redirected_cid=NULL)
 
- Protected Member Functions inherited from PageCacheTagsTestBase
 setUp ()
 
 verifyPageCache (Url $url, $hit_or_miss, $tags=FALSE)
 
- Protected Member Functions inherited from WebTestBase
 drupalCreateNode (array $settings=array())
 
 drupalCreateContentType (array $values=array())
 
 drupalBuildEntityView (EntityInterface $entity, $view_mode= 'full', $langcode=NULL, $reset=FALSE)
 
 drupalPlaceBlock ($plugin_id, array $settings=array())
 
 assertBlockAppears (Block $block)
 
 assertNoBlockAppears (Block $block)
 
 findBlockInstance (Block $block)
 
 drupalGetTestFiles ($type, $size=NULL)
 
 drupalCompareFiles ($file1, $file2)
 
 drupalLogin (AccountInterface $account)
 
 drupalUserIsLoggedIn ($account)
 
 drupalLogout ()
 
 setUp ()
 
 doInstall ()
 
 prepareSettings ()
 
 initSettings ()
 
 initConfig (ContainerInterface $container)
 
 rebuildAll ()
 
 installParameters ()
 
 setBatch ()
 
 restoreBatch ()
 
 initUserSession ()
 
 initKernel (Request $request)
 
 addCustomTranslations ($langcode, array $values)
 
 writeCustomTranslations ()
 
 rebuildContainer ()
 
 resetAll ()
 
 refreshVariables ()
 
 tearDown ()
 
 curlInitialize ()
 
 curlExec ($curl_options, $redirect=FALSE)
 
 curlHeaderCallback ($curlHandler, $header)
 
 curlClose ()
 
 isInChildSite ()
 
 drupalGet ($path, array $options=array(), array $headers=array())
 
 drupalGetJSON ($path, array $options=array(), array $headers=array())
 
 drupalGetWithFormat ($path, $format, array $options=[], array $headers=[])
 
 drupalGetAjax ($path, array $options=array(), array $headers=array())
 
 drupalGetXHR ($path, array $options=array(), array $headers=array())
 
 drupalPostForm ($path, $edit, $submit, array $options=array(), array $headers=array(), $form_html_id=NULL, $extra_post=NULL)
 
 drupalPostAjaxForm ($path, $edit, $triggering_element, $ajax_path=NULL, array $options=array(), array $headers=array(), $form_html_id=NULL, $ajax_settings=NULL)
 
 drupalProcessAjaxResponse ($content, array $ajax_response, array $ajax_settings, array $drupal_settings)
 
 drupalPost ($path, $accept, array $post, $options=array())
 
 drupalPostWithFormat ($path, $format, array $post, $options=[])
 
 getAjaxPageStatePostData ()
 
 serializePostValues ($post=array())
 
 translatePostValues (array $values)
 
 cronRun ()
 
 checkForMetaRefresh ()
 
 drupalHead ($path, array $options=array(), array $headers=array())
 
 handleForm (&$post, &$edit, &$upload, $submit, $form)
 
 clickLink ($label, $index=0)
 
 clickLinkPartialName ($label, $index=0)
 
 clickLinkHelper ($label, $index, $pattern)
 
 getAbsoluteUrl ($path)
 
 drupalGetHeaders ($all_requests=FALSE)
 
 drupalGetHeader ($name, $all_requests=FALSE)
 
 assertHeader ($header, $value, $message= '', $group= 'Browser')
 
 drupalGetMails ($filter=array())
 
 assertUrl ($path, array $options=array(), $message= '', $group= 'Other')
 
 assertResponse ($code, $message= '', $group= 'Browser')
 
 assertNoResponse ($code, $message= '', $group= 'Browser')
 
 assertMail ($name, $value= '', $message= '', $group= 'Email')
 
 assertMailString ($field_name, $string, $email_depth, $message= '', $group= 'Other')
 
 assertMailPattern ($field_name, $regex, $message= '', $group= 'Other')
 
 verboseEmail ($count=1)
 
 prepareRequestForGenerator ($clean_urls=TRUE, $override_server_vars=array())
 
 buildUrl ($path, array $options=array())
 
 assertCacheContext ($expected_cache_context)
 
 assertNoCacheContext ($not_expected_cache_context)
 
 assertCacheTag ($expected_cache_tag)
 
 assertNoCacheTag ($cache_tag)
 
 setHttpResponseDebugCacheabilityHeaders ($value=TRUE)
 
- Protected Member Functions inherited from TestBase
 setUp ()
 
 checkRequirements ()
 
 storeAssertion (array $assertion)
 
 assert ($status, $message= '', $group= 'Other', array $caller=NULL)
 
 getAssertionCall ()
 
 assertTrue ($value, $message= '', $group= 'Other')
 
 assertFalse ($value, $message= '', $group= 'Other')
 
 assertNull ($value, $message= '', $group= 'Other')
 
 assertNotNull ($value, $message= '', $group= 'Other')
 
 assertEqual ($first, $second, $message= '', $group= 'Other')
 
 assertNotEqual ($first, $second, $message= '', $group= 'Other')
 
 assertIdentical ($first, $second, $message= '', $group= 'Other')
 
 assertNotIdentical ($first, $second, $message= '', $group= 'Other')
 
 assertIdenticalObject ($object1, $object2, $message= '', $group= 'Other')
 
 assertNoErrorsLogged ()
 
 assertErrorLogged ($error_message)
 
 pass ($message=NULL, $group= 'Other')
 
 fail ($message=NULL, $group= 'Other')
 
 error ($message= '', $group= 'Other', array $caller=NULL)
 
 verbose ($message)
 
 beforePrepareEnvironment ()
 
 tearDown ()
 
 exceptionHandler ($exception)
 
 settingsSet ($name, $value)
 
 config ($name)
 
 getConfigSchemaExclusions ()
 

Static Protected Member Functions

static generateStandardizedInfo ($entity_type_label, $group)
 

Protected Attributes

 $entity
 
 $referencingEntity
 
 $nonReferencingEntity
 
- Protected Attributes inherited from PageCacheTagsTestBase
 $dumpHeaders = TRUE
 
- Protected Attributes inherited from WebTestBase
 $profile = 'testing'
 
 $url
 
 $curlHandle
 
 $assertAjaxHeader = TRUE
 
 $headers
 
 $cookies = array()
 
 $dumpHeaders = FALSE
 
 $loggedInUser = FALSE
 
 $rootUser
 
 $cookieFile = NULL
 
 $additionalCurlOptions = array()
 
 $originalBatch
 
 $originalUser = NULL
 
 $originalShutdownCallbacks = array()
 
 $sessionId = NULL
 
 $generatedTestFiles = FALSE
 
 $maximumRedirects = 5
 
 $redirectCount
 
 $maximumMetaRefreshCount = NULL
 
 $metaRefreshCount = 0
 
 $kernel
 
 $configDirectories = array()
 
 $curlCookies = array()
 
 $customTranslations
 
 $classLoader
 
- Protected Attributes inherited from TestBase
 $testId
 
 $siteDirectory = NULL
 
 $databasePrefix = NULL
 
 $timeLimit = 500
 
 $assertions = array()
 
 $skipClasses = array(__CLASS__ => TRUE)
 
 $verboseId = 0
 
 $verboseClassName
 
 $verboseDirectory
 
 $verboseDirectoryUrl
 
 $originalConf
 
 $originalConfig
 
 $originalConfigDirectories
 
 $originalContainer
 
 $originalFileDirectory = NULL
 
 $originalLanguage
 
 $originalPrefix
 
 $originalProfile
 
 $originalSessionName
 
 $originalSettings
 
 $originalShutdownCallbacks
 
 $originalSite
 
 $originalUser
 
 $publicFilesDirectory
 
 $privateFilesDirectory
 
 $tempFilesDirectory
 
 $translationFilesDirectory
 
 $kernel
 
 $container
 
 $configImporter
 
 $strictConfigSchema = TRUE
 
 $httpAuthMethod = CURLAUTH_BASIC
 
 $httpAuthCredentials = NULL
 

Additional Inherited Members

- Static Public Member Functions inherited from TestBase
static insertAssert ($test_id, $test_class, $status, $message= '', $group= 'Other', array $caller=array())
 
static deleteAssert ($message_id)
 
static getDatabaseConnection ()
 
static generatePermutations ($parameters)
 
static filePreDeleteCallback ($path)
 
- Data Fields inherited from WebTestBase
createRole as drupalCreateRole
 
createAdminRole as drupalCreateAdminRole
 
- Data Fields inherited from TestBase
 $results
 
 $verbose
 
 $dieOnFail = FALSE
 
- Static Protected Attributes inherited from TestBase
static $configSchemaCheckerExclusions
 

Detailed Description

Provides helper methods for Entity cache tags tests.

Member Function Documentation

createCacheId ( array  $keys,
array  $contexts 
)
protected

Creates a cache ID from a list of cache keys and a set of cache contexts.

Parameters
string[]$keys A list of cache keys.
string[]$contexts A set of cache contexts.
Returns
string The cache ID string.

References Drupal\service().

Referenced by BlockContentCacheTagsTest\testBlock(), EntityWithUriCacheTagsTestBase\testEntityUri(), EntityCacheTagsTestBase\testReferencedEntity(), and EntityCacheTagsTestBase\verifyRenderCache().

Here is the call graph for this function:

Here is the caller graph for this function:

createEntity ( )
abstractprotected

Creates the entity to be tested.

Returns
The entity to be tested.

Referenced by EntityCacheTagsTestBase\setUp().

Here is the caller graph for this function:

createReferenceTestEntities (   $referenced_entity)
protected

Creates a referencing and a non-referencing entity for testing purposes.

Parameters
\Drupal\Core\Entity\EntityInterface$referenced_entityThe entity that the referencing entity should reference.
Returns
[] An array containing a referencing entity and a non-referencing entity.

References FieldStorageDefinitionInterface\CARDINALITY_UNLIMITED, Drupal\entityManager(), and EntityCacheTagsTestBase\selectViewMode().

Referenced by EntityCacheTagsTestBase\setUp().

Here is the call graph for this function:

Here is the caller graph for this function:

static generateStandardizedInfo (   $entity_type_label,
  $group 
)
staticprotected

Generates standardized entity cache tags test info.

Parameters
string$entity_type_labelThe label of the entity type whose cache tags to test.
string$groupThe test group.
Returns
array
See Also
::getInfo()
getAccessCacheContextsForEntity ( EntityInterface  $entity)
protected

Returns the access cache contexts for the tested entity.

Only list cache contexts that aren't part of the required cache contexts.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to be tested, as created by createEntity().
Returns
string[] An array of the additional cache contexts.
See Also

Referenced by EntityCacheTagsTestBase\testReferencedEntity().

Here is the caller graph for this function:

getAdditionalCacheContextsForEntity ( EntityInterface  $entity)
protected

Returns the additional (non-standard) cache contexts for the tested entity.

Only list cache contexts that aren't part of the required cache contexts.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to be tested, as created by createEntity().
Returns
string[] An array of the additional cache contexts.
See Also
::createEntity()

Referenced by EntityWithUriCacheTagsTestBase\testEntityUri(), and EntityCacheTagsTestBase\testReferencedEntity().

Here is the caller graph for this function:

getAdditionalCacheContextsForEntityListing ( )
protected

Returns the additional cache tags for the tested entity's listing by type.

Returns
string[] An array of the additional cache contexts.

Referenced by EntityCacheTagsTestBase\testReferencedEntity().

Here is the caller graph for this function:

getAdditionalCacheTagsForEntity ( EntityInterface  $entity)
protected

Returns the additional (non-standard) cache tags for the tested entity.

Parameters
\Drupal\Core\Entity\EntityInterface$entityThe entity to be tested, as created by createEntity().
Returns
array An array of the additional cache tags.
See Also
::createEntity()

Referenced by EntityWithUriCacheTagsTestBase\testEntityUri(), and EntityCacheTagsTestBase\testReferencedEntity().

Here is the caller graph for this function:

getAdditionalCacheTagsForEntityListing ( )
protected

Returns the additional cache tags for the tested entity's listing by type.

Necessary when there are unavoidable default entities of this type, e.g. the anonymous and administrator User entities always exist.

Returns
array An array of the additional cache tags.

Referenced by EntityCacheTagsTestBase\testReferencedEntity().

Here is the caller graph for this function:

selectViewMode (   $entity_type)
protected

Selects the preferred view mode for the given entity type.

Prefers 'full', picks the first one otherwise, and if none are available, chooses 'default'.

References Drupal\entityManager().

Referenced by EntityCacheTagsTestBase\createReferenceTestEntities(), EntityWithUriCacheTagsTestBase\testEntityUri(), and EntityCacheTagsTestBase\testReferencedEntity().

Here is the call graph for this function:

Here is the caller graph for this function:

setUp ( )
protected

{}

References RoleInterface\ANONYMOUS_ID, EntityCacheTagsTestBase\createEntity(), EntityCacheTagsTestBase\createReferenceTestEntities(), and Entity\load().

Here is the call graph for this function:

testReferencedEntity ( )

Tests cache tags presence and invalidation of the entity when referenced.

Tests the following cache tags:

  • entity type view cache tag: "<entity type>_view"
  • entity cache tag: "<entity type>:<entity ID>"
  • entity type list cache tag: "<entity type>_list"
  • referencing entity type view cache tag: "<referencing entity type>_view"
  • referencing entity type cache tag: "<referencing entity type>:<referencing entity ID>"

References TestBase\assertEqual(), EntityCacheTagsTestBase\createCacheId(), WebTestBase\drupalGetHeader(), Drupal\entityManager(), Url\fromRoute(), EntityCacheTagsTestBase\getAccessCacheContextsForEntity(), EntityCacheTagsTestBase\getAdditionalCacheContextsForEntity(), EntityCacheTagsTestBase\getAdditionalCacheContextsForEntityListing(), EntityCacheTagsTestBase\getAdditionalCacheTagsForEntity(), EntityCacheTagsTestBase\getAdditionalCacheTagsForEntityListing(), Cache\invalidateTags(), Entity\load(), Cache\mergeContexts(), Cache\mergeTags(), Drupal\moduleHandler(), TestBase\pass(), EntityCacheTagsTestBase\selectViewMode(), Drupal\service(), LanguageInterface\TYPE_INTERFACE, PageCacheTagsTestBase\verifyPageCache(), EntityCacheTagsTestBase\verifyRenderCache(), and MainContentViewSubscriber\WRAPPER_FORMAT.

Here is the call graph for this function:

verifyRenderCache (   $cid,
array  $tags,
  $redirected_cid = NULL 
)
protected

Verify that a given render cache entry exists, with the correct cache tags.

Parameters
string$cidThe render cache item ID.
array$tagsAn array of expected cache tags.
string | null$redirected_cid(optional) The redirected render cache item ID.

References TestBase\assertFalse(), TestBase\assertIdentical(), TestBase\assertTrue(), Drupal\cache(), and EntityCacheTagsTestBase\createCacheId().

Referenced by BlockContentCacheTagsTest\testBlock(), ShortcutCacheTagsTest\testEntityCreation(), ItemCacheTagsTest\testEntityCreation(), EntityWithUriCacheTagsTestBase\testEntityUri(), and EntityCacheTagsTestBase\testReferencedEntity().

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following file: