Drupal 8  8.0.2
FileFieldTestBase Class Reference
Inheritance diagram for FileFieldTestBase:

Public Member Functions

 getTestFile ($type_name, $size=NULL)
 
 getLastFileId ()
 
 createFileField ($name, $entity_type, $bundle, $storage_settings=array(), $field_settings=array(), $widget_settings=array())
 
 attachFileField ($name, $entity_type, $bundle, $field_settings=array(), $widget_settings=array())
 
 updateFileField ($name, $type_name, $field_settings=array(), $widget_settings=array())
 
 uploadNodeFile (FileInterface $file, $field_name, $nid_or_type, $new_revision=TRUE, array $extras=array())
 
 uploadNodeFiles (array $files, $field_name, $nid_or_type, $new_revision=TRUE, array $extras=array())
 
 removeNodeFile ($nid, $new_revision=TRUE)
 
 replaceNodeFile ($file, $field_name, $nid, $new_revision=TRUE)
 
 assertFileExists ($file, $message=NULL)
 
 assertFileEntryExists ($file, $message=NULL)
 
 assertFileNotExists ($file, $message=NULL)
 
 assertFileEntryNotExists ($file, $message)
 
 assertFileIsPermanent (FileInterface $file, $message=NULL)
 
- 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 = array('node', 'file', 'file_module_test', 'field_ui')
 

Protected Member Functions

 setUp ()
 
- 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 ()
 

Protected Attributes

 $adminUser
 
- 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 methods specifically for testing File module's field handling.

Member Function Documentation

assertFileEntryExists (   $file,
  $message = NULL 
)

Asserts that a file exists in the database.

References format_string(), and Entity\load().

Here is the call graph for this function:

assertFileEntryNotExists (   $file,
  $message 
)

Asserts that a file does not exist in the database.

References format_string(), and Entity\load().

Here is the call graph for this function:

assertFileExists (   $file,
  $message = NULL 
)

Asserts that a file exists physically on disk.

References format_string().

Referenced by FileFieldWidgetTest\testSingleValuedWidget().

Here is the call graph for this function:

Here is the caller graph for this function:

assertFileIsPermanent ( FileInterface  $file,
  $message = NULL 
)

Asserts that a file's status is set to permanent in the database.

References format_string(), FileInterface\getFileUri(), and FileInterface\isPermanent().

Here is the call graph for this function:

assertFileNotExists (   $file,
  $message = NULL 
)

Asserts that a file does not exist on disk.

References format_string().

Here is the call graph for this function:

attachFileField (   $name,
  $entity_type,
  $bundle,
  $field_settings = array(),
  $widget_settings = array() 
)

Attaches a file field to an entity.

Parameters
string$nameThe name of the new field (all lowercase), exclude the "field_" prefix.
string$entity_typeThe entity type this field will be added to.
string$bundleThe bundle this field will be added to.
array$field_settingsA list of field settings that will be added to the defaults.
array$widget_settingsA list of widget settings that will be added to the widget defaults.

Referenced by FileFieldTestBase\createFileField().

Here is the caller graph for this function:

createFileField (   $name,
  $entity_type,
  $bundle,
  $storage_settings = array(),
  $field_settings = array(),
  $widget_settings = array() 
)

Creates a new file field.

Parameters
string$nameThe name of the new field (all lowercase), exclude the "field_" prefix.
string$entity_typeThe entity type.
string$bundleThe bundle that this field will be added to.
array$storage_settingsA list of field storage settings that will be added to the defaults.
array$field_settingsA list of instance settings that will be added to the instance defaults.
array$widget_settingsA list of widget settings that will be added to the widget defaults.

References FileFieldTestBase\attachFileField().

Referenced by PrivateFileOnTranslatedEntityTest\setUp(), FileFieldFormatterAccessTest\testFileAccessHandler(), FileFieldRSSContentTest\testFileFieldRSSContent(), FileTokenReplaceTest\testFileTokenReplacement(), FileFieldDisplayTest\testNodeDisplay(), FilePrivateTest\testPrivateFile(), FileFieldValidateTest\testRequired(), FileFieldRevisionTest\testRevisions(), and FileFieldWidgetTest\testSingleValuedWidget().

Here is the call graph for this function:

Here is the caller graph for this function:

getLastFileId ( )

Retrieves the fid of the last inserted file.

References db_query().

Referenced by FileManagedFileElementTest\testManagedFile(), FileManagedFileElementTest\testManagedFileRemoved(), and PrivateFileOnTranslatedEntityTest\testPrivateLanguageFile().

Here is the call graph for this function:

Here is the caller graph for this function:

getTestFile (   $type_name,
  $size = NULL 
)

Retrieves a sample file of the specified type.

References WebTestBase\drupalGetTestFiles().

Referenced by FileFieldFormatterAccessTest\testFileAccessHandler(), FileFieldRSSContentTest\testFileFieldRSSContent(), FileListingTest\testFileListingPages(), FileTokenReplaceTest\testFileTokenReplacement(), FileManagedFileElementTest\testManagedFile(), FileManagedFileElementTest\testManagedFileRemoved(), FileFieldDisplayTest\testNodeDisplay(), FilePrivateTest\testPrivateFile(), FileFieldValidateTest\testRequired(), FileFieldRevisionTest\testRevisions(), and FileFieldWidgetTest\testSingleValuedWidget().

Here is the call graph for this function:

Here is the caller graph for this function:

removeNodeFile (   $nid,
  $new_revision = TRUE 
)

Removes a file from a node.

Note that if replacing a file, it must first be removed then added again.

References t().

Here is the call graph for this function:

replaceNodeFile (   $file,
  $field_name,
  $nid,
  $new_revision = TRUE 
)

Replaces a file within a node.

References drupal_realpath(), and t().

Here is the call graph for this function:

updateFileField (   $name,
  $type_name,
  $field_settings = array(),
  $widget_settings = array() 
)

Updates an existing file field with new settings.

References FieldConfig\loadByName().

Here is the call graph for this function:

uploadNodeFile ( FileInterface  $file,
  $field_name,
  $nid_or_type,
  $new_revision = TRUE,
array  $extras = array() 
)

Uploads a file to a node.

Parameters
\Drupal\file\FileInterface$fileThe File to be uploaded.
string$field_nameThe name of the field on which the files should be saved.
$nid_or_typeA numeric node id to upload files to an existing node, or a string indicating the desired bundle for a new node.
bool$new_revisionThe revision number.
array$extrasAdditional values when a new node is created.
Returns
int The node id.

References FileFieldTestBase\uploadNodeFiles().

Referenced by FileFieldFormatterAccessTest\testFileAccessHandler(), FileFieldRSSContentTest\testFileFieldRSSContent(), FileTokenReplaceTest\testFileTokenReplacement(), FileFieldDisplayTest\testNodeDisplay(), FilePrivateTest\testPrivateFile(), FileFieldValidateTest\testRequired(), FileFieldRevisionTest\testRevisions(), and FileFieldWidgetTest\testSingleValuedWidget().

Here is the call graph for this function:

Here is the caller graph for this function:

uploadNodeFiles ( array  $files,
  $field_name,
  $nid_or_type,
  $new_revision = TRUE,
array  $extras = array() 
)

Uploads multiple files to a node.

Parameters
\Drupal\file\FileInterface[]$files The files to be uploaded.
string$field_nameThe name of the field on which the files should be saved.
$nid_or_typeA numeric node id to upload files to an existing node, or a string indicating the desired bundle for a new node.
bool$new_revisionThe revision number.
array$extrasAdditional values when a new node is created.
Returns
int The node id.

References TestBase\assertNotEqual(), WebTestBase\drupalCreateNode(), and FieldStorageConfig\loadByName().

Referenced by FileFieldTestBase\uploadNodeFile().

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: