Drupal 8  8.0.2
FileManagedUnitTestBase Class Reference
Inheritance diagram for FileManagedUnitTestBase:

Public Member Functions

 assertFileHooksCalled ($expected)
 
 assertFileHookCalled ($hook, $expected_count=1, $message=NULL)
 
 assertFileUnchanged (FileInterface $before, FileInterface $after)
 
 assertDifferentFile (FileInterface $file1, FileInterface $file2)
 
 assertSameFile (FileInterface $file1, FileInterface $file2)
 
 createFile ($filepath=NULL, $contents=NULL, $scheme=NULL)
 
 createUri ($filepath=NULL, $contents=NULL, $scheme=NULL)
 

Static Public Attributes

static $modules = array('file_test', 'file', 'system', 'field', 'user')
 

Protected Member Functions

 setUp ()
 

Detailed Description

Base class for file unit tests that use the file_test module to test uploads and hooks.

Member Function Documentation

assertDifferentFile ( FileInterface  $file1,
FileInterface  $file2 
)

Asserts that two files are not the same by comparing the fid and filepath.

Parameters
\Drupal\file\FileInterface$file1File object to compare.
\Drupal\file\FileInterface$file2File object to compare.

References FileInterface\getFileUri(), EntityInterface\id(), and t().

Referenced by CopyTest\testExistingError(), MoveTest\testExistingError(), CopyTest\testExistingRename(), MoveTest\testExistingRename(), SaveDataTest\testExistingRename(), MoveTest\testExistingReplace(), CopyTest\testExistingReplace(), and CopyTest\testNormal().

Here is the call graph for this function:

Here is the caller graph for this function:

assertFileHookCalled (   $hook,
  $expected_count = 1,
  $message = NULL 
)

Assert that a hook_file_* hook was called a certain number of times.

Parameters
string$hookString with the hook name, e.g. 'load', 'save', 'insert', etc.
int$expected_countOptional integer count.
string$messageOptional translated string message.

References format_string(), and Drupal\translation().

Referenced by LoadTest\testMultiple(), LoadTest\testSingleValues(), and LoadTest\testUuidValues().

Here is the call graph for this function:

Here is the caller graph for this function:

assertFileHooksCalled (   $expected)

Assert that all of the specified hook_file_* hooks were called once, other values result in failure.

Parameters
array$expectedArray with string containing with the hook name, e.g. 'load', 'save', 'insert', etc.

References format_string(), and Drupal\state().

Referenced by ValidateTest\testCallerValidation(), SaveDataTest\testExistingError(), CopyTest\testExistingError(), MoveTest\testExistingError(), CopyTest\testExistingRename(), MoveTest\testExistingRename(), SaveDataTest\testExistingRename(), MoveTest\testExistingReplace(), CopyTest\testExistingReplace(), SaveDataTest\testExistingReplace(), MoveTest\testExistingReplaceSelf(), DeleteTest\testInUse(), LoadTest\testLoadInvalidStatus(), LoadTest\testLoadMissingFid(), LoadTest\testLoadMissingFilepath(), LoadTest\testMultiple(), CopyTest\testNormal(), MoveTest\testNormal(), DeleteTest\testUnused(), SaveDataTest\testWithFilename(), and SaveDataTest\testWithoutFilename().

Here is the call graph for this function:

Here is the caller graph for this function:

assertFileUnchanged ( FileInterface  $before,
FileInterface  $after 
)

Asserts that two files have the same values (except timestamp).

Parameters
\Drupal\file\FileInterface$beforeFile object to compare.
\Drupal\file\FileInterface$afterFile object to compare.

References FileInterface\getFilename(), FileInterface\getFileUri(), FileInterface\getMimeType(), EntityOwnerInterface\getOwner(), FileInterface\getSize(), EntityInterface\id(), FileInterface\isPermanent(), and t().

Referenced by SaveDataTest\testExistingError(), CopyTest\testExistingError(), MoveTest\testExistingError(), CopyTest\testExistingRename(), MoveTest\testExistingRename(), SaveDataTest\testExistingRename(), MoveTest\testExistingReplace(), CopyTest\testExistingReplace(), SaveDataTest\testExistingReplace(), MoveTest\testExistingReplaceSelf(), MoveTest\testNormal(), CopyTest\testNormal(), SaveDataTest\testWithFilename(), and SaveDataTest\testWithoutFilename().

Here is the call graph for this function:

Here is the caller graph for this function:

assertSameFile ( FileInterface  $file1,
FileInterface  $file2 
)

Asserts that two files are the same by comparing the fid and filepath.

Parameters
\Drupal\file\FileInterface$file1File object to compare.
\Drupal\file\FileInterface$file2File object to compare.

References FileInterface\getFileUri(), EntityInterface\id(), and t().

Referenced by MoveTest\testExistingReplace(), and SaveDataTest\testExistingReplace().

Here is the call graph for this function:

Here is the caller graph for this function:

createFile (   $filepath = NULL,
  $contents = NULL,
  $scheme = NULL 
)

Create a file and save it to the files table and assert that it occurs correctly.

Parameters
string$filepathOptional string specifying the file path. If none is provided then a randomly named file will be created in the site's files directory.
string$contentsOptional contents to save into the file. If a NULL value is provided an arbitrary string will be used.
string$schemeOptional string indicating the stream scheme to use. Drupal core includes public, private, and temporary. The public wrapper is the default.
Returns
File entity.

References FileManagedUnitTestBase\createUri(), and Drupal\state().

Referenced by UsageTest\testAddUsage(), ValidateTest\testCallerValidation(), SaveDataTest\testExistingError(), CopyTest\testExistingError(), MoveTest\testExistingError(), CopyTest\testExistingRename(), MoveTest\testExistingRename(), SaveDataTest\testExistingRename(), MoveTest\testExistingReplace(), CopyTest\testExistingReplace(), SaveDataTest\testExistingReplace(), MoveTest\testExistingReplaceSelf(), UsageTest\testGetUsage(), DeleteTest\testInUse(), LoadTest\testMultiple(), CopyTest\testNormal(), MoveTest\testNormal(), UsageTest\testRemoveUsage(), LoadTest\testSingleValues(), DeleteTest\testUnused(), and LoadTest\testUuidValues().

Here is the call graph for this function:

Here is the caller graph for this function:

createUri (   $filepath = NULL,
  $contents = NULL,
  $scheme = NULL 
)

Creates a file and returns its URI.

Parameters
string$filepathOptional string specifying the file path. If none is provided then a randomly named file will be created in the site's files directory.
string$contentsOptional contents to save into the file. If a NULL value is provided an arbitrary string will be used.
string$schemeOptional string indicating the stream scheme to use. Drupal core includes public, private, and temporary. The public wrapper is the default.
Returns
string File URI.

References file_default_scheme(), and t().

Referenced by FileManagedUnitTestBase\createFile().

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: