function SpaceUsedTest::createFileWithSize
Same name in other branches
- 9 core/modules/file/tests/src/Kernel/SpaceUsedTest.php \Drupal\Tests\file\Kernel\SpaceUsedTest::createFileWithSize()
- 8.9.x core/modules/file/tests/src/Kernel/SpaceUsedTest.php \Drupal\Tests\file\Kernel\SpaceUsedTest::createFileWithSize()
- 10 core/modules/file/tests/src/Kernel/SpaceUsedTest.php \Drupal\Tests\file\Kernel\SpaceUsedTest::createFileWithSize()
Creates a file with a given size.
Parameters
string $uri: URI of the file to create.
int $size: Size of the file.
int $uid: File owner ID.
int $status: Whether the file should be permanent or temporary.
Return value
\Drupal\Core\Entity\EntityInterface The file entity.
1 call to SpaceUsedTest::createFileWithSize()
- SpaceUsedTest::setUp in core/
modules/ file/ tests/ src/ Kernel/ SpaceUsedTest.php
File
-
core/
modules/ file/ tests/ src/ Kernel/ SpaceUsedTest.php, line 50
Class
- SpaceUsedTest
- Tests the spaceUsed() function.
Namespace
Drupal\Tests\file\KernelCode
protected function createFileWithSize($uri, $size, $uid, $status = FileInterface::STATUS_PERMANENT) : EntityInterface {
file_put_contents($uri, $this->randomMachineName($size));
$file = File::create([
'uri' => $uri,
'uid' => $uid,
'status' => $status,
]);
$file->save();
return $file;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.