public function FileFieldPathsGeneralTestCase::testLongPath in File (Field) Paths 7
Test File (Field) Paths with a very long path.
File
- tests/
filefield_paths.general.test, line 144 - Tests for the File (Field) Paths module.
Class
- FileFieldPathsGeneralTestCase
- Class FileFieldPathsGeneralTestCase
Code
public function testLongPath() {
// Create a File field with 'node/[random:hash:sha256]' as the File path.
$field_name = drupal_strtolower($this
->randomName());
$instance_settings['filefield_paths']['file_path']['value'] = 'node/[random:hash:sha512]/[random:hash:sha512]';
$this
->createFileField($field_name, $this->content_type, array(), $instance_settings);
// Create a node with a test file.
$test_file = $this
->getTestFile('text');
$nid = $this
->uploadNodeFile($test_file, $field_name, $this->content_type);
// Ensure file path is no more than 255 characters.
$node = node_load($nid, NULL, TRUE);
$this
->assert(drupal_strlen($node->{$field_name}[LANGUAGE_NONE][0]['uri']) <= 255, t('File path is no more than 255 characters'));
}