public function createFile($filepath = NULL,
$contents = NULL,
$scheme = NULL
) { // Don't count hook invocations caused by creating the file.
\Drupal::
state()->
set('file_test.count_hook_invocations', FALSE
);
$file = File::
create([ 'uri' =>
$this->
createUri($filepath,
$contents,
$scheme),
'uid' => 1,
]);
$file->
save();
// Write the record directly rather than using the API so we don't invoke
// the hooks.
// Verify that the file was added to the database.
$this->
assertGreaterThan(0,
$file->
id());
\Drupal::
state()->
set('file_test.count_hook_invocations', TRUE
);
return $file;
} /**
* Creates a file and returns its URI.
*
* @param string $filepath
* Optional string specifying the file path. If none is provided then a
* randomly named file will be created in the site's files directory.
* @param string $contents
* Optional contents to save into the file. If a NULL value is provided an
* arbitrary string will be used.
* @param string $scheme
* Optional string indicating the stream scheme to use. Drupal core includes
* public, private, and temporary. The public wrapper is the default.
*
* @return string
* File URI.
*/