You are here

function SpaceUsedTest::testFileSpaceUsed in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/file/src/Tests/SpaceUsedTest.php \Drupal\file\Tests\SpaceUsedTest::testFileSpaceUsed()

Test different users with the default status.

File

core/modules/file/src/Tests/SpaceUsedTest.php, line 59
Contains \Drupal\file\Tests\SpaceUsedTest.

Class

SpaceUsedTest
Tests the spaceUsed() function.

Namespace

Drupal\file\Tests

Code

function testFileSpaceUsed() {
  $file = $this->container
    ->get('entity.manager')
    ->getStorage('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);
}