Skip to content

File upload in functional test not working after #30895 #31329

@jeroendk

Description

@jeroendk

Symfony version(s) affected: 3.4.25

Description
According to the docs you can test a form with a file field as follow:

// uploads a file
$form['photo']->upload('/path/to/lucas.jpg');

In Symfony 3.4.24 this works, in 3.4.25 it does not because the form errors are added & isValid on the UploadedFile returns false.

elseif ($requestHandler->isFileUpload($event->getData()) && method_exists($requestHandler, 'getUploadFileError') && null !== $errorCode = $requestHandler->getUploadFileError($event->getData())) {
    $form->addError($this->getFileUploadError($errorCode)); 
}

The related change is added in #30895 in the file src/Symfony/Component/Form/Extension/Core/Type/FileType.php on line 80

Not sure why this worked before this change and how to get it working again..

How to reproduce
Create a functional test with an upload form and submit it

$form['photo']->upload('/path/to/lucas.jpg');
$client->submit($form);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy