function LoadTest::testLoadMissingFilepath

Same name in other branches
  1. 9 core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testLoadMissingFilepath()
  2. 8.9.x core/modules/file/tests/src/Kernel/LoadTest.php \Drupal\Tests\file\Kernel\LoadTest::testLoadMissingFilepath()
  3. 10 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 28

Class

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

Namespace

Drupal\Tests\file\Kernel

Code

public function testLoadMissingFilepath() : void {
    $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([]);
}

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