FileUrlGenerator and stream wrapper create broken URLs in kernel tests

Created on 13 November 2023, 8 months ago
Updated 15 November 2023, 8 months ago

Problem/Motivation

The following kernel test code:

    $this->container->get('file_system')->copy($this->root . '/core/misc/druplicon.png', 'public://druplicon.png');
    $image_file = $this->entityTypeManager->getStorage('file')->create([
      'uri' => 'public://druplicon.png',
    ]);
    $image_file->save();

    dump($image_file->getFileUri());
    dump($image_file->createFileUrl(FALSE));
    dump($image_file->createFileUrl());

produces this output:

"public://druplicon.png"

"http://localhost/vfs://root/sites/simpletest/86401788/files/druplicon.png"

"/vfs://root/sites/simpletest/86401788/files/druplicon.png"

The last two values look wrong.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
File system 

Last updated about 5 hours ago

Created by

🇬🇧United Kingdom joachim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024