You are here

function FileSpaceUsedTest::setUp in SimpleTest 7

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

Parameters

...: List of modules to enable for the duration of the test.

Overrides DrupalWebTestCase::setUp

File

tests/file.test, line 286
This provides SimpleTests for the core file handling functionality. These include FileValidateTest and FileSaveTest.

Class

FileSpaceUsedTest
This will run tests against the file_space_used() function.

Code

function setUp() {
  parent::setUp();

  // Create records for a couple of users with different sizes.
  drupal_write_record('file', $file = array(
    'uid' => 2,
    'uri' => 'public://example1.txt',
    'filesize' => 50,
    'status' => FILE_STATUS_PERMANENT,
  ));
  drupal_write_record('file', $file = array(
    'uid' => 2,
    'uri' => 'public://example2.txt',
    'filesize' => 20,
    'status' => FILE_STATUS_PERMANENT,
  ));
  drupal_write_record('file', $file = array(
    'uid' => 3,
    'uri' => 'public://example3.txt',
    'filesize' => 100,
    'status' => FILE_STATUS_PERMANENT,
  ));
  drupal_write_record('file', $file = array(
    'uid' => 3,
    'uri' => 'public://example4.txt',
    'filesize' => 200,
    'status' => FILE_STATUS_PERMANENT,
  ));

  // Now create some with other statuses. These values were chosen arbitrarily
  // for the sole purpose of testing that bitwise operators were used
  // correctly on the field.
  drupal_write_record('file', $file = array(
    'uid' => 2,
    'uri' => 'public://example5.txt',
    'filesize' => 1,
    'status' => 2 | 8,
  ));
  drupal_write_record('file', $file = array(
    'uid' => 3,
    'uri' => 'public://example6.txt',
    'filesize' => 3,
    'status' => 2 | 4,
  ));
}