function FileFieldTestBase::getTestFile
Same name in other branches
- 9 core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getTestFile()
- 8.9.x core/modules/file/src/Tests/FileFieldTestBase.php \Drupal\file\Tests\FileFieldTestBase::getTestFile()
- 8.9.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getTestFile()
- 11.x core/modules/file/tests/src/Functional/FileFieldTestBase.php \Drupal\Tests\file\Functional\FileFieldTestBase::getTestFile()
Retrieves a sample file of the specified type.
Return value
\Drupal\file\FileInterface The new unsaved file entity.
26 calls to FileFieldTestBase::getTestFile()
- FileFieldAnonymousSubmissionTest::doTestNodeWithFileWithoutTitle in core/
modules/ file/ tests/ src/ Functional/ FileFieldAnonymousSubmissionTest.php - Helper method to test file submissions with missing node titles.
- FileFieldAnonymousSubmissionTest::testAnonymousNodeWithFile in core/
modules/ file/ tests/ src/ Functional/ FileFieldAnonymousSubmissionTest.php - Tests file submission for an anonymous visitor.
- FileFieldDisplayTest::testDefaultFileFieldDisplay in core/
modules/ file/ tests/ src/ Functional/ FileFieldDisplayTest.php - Tests default display of File Field.
- FileFieldDisplayTest::testDescriptionDefaultFileFieldDisplay in core/
modules/ file/ tests/ src/ Functional/ FileFieldDisplayTest.php - Tests description display of File Field.
- FileFieldFormatterAccessTest::testFileAccessHandler in core/
modules/ file/ tests/ src/ Functional/ FileFieldFormatterAccessTest.php - Tests the custom access handler is invoked.
File
-
core/
modules/ file/ tests/ src/ Functional/ FileFieldTestBase.php, line 64
Class
- FileFieldTestBase
- Provides methods specifically for testing File module's field handling.
Namespace
Drupal\Tests\file\FunctionalCode
public function getTestFile($type_name, $size = NULL) {
// Get a file to upload.
$file = current($this->drupalGetTestFiles($type_name, $size));
// Add a filesize property to files as would be read by
// \Drupal\file\Entity\File::load().
$file->filesize = filesize($file->uri);
return File::create((array) $file);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.