1 file.test FileUnitTestCase::testFile()

Tests basic file entity properties.

File

core/modules/file/tests/file.test, line 2178
Tests for file.module.

Class

FileUnitTestCase
Tests basic file entity functionality.

Code

function testFile() {
  // Save a raw file, turning it into a file entity.
  $file = $this->getTestFile('text');
  $file->uid = 1;
  $file->status = FILE_STATUS_PERMANENT;
  $file = new File((array) $file);
  file_save($file);

  // Test entity ID, revision ID, and bundle.
  $ids = entity_extract_ids('file', $file);
  $this->assertIdentical($ids, array($file->fid, NULL, 'document'));

  // Test the entity URI callback.
  $uri = entity_uri('file', $file);
  $this->assertEqual($uri, $file->uri());
}