You are here

function TokenFileTestCase::testFileTokens in Token 7

File

./token.test, line 1032
Test integration for the token module.

Class

TokenFileTestCase

Code

function testFileTokens() {

  // Create a test file object.
  $file = new stdClass();
  $file->fid = 1;
  $file->filename = 'test.png';
  $file->filesize = 100;
  $file->uri = 'public://images/test.png';
  $file->filemime = 'image/png';
  $tokens = array(
    'basename' => 'test.png',
    'extension' => 'png',
    'size-raw' => 100,
  );
  $this
    ->assertTokens('file', array(
    '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(
    'basename' => 'test',
    'extension' => '',
    'size-raw' => 100,
  );
  $this
    ->assertTokens('file', array(
    'file' => $file,
  ), $tokens);
}