function LoadTest::testLoadInvalidStatus

Same name in other branches
  1. 8.9.x core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testLoadInvalidStatus()
  2. 10 core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testLoadInvalidStatus()
  3. 11.x core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testLoadInvalidStatus()

Try to load a non-existent file by status.

File

core/modules/file/tests/src/Kernel/LoadTest.php, line 35

Class

LoadTest
Tests \Drupal\file\Entity\File::load().

Namespace

Drupal\Tests\file\Kernel

Code

public function testLoadInvalidStatus() {
    $files = \Drupal::entityTypeManager()->getStorage('file')
        ->loadByProperties([
        'status' => -99,
    ]);
    $this->assertFalse(reset($files), 'Trying to load a file with an invalid status fails.');
    $this->assertFileHooksCalled([]);
}

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