namespace Drupal\Tests\token\Kernel;
+use Drupal\file\Entity\File;
/**
* Tests file tokens.
*
*
* @var array
*/
- public static $modules = array('file');
+ public static $modules = ['file'];
/**
* {@inheritdoc}
function testFileTokens() {
// Create a test file object.
- $file = entity_create('file', array(
+ $file = File::create([
'fid' => 1,
'filename' => 'test.png',
'filesize' => 100,
'uri' => 'public://images/test.png',
'filemime' => 'image/png',
- ));
+ ]);
- $tokens = array(
+ $tokens = [
'basename' => 'test.png',
'extension' => 'png',
'size-raw' => 100,
- );
- $this->assertTokens('file', array('file' => $file), $tokens);
+ ];
+ $this->assertTokens('file', ['file' => $file], $tokens);
// Test a file with no extension and a fake name.
$file->filename = 'Test PNG image';
$file->uri = 'public://images/test';
- $tokens = array(
+ $tokens = [
'basename' => 'test',
'extension' => '',
'size-raw' => 100,
- );
- $this->assertTokens('file', array('file' => $file), $tokens);
+ ];
+ $this->assertTokens('file', ['file' => $file], $tokens);
}
+
}