You are here

protected function EntityWebTestCase::createFile in Entity API 7

Creates a random file of the given type.

4 calls to EntityWebTestCase::createFile()
EntityMetadataIntegrationTestCase::testFileFields in ./entity.test
Test making use of a file field.
EntityMetadataIntegrationTestCase::testImageFields in ./entity.test
Test making use of an image field.
EntityMetadataIntegrationTestCase::testSystemProperties in ./entity.test
Test properties provided by system module.
EntityTokenTestCase::testTokenSupport in ./entity.test
Tests whether token support is basically working.

File

./entity.test, line 29
Entity CRUD API tests.

Class

EntityWebTestCase
Common parent class containing common helpers.

Code

protected function createFile($file_type = 'text') {

  // Create a managed file.
  $file = current($this
    ->drupalGetTestFiles($file_type));

  // Set additional file properties and save it.
  $file->filemime = file_get_mimetype($file->filename);
  $file->uid = 1;
  $file->timestamp = REQUEST_TIME;
  $file->filesize = filesize($file->uri);
  $file->status = 0;
  file_save($file);
  return $file;
}