You are here

public function CommentAlterFileTestCase::testFileFieldMultiple in Comment Alter 7

File

./comment_alter.test, line 559
Functional tests for the Comment Alter module.

Class

CommentAlterFileTestCase
Functional tests for Comment Alter and File fields.

Code

public function testFileFieldMultiple() {
  $field_name = $this
    ->createField('file', 'file_generic', array(
    'cardinality' => -1,
  ));
  $file1 = file_save_data($this
    ->randomName(), 'public://' . $this
    ->randomName() . '.txt', FILE_EXISTS_RENAME);
  $file1->display = TRUE;
  $file2 = $this
    ->getTestFile('text');
  $this
    ->createNodeThenPostComment(array(
    $field_name => array(
      LANGUAGE_NONE => array(
        0 => (array) $file1,
      ),
    ),
  ), array(
    "files[{$field_name}_" . LANGUAGE_NONE . '_1]' => drupal_realpath($file2->uri),
  ));
  $this
    ->assertCommentDiff(array(
    $field_name => array(
      array(
        'File: ' . basename($file1->uri),
        'File: ' . basename($file1->uri),
      ),
      array(
        NULL,
        'File: ' . basename($file2->uri),
      ),
    ),
  ));
}