You are here

public function SpaceUsedTest::testFileSpaceUsed in Drupal 8

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

Test different users with the default status.

File

core/modules/file/tests/src/Kernel/SpaceUsedTest.php, line 57

Class

SpaceUsedTest
Tests the spaceUsed() function.

Namespace

Drupal\Tests\file\Kernel

Code

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