function FileEntityChangeSchemeTestCase::testChangeScheme in File Entity (fieldable files) 7.2
Same name and namespace in other branches
- 7.3 file_entity.test \FileEntityChangeSchemeTestCase::testChangeScheme()
File
- ./
file_entity.test, line 994 - Test integration for the file_entity module.
Class
- FileEntityChangeSchemeTestCase
- Test changing the scheme of a file.
Code
function testChangeScheme() {
// Select the first text test file to use.
$file = $this
->createFileEntity(array(
'type' => 'document',
));
$this
->assertEqual(file_uri_scheme($file->uri), 'public', 'File is public.');
// Create a user with file edit permissions.
$user = $this
->drupalCreateUser(array(
'edit any document files',
));
$this
->drupalLogin($user);
$this
->drupalGet('file/' . $file->fid . '/edit');
$this
->assertNoFieldByName('scheme');
// Create a user with file admin permissions.
$user = $this
->drupalCreateUser(array(
'edit any document files',
'administer files',
));
$this
->drupalLogin($user);
$this
->drupalGet('file/' . $file->fid . '/edit');
$this
->assertFieldByName('scheme', 'public');
$this
->drupalPost(NULL, array(
'scheme' => 'private',
), 'Save');
$file = entity_load_unchanged('file', $file->fid);
$this
->assertEqual(file_uri_scheme($file->uri), 'private', 'File has changed to private.');
}