public function ScaldAtomEntityTestCase::testScaldPrivateFileSystem in Scald: Media Management made easy 7
Test Scald with private file system.
File
- tests/
scald.test, line 469 - Tests for scald.module.
Class
- ScaldAtomEntityTestCase
- Test the Scald atom entities.
Code
public function testScaldPrivateFileSystem() {
$this
->enablePrivateFileSystem();
$image = $this
->getTestFile('image');
$this
->drupalLogout();
$web_user = $this
->drupalCreateUser(array(
'view any atom',
'fetch any atom',
'create atom of image type',
));
$this
->drupalLogin($web_user);
// Create an image atom.
$edit = array(
'files[file]' => drupal_realpath($image->uri),
);
$this
->drupalPost('atom/add/image', $edit, t('Continue'));
$this
->drupalPost(NULL, array(), t('Finish'));
// Check that the image is accessible.
$this
->assertIdentical(1, preg_match('/scald=1:full --><img.*?src="(.+?)"/', $this
->drupalGetContent(), $match), 'Found image in the atom full page.');
$url = $match[1];
$this
->assertNotIdentical(FALSE, strpos($url, 'system/files/'), 'Private file system is used for this atom.');
$this
->drupalGet($url);
$this
->assertResponse(200, 'Private image inside the atom is accessible.');
}