1 file.test public FileManagedFileElementTestCase::testManagedFileExceedMaximumFileSize()

Tests uploading a file that exceeds the maximum file size.

File

core/modules/file/tests/file.test, line 720
Tests for file.module.

Class

FileManagedFileElementTestCase
Tests the 'managed_file' element type.

Code

public function testManagedFileExceedMaximumFileSize() {
  $path = 'file/test/0/0';
  $this->backdropGet($path);

  // Create a test file that exceeds the maximum POST size with 1 kilobyte.
  $post_max_size = $this->_postMaxSizeToInteger(ini_get('post_max_size'));
  $filename = 'text-exceeded';
  simpletest_generate_file($filename, ceil(($post_max_size + 1024) / 1024), 1024, 'text');
  $uri = 'public://' . $filename . '.txt';
  $input_base_name = 'file';
  $edit = array('files[' . $input_base_name . ']' => backdrop_realpath($uri));
  $this->backdropPostAJAX(NULL, $edit, $input_base_name . '_upload_button');
  $this->assertFieldByXpath('//input[@type="submit"]', t('Upload'), 'After uploading a file that exceeds the maximum file size, the "Upload" button is displayed.');
  $this->backdropPost($path, array(), t('Save'));
  $this->assertRaw(t('The file id is %fid.', array('%fid' => 0)), 'Submitted without a file.');
}