function 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 47 
Class
- SpaceUsedTest
- Tests the spaceUsed() function.
Namespace
Drupal\Tests\file\KernelCode
protected function createFileWithSize($uri, $size, $uid, $status = FileInterface::STATUS_PERMANENT) {
  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.
