1.20.x file.test | FileChangeSchemeTestCase::testChangeScheme() |
File
- modules/
file/ tests/ file.test, line 2709 - Tests for file.module.
Class
- FileChangeSchemeTestCase
- Test changing the scheme of a file.
Code
function testChangeScheme() {
// Select the first text test file to use.
$file = $this->createFile(array('type' => 'document'));
$this->assertEqual(file_uri_scheme($file->uri), 'public', 'File is public.');
// Create a user with file edit permissions.
$user = $this->backdropCreateUser(array('edit any document files'));
$this->backdropLogin($user);
$this->backdropGet('file/' . $file->fid . '/manage');
$this->assertNoFieldByName('scheme');
// Create a user with file admin permissions.
$user = $this->backdropCreateUser(array('edit any document files', 'manage files'));
$this->backdropLogin($user);
$this->backdropGet('file/' . $file->fid . '/manage');
$this->assertFieldByName('scheme', 'public');
$this->backdropPost(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.');
}