protected function FileListingTest::createFile in Drupal 8
Same name and namespace in other branches
- 9 core/modules/file/tests/src/Functional/FileListingTest.php \Drupal\Tests\file\Functional\FileListingTest::createFile()
Creates and saves a test file.
Return value
\Drupal\Core\Entity\EntityInterface A file entity.
1 call to FileListingTest::createFile()
- FileListingTest::testFileListingPages in core/
modules/ file/ tests/ src/ Functional/ FileListingTest.php - Tests file overview with different user permissions.
File
- core/
modules/ file/ tests/ src/ Functional/ FileListingTest.php, line 218
Class
- FileListingTest
- Tests file listing page functionality.
Namespace
Drupal\Tests\file\FunctionalCode
protected function createFile() {
// Create a new file entity.
$file = File::create([
'uid' => 1,
'filename' => 'druplicon.txt',
'uri' => 'public://druplicon.txt',
'filemime' => 'text/plain',
'created' => 1,
'changed' => 1,
'status' => FILE_STATUS_PERMANENT,
]);
file_put_contents($file
->getFileUri(), 'hello world');
// Save it, inserting a new record.
$file
->save();
return $file;
}