Commit a15bf9ee authored by alexpott's avatar alexpott

Issue #1970006 by andypost: Make FileFieldTestBase::createFileField to return Field entity.

parent 49861ccc
......@@ -35,8 +35,6 @@ function testNodeDisplay() {
);
$widget_settings = array();
$this->createFileField($field_name, $type_name, $field_settings, $instance_settings, $widget_settings);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
// Create a new node *without* the file field set, and check that the field
// is not shown for each node display.
......
......@@ -25,7 +25,7 @@ public static function getInfo() {
function testUploadPath() {
$field_name = strtolower($this->randomName());
$type_name = 'article';
$field = $this->createFileField($field_name, $type_name);
$this->createFileField($field_name, $type_name);
$test_file = $this->getTestFile('text');
// Create a new node.
......@@ -37,7 +37,7 @@ function testUploadPath() {
$this->assertPathMatch('public://' . $test_file->filename, $node_file->uri, t('The file %file was uploaded to the correct path.', array('%file' => $node_file->uri)));
// Change the path to contain multiple subdirectories.
$field = $this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz'));
$this->updateFileField($field_name, $type_name, array('file_directory' => 'foo/bar/baz'));
// Upload a new file into the subdirectories.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
......@@ -49,7 +49,7 @@ function testUploadPath() {
// Check the path when used with tokens.
// Change the path to contain multiple token directories.
$field = $this->updateFileField($field_name, $type_name, array('file_directory' => '[current-user:uid]/[current-user:name]'));
$this->updateFileField($field_name, $type_name, array('file_directory' => '[current-user:uid]/[current-user:name]'));
// Upload a new file into the token subdirectories.
$nid = $this->uploadNodeFile($test_file, $field_name, $type_name);
......
......@@ -42,8 +42,6 @@ function testFileFieldRSSContent() {
);
$widget_settings = array();
$this->createFileField($field_name, $type_name, $field_settings, $instance_settings, $widget_settings);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
// RSS display must be added manually.
$this->drupalGet("admin/structure/types/manage/$type_name/display");
......
......@@ -34,8 +34,6 @@ function testRevisions() {
$type_name = 'article';
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
// Attach the same fields to users.
$this->attachFileField($field_name, 'user', 'user');
......
......@@ -72,9 +72,10 @@ function createFileField($name, $type_name, $field_settings = array(), $instance
'cardinality' => !empty($field_settings['cardinality']) ? $field_settings['cardinality'] : 1,
);
$field['settings'] = array_merge($field['settings'], $field_settings);
field_create_field($field);
$field = field_create_field($field);
$this->attachFileField($name, 'node', $type_name, $instance_settings, $widget_settings);
return $field;
}
/**
......
......@@ -28,8 +28,7 @@ public static function getInfo() {
function testRequired() {
$type_name = 'article';
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name, array(), array('required' => '1'));
$field = field_info_field($field_name);
$field = $this->createFileField($field_name, $type_name, array(), array('required' => '1'));
$instance = field_info_instance('node', $field_name, $type_name);
$test_file = $this->getTestFile('text');
......@@ -65,9 +64,6 @@ function testRequired() {
$node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading to the required multiple value field.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading to the required multipel value field.'));
// Remove our file field.
field_delete_field($field_name);
}
/**
......@@ -77,8 +73,6 @@ function testFileMaxSize() {
$type_name = 'article';
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name, array(), array('required' => '1'));
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
$small_file = $this->getTestFile('text', 131072); // 128KB.
$large_file = $this->getTestFile('text', 1310720); // 1.2MB
......@@ -93,7 +87,6 @@ function testFileMaxSize() {
foreach ($sizes as $max_filesize => $file_limit) {
// Set the max file upload size.
$this->updateFileField($field_name, $type_name, array('max_filesize' => $max_filesize));
$instance = field_info_instance('node', $field_name, $type_name);
// Create a new node with the small file, which should pass.
$nid = $this->uploadNodeFile($small_file, $field_name, $type_name);
......@@ -117,9 +110,6 @@ function testFileMaxSize() {
$node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file (%filesize) with no max limit.', array('%filesize' => format_size($large_file->filesize))));
// Remove our file field.
field_delete_field($field_name);
}
/**
......@@ -129,8 +119,6 @@ function testFileExtension() {
$type_name = 'article';
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
$test_file = $this->getTestFile('image');
list(, $test_file_extension) = explode('.', $test_file->filename);
......@@ -162,8 +150,5 @@ function testFileExtension() {
$node_file = file_load($node->{$field_name}[LANGUAGE_NOT_SPECIFIED][0]['fid']);
$this->assertFileExists($node_file, t('File exists after uploading a file with extension checking.'));
$this->assertFileEntryExists($node_file, t('File entry exists after uploading a file with extension checking.'));
// Remove our file field.
field_delete_field($field_name);
}
}
......@@ -34,8 +34,6 @@ function testSingleValuedWidget() {
$type_name = 'article';
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
$test_file = $this->getTestFile('text');
......@@ -99,12 +97,6 @@ function testMultiValuedWidget() {
$this->createFileField($field_name, $type_name, array('cardinality' => 3));
$this->createFileField($field_name2, $type_name, array('cardinality' => 3));
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
$field2 = field_info_field($field_name2);
$instance2 = field_info_instance('node', $field_name2, $type_name);
$test_file = $this->getTestFile('text');
foreach (array('nojs', 'js') as $type) {
......@@ -213,8 +205,6 @@ function testPrivateFileSetting() {
$type_name = 'article';
$field_name = strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
$test_file = $this->getTestFile('text');
......
......@@ -34,8 +34,6 @@ function testFileTokenReplacement() {
$type_name = 'article';
$field_name = 'field_' . strtolower($this->randomName());
$this->createFileField($field_name, $type_name);
$field = field_info_field($field_name);
$instance = field_info_instance('node', $field_name, $type_name);
$test_file = $this->getTestFile('text');
// Coping a file to test uploads with non-latin filenames.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment