public function LoadTest::testLoadMissingFilepath in Drupal 9
Same name and namespace in other branches
- 8 core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testLoadMissingFilepath()
Try to load a non-existent file by URI.
File
- core/modules/ file/ tests/ src/ Kernel/ LoadTest.php, line 26 
Class
- LoadTest
- Tests \Drupal\file\Entity\File::load().
Namespace
Drupal\Tests\file\KernelCode
public function testLoadMissingFilepath() {
  $files = \Drupal::entityTypeManager()
    ->getStorage('file')
    ->loadByProperties([
    'uri' => 'foobar://misc/druplicon.png',
  ]);
  $this
    ->assertFalse(reset($files), "Try to load a file that doesn't exist in the database fails.");
  $this
    ->assertFileHooksCalled([]);
}