public function FileHashTest::testFileHash in File Hash 8
Tests that a file hash is set on the file object.
File
- tests/
src/ Functional/ FileHashTest.php, line 51
Class
- FileHashTest
- File Hash tests.
Namespace
Drupal\Tests\filehash\FunctionalCode
public function testFileHash() {
$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');
$file
->save();
$this
->assertEquals($file->filehash['sha1'], '2aae6c35c94fcfb415dbe95f408b9ce91ee846ed', 'File hash was set correctly.');
}