3 namespace Drupal\Tests\file\Kernel;
5 use Drupal\file\Entity\File;
8 * File URI field item test.
12 * @see \Drupal\file\Plugin\Field\FieldType\FileUriItem
13 * @see \Drupal\file\FileUrl
15 class FileUriItemTest extends FileManagedUnitTestBase {
18 * Tests the file entity override of the URI field.
20 public function testCustomFileUriField() {
21 $uri = 'public://druplicon.txt';
23 // Create a new file entity.
24 $file = File::create([
26 'filename' => 'druplicon.txt',
28 'filemime' => 'text/plain',
29 'status' => FILE_STATUS_PERMANENT,
31 file_put_contents($file->getFileUri(), 'hello world');
35 $this->assertSame($uri, $file->uri->value);
36 $expected_url = base_path() . $this->siteDirectory . '/files/druplicon.txt';
37 $this->assertSame($expected_url, $file->uri->url);