Skip to content

Fake file creation fails #30641

@vroomfondle

Description

@vroomfondle
  • Laravel Version: 6.5.2
  • PHP Version: 7.3
  • Database Driver & Version:
    n/a

Description:

In our tests we create a fake file:

        use Illuminate\Http\UploadedFile;
        $uploadedFile = UploadedFile::fake()->create('foo.docx', '20');

This causes an error:

ErrorException : file_put_contents() expects parameter 1 to be a valid path, resource given
 /var/www/api/vendor/laravel/framework/src/Illuminate/Http/Testing/FileFactory.php:21
 /var/www/api/tests/Api/v2/File/Controllers/FileControllerTest.php:42

I believe the bug was introduced in 181db51

The return value of tmpfile() is being passed to file_put_contents(). However, tmpfile() returns a resource, whereas file_put_contents() expects a string containing a path.

Steps To Reproduce:

        use Illuminate\Http\UploadedFile;
        $uploadedFile = UploadedFile::fake()->create('foo.docx', '20');

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions