function FileManagedFileElementTestCase::testManagedFileExceedMaximumFileSize

Tests uploading a file that exceeds the maximum file size.

File

modules/file/tests/file.test, line 496

Class

FileManagedFileElementTestCase
Tests the 'managed_file' element type.

Code

function testManagedFileExceedMaximumFileSize() {
    $path = 'file/test/0/0';
    $this->drupalGet($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 . ']' => drupal_realpath($uri),
    );
    $this->drupalPostAJAX(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->drupalPost($path, array(), t('Save'));
    $this->assertRaw(t('The file id is %fid.', array(
        '%fid' => 0,
    )), 'Submitted without a file.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.