FileUrlGenerator and stream wrapper create broken URLs in kernel tests

Created on 13 November 2023, about 1 year ago
Updated 15 November 2023, about 1 year 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 2 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.71.5 2024