function SpaceUsedTest::testFileSpaceUsed

Test different users with the default status.

File

drupal/core/modules/file/lib/Drupal/file/Tests/SpaceUsedTest.php, line 45
Definition of Drupal\file\Tests\SpaceUsedTest.

Class

SpaceUsedTest
This will run tests against the $file_managed->spaceUsed() function.

Namespace

Drupal\file\Tests

Code

function testFileSpaceUsed() {
  $file = entity_get_controller('file');

  // Test different users with default status.
  $this
    ->assertEqual($file
    ->spaceUsed(2), 70);
  $this
    ->assertEqual($file
    ->spaceUsed(3), 300);
  $this
    ->assertEqual($file
    ->spaceUsed(), 370);

  // Test the status fields
  $this
    ->assertEqual($file
    ->spaceUsed(NULL, 0), 4);
  $this
    ->assertEqual($file
    ->spaceUsed(NULL, FILE_STATUS_PERMANENT), 370);

  // Test both the user and status.
  $this
    ->assertEqual($file
    ->spaceUsed(1, 0), 0);
  $this
    ->assertEqual($file
    ->spaceUsed(1, FILE_STATUS_PERMANENT), 0);
  $this
    ->assertEqual($file
    ->spaceUsed(2, 0), 1);
  $this
    ->assertEqual($file
    ->spaceUsed(2, FILE_STATUS_PERMANENT), 70);
  $this
    ->assertEqual($file
    ->spaceUsed(3, 0), 3);
  $this
    ->assertEqual($file
    ->spaceUsed(3, FILE_STATUS_PERMANENT), 300);
}